-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#38] Implement integration test for Question page and Question Compl…
…ete page
- Loading branch information
Showing
6 changed files
with
129 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
describe('Question Complete screen', () => { | ||
context('given the Question Complete screen is opened', () => { | ||
beforeEach(() => { | ||
cy.signIn(); | ||
cy.interceptWithDelay('GET', '**/api/v1/surveys/*', 200, { | ||
statusCode: 200, | ||
fixture: 'Survey/Detail/valid.json', | ||
}); | ||
cy.interceptWithDelay('GET', '**/api/v1/surveys*', 200, { | ||
statusCode: 200, | ||
fixture: 'Survey/List/valid.json', | ||
}); | ||
cy.interceptWithDelay('GET', '**/api/v1/me', 200, { | ||
statusCode: 200, | ||
fixture: 'User/valid.json', | ||
}); | ||
cy.interceptWithDelay('POST', '**/responses', 200, { | ||
statusCode: 201, | ||
fixture: 'Survey/Submit/valid.json', | ||
}); | ||
}); | ||
it('navigates to the Home screen after 3 seconds', () => { | ||
cy.visit('/surveys/d5de6a8f8f5f1cfe51bc/questions/complete'); | ||
|
||
cy.location().should((location) => { | ||
expect(location.pathname).to.equal('/'); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { surveyScreenTestIds } from '../Survey/index.spec'; | ||
|
||
const questionScreenTestIds = { | ||
index: 'question__index', | ||
title: 'question__title', | ||
answer: 'question__answer', | ||
closeButton: 'question__close-button', | ||
nextButton: 'question__next-button', | ||
submitButton: 'question__submit-button', | ||
}; | ||
|
||
const confirmDialogDataTestIds = { | ||
positiveButton: 'confirm-dialog__positive-button', | ||
}; | ||
|
||
describe('Question screen', () => { | ||
context('given the submit button is clicked', () => { | ||
context('given the API responses returns success result', () => { | ||
beforeEach(() => { | ||
cy.signIn(); | ||
cy.interceptWithDelay('GET', '**/api/v1/surveys/*', 200, { | ||
statusCode: 200, | ||
fixture: 'Survey/Detail/valid.json', | ||
}); | ||
cy.interceptWithDelay('GET', '**/api/v1/surveys*', 200, { | ||
statusCode: 200, | ||
fixture: 'Survey/List/valid.json', | ||
}); | ||
cy.interceptWithDelay('GET', '**/api/v1/me', 200, { | ||
statusCode: 200, | ||
fixture: 'User/valid.json', | ||
}); | ||
cy.interceptWithDelay('POST', '**/responses', 200, { | ||
statusCode: 201, | ||
fixture: 'Survey/Submit/valid.json', | ||
}); | ||
}); | ||
|
||
it('navigates to the Question Complete screen', () => { | ||
cy.visit('/'); | ||
cy.visit('/surveys/d5de6a8f8f5f1cfe51bc'); | ||
|
||
// Go to Question screen | ||
cy.findByTestId(surveyScreenTestIds.startSurveyButton).click(); | ||
|
||
cy.findByTestId(questionScreenTestIds.nextButton).click(); | ||
cy.findByTestId(questionScreenTestIds.submitButton).click(); | ||
|
||
cy.location({ timeout: 1000 }).should((location) => { | ||
expect(location.pathname).to.equal('/surveys/d5de6a8f8f5f1cfe51bc/questions/complete'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
context('given the close button is clicked', () => { | ||
context('given the Positive button of the confirm dialog is clicked', () => { | ||
beforeEach(() => { | ||
cy.signIn(); | ||
cy.interceptWithDelay('GET', '**/api/v1/surveys/*', 200, { | ||
statusCode: 200, | ||
fixture: 'Survey/Detail/valid.json', | ||
}); | ||
cy.interceptWithDelay('GET', '**/api/v1/surveys*', 200, { | ||
statusCode: 200, | ||
fixture: 'Survey/List/valid.json', | ||
}); | ||
cy.interceptWithDelay('GET', '**/api/v1/me', 200, { | ||
statusCode: 200, | ||
fixture: 'User/valid.json', | ||
}); | ||
}); | ||
|
||
it('navigates back to Home', () => { | ||
cy.visit('/'); | ||
cy.visit('/surveys/d5de6a8f8f5f1cfe51bc'); | ||
|
||
// Go to Question screen | ||
cy.findByTestId(surveyScreenTestIds.startSurveyButton).click(); | ||
|
||
cy.findByTestId(questionScreenTestIds.closeButton).click(); | ||
cy.findByTestId(confirmDialogDataTestIds.positiveButton).click(); | ||
|
||
cy.location().should((location) => { | ||
expect(location.pathname).to.equal('/'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"errors": [ | ||
{ | ||
"detail": "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client." | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |