Skip to content

Commit 7016f35

Browse files
committed
Improve e2e test messages
1 parent 87b60ba commit 7016f35

File tree

6 files changed

+60
-45
lines changed

6 files changed

+60
-45
lines changed

client/e2e/pages/feedback-history-details.page.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,31 @@ export class FeedbackHistoryDetailsPage {
2121
async matchPending(type: 'sentRequest' | 'receivedRequest', persona: Persona, message: string) {
2222
await this.page.waitForURL('/fr/history/id/**');
2323

24-
await expect(this.page.getByRole('heading', { name: this.headingMap[type] })).toBeVisible();
24+
await expect(
25+
this.page.getByRole('heading', { name: this.headingMap[type] }),
26+
`Page heading should be "${this.headingMap[type]}"`,
27+
).toBeVisible();
2528

26-
await expect(this.page.getByText(persona)).toBeVisible();
29+
await expect(this.page.getByText(persona), 'Feedback "persona" should be visible').toBeVisible();
2730

28-
await expect(this.page.getByText(message)).toBeVisible();
31+
await expect(this.page.getByText(message), 'Feedback "message" should be visible').toBeVisible();
2932
}
3033

3134
async matchDone(type: 'received' | 'given', persona: Persona, details: Details) {
3235
await this.page.waitForURL('/fr/history/id/**');
3336

34-
await expect(this.page.getByRole('heading', { name: this.headingMap[type] })).toBeVisible();
37+
await expect(
38+
this.page.getByRole('heading', { name: this.headingMap[type] }),
39+
`Page heading should be "${this.headingMap[type]}"`,
40+
).toBeVisible();
3541

36-
await expect(this.page.getByText(persona)).toBeVisible();
42+
await expect(this.page.getByText(persona), 'Feedback "persona" should be visible').toBeVisible();
3743

3844
if (details.message) {
39-
await expect(this.page.getByText(details.message)).toBeVisible();
45+
await expect(this.page.getByText(details.message), 'Feedback "message" should be visible').toBeVisible();
4046
}
41-
await expect(this.page.getByText(details.positive)).toBeVisible();
42-
await expect(this.page.getByText(details.negative)).toBeVisible();
43-
await expect(this.page.getByText(details.comment)).toBeVisible();
47+
await expect(this.page.getByText(details.positive), 'Feedback "positive" should be visible').toBeVisible();
48+
await expect(this.page.getByText(details.negative), 'Feedback "negative" should be visible').toBeVisible();
49+
await expect(this.page.getByText(details.comment), 'Feedback "comment" should be visible').toBeVisible();
4450
}
4551
}

