Skip to content

Commit a840939

Browse files
fixed failing tests (#255)
1 parent fec3043 commit a840939

File tree

9 files changed

+115
-104
lines changed

9 files changed

+115
-104
lines changed

E2E/pageObjects/game.page.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ const locator = {
5656
chessPieceOnBoard: (tile: string, chessPiece: string) =>
5757
`//*[@data-testid='chess-tile-${tile}']//img[@alt='${chessPiece} icon']`,
5858
avatarOnBoard: (tile: string) =>
59-
`//*[@data-testid='chess-tile-${tile}']//span[@class='ant-avatar-string']`,
59+
`//*[@data-testid='chess-tile-${tile}']//*[contains(@data-testid, 'default-avatar-square')]`,
6060
avatarPictureOnBoard: (tile: string) =>
61-
`//*[@data-testid='chess-tile-${tile}']//div[@class='bubble-container']//img[@alt='profile pic']`,
61+
`//*[@data-testid='chess-tile-${tile}']//*[contains(@data-testid,'custom-avatar-square-')]`,
6262
openedPopUp: '//*[contains(@class, "pop-over-opened")]',
6363
pointsOnBoard: (tile: string, value: number) =>
6464
`//*[@data-testid='chess-tile-${tile}']//*[contains(text(), '${value}SP')]`,
@@ -109,13 +109,15 @@ const locator = {
109109
newRoom: "#dropdown-create-new-room",
110110
},
111111
chessBoardPopUp: {
112-
square: '//*[@class="pop-over-title" and contains(text(), "Square ")]',
112+
square:
113+
'//*[contains(@class,"pop-over-title") and contains(text(), "Square ")]',
113114
chessPiece: '//*[@class="pop-up-figure-icon margin-r-xs"]',
114115
avatar:
115116
'//*[contains(@class, "pop-over")]//*[contains(@class, "ant-avatar-circle")]',
116117
player: (username: string) =>
117118
`//*[contains(@class, "pop-over")]//*[contains(text(), "${username}")]`,
118-
score: '//*[contains(@class, "pop-over")]//*[@class = "score"]//span',
119+
score:
120+
'//*[contains(@class, "pop-over")]//*[contains(@class, "score")]//span',
119121
},
120122
};
121123

@@ -153,10 +155,10 @@ export = {
153155
I.click(locator.chessBoard.chessTile(tile));
154156
},
155157

156-
voteIsVisible: (chessPiece: ChessPiece, tile: string) => {
158+
voteIsVisible: async (chessPiece: ChessPiece, tile: string) => {
157159
I.seeElement(locator.chessBoard.avatarOnBoard(tile));
158-
assertions.chessPieceOnBoard(chessPiece, tile);
159-
assertions.SPOnBoard(chessPiece, tile);
160+
await assertions.chessPieceOnBoard(chessPiece, tile);
161+
await assertions.SPOnBoard(chessPiece, tile);
160162
},
161163

162164
voteIsNotVisible: (chessPiece: ChessPiece, tile: string) => {
@@ -203,9 +205,12 @@ export = {
203205
I.seeElement(locator.buttons.skipButtonHighlighted);
204206
},
205207

206-
voteAndCheckThatVoteIsVisible: (chessPiece: ChessPiece, tile: string) => {
208+
voteAndCheckThatVoteIsVisible: async (
209+
chessPiece: ChessPiece,
210+
tile: string
211+
) => {
207212
game.vote(chessPiece, tile);
208-
game.voteIsVisible(chessPiece, tile);
213+
await game.voteIsVisible(chessPiece, tile);
209214
},
210215

211216
openPopUp(chessTile: string) {

E2E/tests/avatarUpload.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Scenario(
8585
session(username.user2, () => {
8686
login.voterLoginIntoCreatedGameRoom(url, username.user2);
8787
});
88-
game.voteAndCheckThatVoteIsVisible(ChessPieces.rook, ChessTile.a1);
88+
await game.voteAndCheckThatVoteIsVisible(ChessPieces.rook, ChessTile.a1);
8989
game.uploadAvatarPhoto(imageLink.dogImageLink);
9090
await game.confirmAvatarPhotoWhenImageLinkIsValid(imageLink.dogImageLink);
9191
session(username.user2, async () => {
@@ -95,8 +95,8 @@ Scenario(
9595
);
9696
I.assertEqual(imageLink.dogImageLink, firstPlayersImageOnThePlayersList);
9797
game.voteIsNotVisible(ChessPieces.rook, ChessTile.a1);
98-
game.voteAndCheckThatVoteIsVisible(ChessPieces.pawn, ChessTile.b3);
99-
I.waitForText("Game complete");
98+
await game.voteAndCheckThatVoteIsVisible(ChessPieces.pawn, ChessTile.b3);
99+
I.seeElement(game.locator.playersList.totalSP);
100100
game.avatarPictureIsVisibleOnTheBoard(ChessPieces.rook, ChessTile.a1);
101101
});
102102
}

E2E/tests/gameComplete.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Scenario("Game completes automatically after last voter votes", async () => {
1515
I.click(game.locator.chessPieces.chessPiece(ChessPieces.rook.name));
1616
});
1717
game.vote(ChessPieces.pawn, ChessTile.c4);
18-
I.waitForText("Game complete");
18+
I.seeElement(game.locator.playersList.totalSP);
1919
session(username.user2, () => {
20-
I.waitForText("Game complete");
20+
I.seeElement(game.locator.playersList.totalSP);
2121
game.voteIsVisible(ChessPieces.pawn, ChessTile.c4);
2222
game.voteIsVisible(ChessPieces.knight, ChessTile.e4);
2323
I.seeElement(

E2E/tests/reenterGame.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Scenario(
2020
I.seeElement(game.locator.buttons.skipButtonHighlighted);
2121
});
2222
game.vote(ChessPieces.knight, ChessTile.e4);
23-
I.waitForText("Game complete");
23+
I.seeElement(game.locator.playersList.totalSP);
2424
}
2525
);
2626

@@ -54,7 +54,7 @@ Scenario(
5454
game.skipMove();
5555
I.refreshPage();
5656
I.seeElement(game.locator.buttons.skipButtonHighlighted);
57-
I.waitForText("Game complete");
57+
I.seeElement(game.locator.playersList.totalSP);
5858
});
5959
}
6060
);
@@ -69,12 +69,12 @@ Scenario(
6969
game.voteAndCheckThatVoteIsVisible(ChessPieces.pawn, ChessTile.a1);
7070
});
7171
game.voteAndCheckThatVoteIsVisible(ChessPieces.knight, ChessTile.e4);
72-
I.waitForText("Game complete");
72+
I.seeElement(game.locator.playersList.totalSP);
7373
const actualFinalScoreBeforeNavigating = await I.grabNumberFrom(
7474
game.locator.playersList.totalSP
7575
);
7676
game.navigateBackAndForward();
77-
I.waitForText("Game complete");
77+
I.seeElement(game.locator.playersList.totalSP);
7878
game.voteIsVisible(ChessPieces.pawn, ChessTile.a1);
7979
game.voteIsVisible(ChessPieces.knight, ChessTile.e4);
8080
const actualFinalScoreAfterNavigating = await I.grabNumberFrom(
@@ -99,7 +99,7 @@ Scenario("Player refreshes browser when he already finished move", async () => {
9999
});
100100
game.voteIsNotVisible(ChessPieces.pawn, ChessTile.a1);
101101
game.voteAndCheckThatVoteIsVisible(ChessPieces.knight, ChessTile.e4);
102-
I.waitForText("Game complete");
102+
I.seeElement(game.locator.playersList.totalSP);
103103
game.voteIsVisible(ChessPieces.pawn, ChessTile.a1);
104104
game.voteIsVisible(ChessPieces.knight, ChessTile.e4);
105105
});

