-
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.
- Loading branch information
1 parent
8df5d91
commit 10a1947
Showing
2 changed files
with
100 additions
and
0 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,98 @@ | ||
describe('Modal', () => { | ||
const clickCorrectNumberKey = () => { | ||
cy.get('.bg-focused').children().children('.invisible').then(($correctNumberTile) => { | ||
const correctNumber = $correctNumberTile.text() | ||
cy.findByTestId(`number-key-${correctNumber}`).click() | ||
}) | ||
} | ||
|
||
const clearWordplayByClicking = () => { | ||
for (let i = 0; i < 2; i++) { | ||
clickCorrectNumberKey(); | ||
} | ||
} | ||
|
||
const clearStage = () => { | ||
let level = 0; | ||
for (const number of [5, 3, 3, 3, 1]) { | ||
level++; | ||
for (let i = 0; i < number; i++) { | ||
cy.findByTestId('start-answering').click() | ||
for (let j = 0; j < level; j++) { | ||
clearWordplayByClicking(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
const clearReview = () => { | ||
for (let i = 0; i < 10; i++) { | ||
cy.findByTestId('start-answering').click() | ||
for (let j = 0; j < 5; j++) { | ||
clearWordplayByClicking(); | ||
} | ||
} | ||
} | ||
|
||
context('when the user clears stage 1', () => { | ||
context('when the user clicks "move to stage select" button', () => { | ||
it('moves to stage select page', () => { | ||
cy.visit('/stages/1') | ||
cy.wait(500) | ||
clearStage() | ||
cy.findByTestId('move-to-stage-select-button').click() | ||
cy.url().should('eq', Cypress.config().baseUrl + '/') | ||
}) | ||
}) | ||
|
||
context('when the user clicks "move to next stage" button', () => { | ||
it('moves to stage 2', () => { | ||
cy.visit('/stages/1') | ||
cy.wait(500) | ||
clearStage() | ||
cy.findByTestId('move-to-next-stage-button').click() | ||
cy.wait(500) | ||
cy.url().should('eq', Cypress.config().baseUrl + '/stages/2') | ||
}) | ||
}) | ||
}) | ||
|
||
context('when the user clears stage 10', () => { | ||
context('when the user clicks "move to next stage" button', () => { | ||
it('moves to review 1', () => { | ||
cy.setLocalStorage('gorogoropanda.com/clearedStage', 'u51'); | ||
cy.visit('/stages/10') | ||
cy.wait(500) | ||
clearStage() | ||
cy.findByTestId('move-to-next-stage-button').click() | ||
cy.wait(500) | ||
cy.url().should('eq', Cypress.config().baseUrl + '/reviews/1') | ||
}) | ||
}) | ||
}) | ||
|
||
context('when the user clears review 1', () => { | ||
context('when the user clicks "move to stage select" button', () => { | ||
it('moves to stage select page', () => { | ||
cy.setLocalStorage('gorogoropanda.com/clearedStage', 'ttw'); | ||
cy.visit('/reviews/1') | ||
cy.wait(500) | ||
clearReview() | ||
cy.findByTestId('move-to-stage-select-button').click() | ||
cy.url().should('eq', Cypress.config().baseUrl + '/') | ||
}) | ||
}) | ||
|
||
context('when the user clicks "move to next stage" button', () => { | ||
it('moves to the finale page', () => { | ||
cy.setLocalStorage('gorogoropanda.com/clearedStage', 'ttw'); | ||
cy.visit('/reviews/1') | ||
cy.wait(500) | ||
clearReview() | ||
cy.findByTestId('move-to-next-stage-button').click() | ||
cy.wait(500) | ||
cy.url().should('eq', Cypress.config().baseUrl + '/thank-you-for-playing') | ||
}) | ||
}) | ||
}) | ||
}) |
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