client/e2e/pages/give-requested-feedback.page.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export class GiveRequestedFeedbackPage {
1414
async give(persona: Persona, details: Details) {
1515
await this.page.waitForURL('/fr/give-requested/token/**');
1616

17-
await expect(this.page.getByLabel('Email de votre collègue')).toHaveValue(persona);
17+
await expect(
18+
this.page.getByLabel('Email de votre collègue'),
19+
'Feedback receiver should be filled in correctly',
20+
).toHaveValue(persona);
1821

1922
await this.page.getByText('Points positifs').fill(details.positive);
2023
await this.page.getByText("Axes d'améliorations").fill(details.negative);

client/e2e/pages/manager.page.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,35 @@ export class ManagerPage {
3232
async matchPendingFeedback(giver: Persona, receiver: Persona, message: string) {
3333
await this.page.waitForURL('/fr/manager/document/**');
3434

35-
await expect(this.page.getByRole('heading', { name: 'Demande de feedZback partagé' })).toBeVisible();
35+
await expect(
36+
this.page.getByRole('heading', { name: 'Demande de feedZback partagé' }),
37+
'Page heading should be correct',
38+
).toBeVisible();
3639

37-
await expect(this.page.getByText(giver)).toBeVisible();
38-
await expect(this.page.getByText(receiver)).toBeVisible();
40+
await expect(this.page.getByText(giver), `Feedback giver should be "${giver}"`).toBeVisible();
41+
await expect(this.page.getByText(receiver), `Feedback receiver should be "${receiver}"`).toBeVisible();
3942

4043
if (message) {
41-
await expect(this.page.getByText(message)).toBeVisible();
44+
await expect(this.page.getByText(message), 'Feedback "message" should be visible').toBeVisible();
4245
}
4346
}
4447

4548
async matchDoneFeedback(giver: Persona, receiver: Persona, details: Details) {
4649
await this.page.waitForURL('/fr/manager/document/**');
4750

48-
await expect(this.page.getByRole('heading', { name: 'FeedZback partagé' })).toBeVisible();
51+
await expect(
52+
this.page.getByRole('heading', { name: 'FeedZback partagé' }),
53+
'Page heading should be correct',
54+
).toBeVisible();
4955

50-
await expect(this.page.getByText(giver)).toBeVisible();
51-
await expect(this.page.getByText(receiver)).toBeVisible();
56+
await expect(this.page.getByText(giver), `Feedback giver should be "${giver}"`).toBeVisible();
57+
await expect(this.page.getByText(receiver), `Feedback receiver should be "${receiver}"`).toBeVisible();
5258

5359
if (details.message) {
54-
await expect(this.page.getByText(details.message)).toBeVisible();
60+
await expect(this.page.getByText(details.message), 'Feedback "message" should be visible').toBeVisible();
5561
}
56-
await expect(this.page.getByText(details.positive)).toBeVisible();
57-
await expect(this.page.getByText(details.negative)).toBeVisible();
58-
await expect(this.page.getByText(details.comment)).toBeVisible();
62+
await expect(this.page.getByText(details.positive), 'Feedback "positive" should be visible').toBeVisible();
63+
await expect(this.page.getByText(details.negative), 'Feedback "negative" should be visible').toBeVisible();
64+
await expect(this.page.getByText(details.comment), 'Feedback "comment" should be visible').toBeVisible();
5965
}
6066
}

client/e2e/pages/user-menu.page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { expect, Page } from '@playwright/test';
33
export class UserMenuPage {
44
constructor(private page: Page) {}
55

6-
async logout() {
7-
expect(this.page.url()).not.toMatch(/sign-in/);
6+
async signOut() {
7+
expect(this.page.url(), 'Should not to be in sign-in page when trying to sign-out').not.toMatch(/sign-in/);
88

99
await this.page.getByLabel('Menu utilisateur').click();
1010
await this.page.getByRole('menuitem', { name: 'Se déconnecter' }).click();

client/e2e/requested-feedback.spec.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ test('Requested feedback', async ({ page }) => {
2525

2626
await new RequestFeedbackPage(page).gotoAndRequest([Persona.Bernard, Persona.Charles], feedbackDetails.message);
2727

28-
// See the personas in the success page
29-
await expect(page.getByText(Persona.Bernard)).toBeVisible();
30-
await expect(page.getByText(Persona.Charles)).toBeVisible();
28+
await expect(page.getByText(Persona.Bernard), 'Recipient should be visible in the success page').toBeVisible();
29+
await expect(page.getByText(Persona.Charles), 'Recipient should be visible in the success page').toBeVisible();
3130

3231
const alfredHistoryPage = new FeedbackHistoryPage(page);
3332
await alfredHistoryPage.goto('sentRequest');
@@ -36,15 +35,15 @@ test('Requested feedback', async ({ page }) => {
3635
const charlesDetailsLink = await alfredHistoryPage.findDetailsLink(Persona.Charles);
3736

3837
// See the personas in the history page
39-
await expect(bernardDetailsLink).toBeVisible();
40-
await expect(charlesDetailsLink).toBeVisible();
38+
await expect(bernardDetailsLink, 'Expected giver should be visible in the history page').toBeVisible();
39+
await expect(charlesDetailsLink, 'Expected giver should be visible in the history page').toBeVisible();
4140

4241
// Let's focus on Bernard
4342
await bernardDetailsLink.click();
4443

4544
await new FeedbackHistoryDetailsPage(page).matchPending('sentRequest', Persona.Bernard, feedbackDetails.message);
4645

47-
await new UserMenuPage(page).logout();
46+
await new UserMenuPage(page).signOut();
4847

4948
// ====== Bernard replies to Alfred request ======
5049

@@ -54,7 +53,10 @@ test('Requested feedback', async ({ page }) => {
5453
await bernardHistoryPage.goto('receivedRequest');
5554

5655
const alfredDetailsLink = await bernardHistoryPage.findDetailsLink(Persona.Alfred);
57-
await expect(alfredDetailsLink).toBeVisible();
56+
await expect(
57+
alfredDetailsLink,
58+
'Feedback receiver should be visible in the page "Répondre aux demandes de feedZback"',
59+
).toBeVisible();
5860
await alfredDetailsLink.click();
5961

6062
await new FeedbackHistoryDetailsPage(page).matchPending('receivedRequest', Persona.Alfred, feedbackDetails.message);
@@ -63,13 +65,12 @@ test('Requested feedback', async ({ page }) => {
6365

6466
await new GiveRequestedFeedbackPage(page).give(Persona.Alfred, feedbackDetails);
6567

66-
// See the persona in the success page
67-
await expect(page.getByText(Persona.Alfred)).toBeVisible();
68+
await expect(page.getByText(Persona.Alfred), 'Feedback receiver should be visible in the success page').toBeVisible();
6869
await page.getByRole('button', { name: 'Consulter le feedZback' }).click();
6970

7071
await new FeedbackHistoryDetailsPage(page).matchDone('given', Persona.Alfred, feedbackDetails);
7172

72-
await new UserMenuPage(page).logout();
73+
await new UserMenuPage(page).signOut();
7374

7475
// ====== Alfred has received feedback from Bernard ======
7576

@@ -79,29 +80,29 @@ test('Requested feedback', async ({ page }) => {
7980
await alfredHistoryPage2.goto('received');
8081

8182
const bernardDetailsLink2 = await alfredHistoryPage2.findDetailsLink(Persona.Bernard);
82-
await expect(bernardDetailsLink2).toBeVisible();
83+
await expect(bernardDetailsLink2, 'Feedback giver should be visible in the history page').toBeVisible();
8384
await bernardDetailsLink2.click();
8485

8586
await new FeedbackHistoryDetailsPage(page).matchDone('received', Persona.Bernard, feedbackDetails);
8687

8788
// ====== Alfred sets Daniel as its manager ======
8889

8990
await new SettingsPage(page).gotoAndSetManager(Persona.Daniel);
90-
await new UserMenuPage(page).logout();
91+
await new UserMenuPage(page).signOut();
9192

9293
// ====== Daniel can now view the feedbacks that Alfred has shared with him ======
9394

9495
await new SignInPage(page).gotoAndSignIn(Persona.Daniel);
9596

96-
await expect(page.getByRole('link', { name: 'Manager' })).toBeVisible();
97+
await expect(page.getByRole('link', { name: 'Manager' }), 'Manager link should be visible').toBeVisible();
9798

9899
const managerPage = new ManagerPage(page);
99100
managerPage.goto();
100101
managerPage.selectManaged(Persona.Alfred);
101102

102103
// View the feedback sent by Bernard
103104
const bernardDetailsLink3 = await managerPage.findGiverDetailsLink(Persona.Bernard);
104-
await expect(bernardDetailsLink3).toBeVisible();
105+
await expect(bernardDetailsLink3, 'Shared feedback (done) link should be visible').toBeVisible();
105106
await bernardDetailsLink3.click();
106107
await managerPage.matchDoneFeedback(Persona.Bernard, Persona.Alfred, feedbackDetails);
107108

@@ -111,7 +112,7 @@ test('Requested feedback', async ({ page }) => {
111112

112113
// View the feedback expected from Charles
113114
const charlesDetailsLink2 = await managerPage.findGiverDetailsLink(Persona.Charles);
114-
await expect(charlesDetailsLink2).toBeVisible();
115+
await expect(charlesDetailsLink2, 'Shared feedback (pending) link should be visible').toBeVisible();
115116
await charlesDetailsLink2.click();
116117
await managerPage.matchPendingFeedback(Persona.Charles, Persona.Alfred, feedbackDetails.message);
117118
});

client/e2e/spontaneous-feedback.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ test('Spontaneous feedback', async ({ page }) => {
2323

2424
await new GiveSpontaneousFeedbackPage(page).gotoAndGive(Persona.Alfred, feedbackDetails);
2525

26-
// See the persona in the success page
27-
await expect(page.getByText(Persona.Alfred)).toBeVisible();
26+
await expect(page.getByText(Persona.Alfred), 'Feedback receiver should be visible in the success page').toBeVisible();
2827
await page.getByRole('button', { name: 'Consulter le feedZback' }).click();
2928

3029
await new FeedbackHistoryDetailsPage(page).matchDone('given', Persona.Alfred, feedbackDetails);
3130

32-
await new UserMenuPage(page).logout();
31+
await new UserMenuPage(page).signOut();
3332

3433
// ====== Alfred has received feedback from Bernard ======
3534

@@ -39,28 +38,28 @@ test('Spontaneous feedback', async ({ page }) => {
3938
await alfredHistoryPage.goto('received');
4039

4140
const bernardDetailsLink = await alfredHistoryPage.findDetailsLink(Persona.Bernard);
42-
await expect(bernardDetailsLink).toBeVisible();
41+
await expect(bernardDetailsLink, 'Feedback giver should be visible in the history page').toBeVisible();
4342
await bernardDetailsLink.click();
4443

4544
await new FeedbackHistoryDetailsPage(page).matchDone('received', Persona.Bernard, feedbackDetails);
4645

4746
// ====== Alfred sets Daniel as its manager ======
4847

4948
await new SettingsPage(page).gotoAndSetManager(Persona.Daniel);
50-
await new UserMenuPage(page).logout();
49+
await new UserMenuPage(page).signOut();
5150

5251
// ====== Daniel can now view the feedback that Alfred has shared with him ======
5352

5453
await new SignInPage(page).gotoAndSignIn(Persona.Daniel);
5554

56-
await expect(page.getByRole('link', { name: 'Manager' })).toBeVisible();
55+
await expect(page.getByRole('link', { name: 'Manager' }), 'Manager link should be visible').toBeVisible();
5756

5857
const managerPage = new ManagerPage(page);
5958
managerPage.goto();
6059
managerPage.selectManaged(Persona.Alfred);
6160

6261
const managerDetailsLink = await managerPage.findGiverDetailsLink(Persona.Bernard);
63-
await expect(managerDetailsLink).toBeVisible();
62+
await expect(managerDetailsLink, 'Shared feedback link should be visible').toBeVisible();
6463
await managerDetailsLink.click();
6564

6665
await managerPage.matchDoneFeedback(Persona.Bernard, Persona.Alfred, feedbackDetails);

0 commit comments

Comments
 (0)