E2E/tests/restartGame.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ const { I, login, game } = inject();
99
Scenario("Board is cleared after clicking restart game button", async () => {
1010
login.firstVoterLogin(username.user1);
1111
const url = await I.grabCurrentUrl();
12-
session(username.user2, () => {
12+
session(username.user2, async () => {
1313
login.voterLoginIntoCreatedGameRoom(url, username.user2);
14-
game.voteAndCheckThatVoteIsVisible(ChessPieces.bishop, ChessTile.a1);
14+
await game.voteAndCheckThatVoteIsVisible(ChessPieces.bishop, ChessTile.a1);
1515
});
16-
game.voteAndCheckThatVoteIsVisible(ChessPieces.bishop, ChessTile.c4);
17-
I.waitForText("Game complete");
16+
await game.voteAndCheckThatVoteIsVisible(ChessPieces.bishop, ChessTile.c4);
17+
I.seeElement(game.locator.playersList.totalSP);
1818
I.click(game.locator.buttons.restartGame);
1919
game.voteIsNotVisible(ChessPieces.bishop, ChessTile.c4);
2020
game.voteIsNotVisible(ChessPieces.bishop, ChessTile.a1);

E2E/tests/skipMove.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Scenario(
1212
async () => {
1313
login.firstVoterLogin(username.user1);
1414
const url = await I.grabCurrentUrl();
15-
session(username.user2, () => {
15+
session(username.user2, async () => {
1616
login.voterLoginIntoCreatedGameRoom(url, username.user2);
17-
game.voteAndCheckThatVoteIsVisible(ChessPieces.pawn, ChessTile.a1);
17+
await game.voteAndCheckThatVoteIsVisible(ChessPieces.pawn, ChessTile.a1);
1818
I.waitForElement(game.locator.playersList.voterScoreIcon(username.user2));
1919
game.skipMove();
2020
game.voteIsNotVisible(ChessPieces.pawn, ChessTile.a1);
@@ -32,18 +32,18 @@ Scenario("Player who makes the move last skips", async () => {
3232
session(username.user2, () => {
3333
login.voterLoginIntoCreatedGameRoom(url, username.user2);
3434
});
35-
session(username.user3, () => {
35+
session(username.user3, async () => {
3636
login.voterLoginIntoCreatedGameRoom(url, username.user3);
37-
game.voteAndCheckThatVoteIsVisible(ChessPieces.pawn, ChessTile.a1);
37+
await game.voteAndCheckThatVoteIsVisible(ChessPieces.pawn, ChessTile.a1);
3838
});
39-
session(username.user2, () => {
39+
session(username.user2, async () => {
4040
I.waitForElement(game.locator.playersList.playerDoneIcon(username.user3));
41-
game.voteAndCheckThatVoteIsVisible(ChessPieces.rook, ChessTile.b3);
41+
await game.voteAndCheckThatVoteIsVisible(ChessPieces.rook, ChessTile.b3);
4242
});
4343
I.waitForElement(game.locator.playersList.playerDoneIcon(username.user2));
4444
I.waitForElement(game.locator.playersList.playerDoneIcon(username.user3));
4545
game.skipMove();
46-
I.waitForText("Game complete");
46+
I.seeElement(game.locator.playersList.totalSP);
4747
});
4848

4949
Scenario("Player who makes the move first skips", async () => {
@@ -56,19 +56,19 @@ Scenario("Player who makes the move first skips", async () => {
5656
login.voterLoginIntoCreatedGameRoom(url, username.user3);
5757
});
5858
game.skipMove();
59-
session(username.user2, () => {
59+
session(username.user2, async () => {
6060
I.waitForElement(
6161
game.locator.playersList.playerSkippedIcon(username.user1)
6262
);
63-
game.voteAndCheckThatVoteIsVisible(ChessPieces.rook, ChessTile.b3);
63+
await game.voteAndCheckThatVoteIsVisible(ChessPieces.rook, ChessTile.b3);
6464
});
65-
session(username.user3, () => {
65+
session(username.user3, async () => {
6666
I.waitForElement(
6767
game.locator.playersList.playerSkippedIcon(username.user1)
6868
);
6969
I.waitForElement(game.locator.playersList.playerDoneIcon(username.user2));
70-
game.voteAndCheckThatVoteIsVisible(ChessPieces.pawn, ChessTile.a1);
71-
I.waitForText("Game complete");
70+
await game.voteAndCheckThatVoteIsVisible(ChessPieces.pawn, ChessTile.a1);
71+
I.seeElement(game.locator.playersList.totalSP);
7272
});
7373
});
7474

@@ -83,18 +83,18 @@ Scenario(
8383
session(username.user3, () => {
8484
login.voterLoginIntoCreatedGameRoom(url, username.user3);
8585
});
86-
game.voteAndCheckThatVoteIsVisible(ChessPieces.rook, ChessTile.b3);
86+
await game.voteAndCheckThatVoteIsVisible(ChessPieces.rook, ChessTile.b3);
8787
session(username.user2, () => {
8888
I.waitForElement(game.locator.playersList.playerDoneIcon(username.user1));
8989
game.skipMove();
9090
});
91-
session(username.user3, () => {
91+
session(username.user3, async () => {
9292
I.waitForElement(game.locator.playersList.playerDoneIcon(username.user1));
9393
I.waitForElement(
9494
game.locator.playersList.playerSkippedIcon(username.user2)
9595
);
96-
game.voteAndCheckThatVoteIsVisible(ChessPieces.pawn, ChessTile.a1);
97-
I.waitForText("Game complete");
96+
await game.voteAndCheckThatVoteIsVisible(ChessPieces.pawn, ChessTile.a1);
97+
I.seeElement(game.locator.playersList.totalSP);
9898
});
9999
}
100100
);

E2E/tests/spectatorView.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Scenario("Spectator doesn’t have to vote for game to be finished", async () =>
6767
game.voteAndCheckThatVoteIsVisible(ChessPieces.pawn, ChessTile.a1);
6868
});
6969
game.skipMove();
70-
I.waitForText("Game complete");
70+
I.seeElement(game.locator.playersList.totalSP);
7171
game.voteIsVisible(ChessPieces.pawn, ChessTile.a1);
7272
session(username.user3, () => {
7373
game.voteIsVisible(ChessPieces.pawn, ChessTile.a1);
@@ -88,14 +88,14 @@ Scenario("Spectator restarts previously finished game", async () => {
8888
});
8989
game.skipMove();
9090
session(username.user3, () => {
91-
I.waitForText("Game complete");
91+
I.seeElement(game.locator.playersList.totalSP);
9292
I.click(game.locator.buttons.restartGame);
9393
game.voteIsNotVisible(ChessPieces.pawn, ChessTile.a1);
9494
});
9595
game.voteAndCheckThatVoteIsVisible(ChessPieces.knight, ChessTile.e2);
9696
session(username.user2, () => {
9797
game.voteAndCheckThatVoteIsVisible(ChessPieces.king, ChessTile.d3);
98-
I.waitForText("Game complete");
98+
I.seeElement(game.locator.playersList.totalSP);
9999
game.voteIsVisible(ChessPieces.king, ChessTile.d3);
100100
game.voteIsVisible(ChessPieces.knight, ChessTile.e2);
101101
game.voteIsNotVisible(ChessPieces.pawn, ChessTile.a1);
@@ -133,7 +133,7 @@ Scenario("Spectators are displayed at the bottom of players list", async () => {
133133
game.vote(ChessPieces.king, ChessTile.c3);
134134
session(username.user3, () => {
135135
game.vote(ChessPieces.king, ChessTile.c3);
136-
I.waitForText("Game complete");
136+
I.seeElement(game.locator.playersList.totalSP);
137137
I.seeTextEquals(
138138
`${username.user2}`,
139139
game.locator.playersList.playerUsernameByIndex(3)

E2E/tests/teamList.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Scenario(
2626
session(username.user3, () => {
2727
I.click(game.locator.buttons.skip);
2828
I.click(game.locator.buttons.skipOtherPlayer(username.user1));
29-
I.waitForText("Game complete");
29+
I.seeElement(game.locator.playersList.totalSP);
3030
const expectedUserOrder = [
3131
username.user4,
3232
username.user2,

0 commit comments

Comments
 (0)