-
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.
Merge pull request #8 from aliaks-ei/add-e2e-tests
feat: provided e2e tests
- Loading branch information
Showing
9 changed files
with
103 additions
and
22 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,22 @@ | ||
name: E2E tests | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ['20'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
- run: npm run build | ||
- run: npm run test:e2e |
This file was deleted.
Oops, something went wrong.
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,33 @@ | ||
/* eslint-disable cypress/no-unnecessary-waiting */ | ||
const moveTilesAndWait = (key: "ArrowUp" | "ArrowDown" | "ArrowLeft" | "ArrowRight") => { | ||
cy.get("html").trigger("keyup", { key }); | ||
cy.wait(500); | ||
}; | ||
|
||
describe("Game", () => { | ||
it("should move tiles around the board and add new ones", () => { | ||
cy.visit("/"); | ||
|
||
// Trigger several arrow clicks | ||
moveTilesAndWait("ArrowUp"); | ||
moveTilesAndWait("ArrowDown"); | ||
moveTilesAndWait("ArrowLeft"); | ||
moveTilesAndWait("ArrowRight"); | ||
|
||
// At least one tile should appear after movements | ||
cy.get(".tile").should("have.length.at.least", 2); | ||
}); | ||
|
||
it("start a new game", () => { | ||
cy.visit("/"); | ||
|
||
// Trigger several arrow clicks | ||
moveTilesAndWait("ArrowUp"); | ||
moveTilesAndWait("ArrowLeft"); | ||
|
||
// Restart game | ||
cy.get("[data-testid='new-game']").click(); | ||
|
||
cy.get(".tile").should("have.length", 1); | ||
}); | ||
}); |
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,25 @@ | ||
const newGridSize = 4; | ||
const newNumOnbstacles = 2; | ||
|
||
describe("Settings", () => { | ||
it("should update board settings", () => { | ||
cy.visit("/"); | ||
|
||
// Open settings dialog | ||
cy.get("[data-testid='open-settings']").click(); | ||
cy.get("[data-testid='app-dialog']").should("be.visible"); | ||
|
||
// Update grid size | ||
cy.get("[data-testid='grid-size-setting']").select(newGridSize.toString()); | ||
|
||
// Update obstacles | ||
cy.get("[data-testid='obstacles-setting']").select(newNumOnbstacles.toString()); | ||
|
||
// Save settings | ||
cy.get("[data-testid='save-settings']").click(); | ||
|
||
// Vefiry game changed | ||
cy.get(".tile.tile--obstacle").should('have.length', newNumOnbstacles); | ||
cy.get("[data-testid='grid-item']").should('have.length', Math.pow(newGridSize, 2)); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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
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