Skip to content

Commit 0e939a0

Browse files
HusneShabbirHusneShabbir
andauthored
refactor(scorecard): improve e2e tests with specific card error checks (#2254)
* refactor(scorecard): improve e2e tests with specific card error checks - Add expectCardHasMissingPermission helper to HomePage - Add expectCardHasNoDataFound helper to HomePage - Update tests to verify error states on specific GitHub and Jira cards - Remove redundant expectCardVisible calls * style: fix prettier formatting in CatalogPage.ts --------- Co-authored-by: HusneShabbir <husneshabbir447@gmail.com>
1 parent d13a155 commit 0e939a0

3 files changed

Lines changed: 27 additions & 8 deletions

File tree

workspaces/scorecard/packages/app/e2e-tests/pages/CatalogPage.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ export class CatalogPage {
4949

5050
async openComponent(componentName: string) {
5151
const link = this.page.getByRole('link', { name: componentName });
52+
await this.page
53+
.getByRole('textbox', { name: 'Search' })
54+
.fill(componentName);
5255
await expect(link).toBeVisible({ timeout: 10000 });
5356
await link.click();
5457
}

workspaces/scorecard/packages/app/e2e-tests/pages/HomePage.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,23 @@ export class HomePage {
8787
this.page.getByText(percentage, { exact: true }),
8888
).toBeVisible();
8989
}
90+
91+
async expectCardHasMissingPermission(
92+
metricId: 'github.open_prs' | 'jira.open_issues',
93+
) {
94+
const card = this.getCard(metricId);
95+
await expect(card).toContainText(
96+
this.translations.errors.missingPermissionMessage,
97+
);
98+
}
99+
100+
async expectCardHasNoDataFound(
101+
metricId: 'github.open_prs' | 'jira.open_issues',
102+
) {
103+
const card = this.getCard(metricId);
104+
await expect(card).toContainText(this.translations.errors.noDataFound);
105+
await expect(card).toContainText(
106+
this.translations.errors.noDataFoundMessage,
107+
);
108+
}
90109
}

workspaces/scorecard/packages/app/e2e-tests/scorecard.test.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ test.describe('Scorecard Plugin Tests', () => {
202202
entityCount,
203203
),
204204
);
205+
206+
await homePage.expectCardHasMissingPermission('github.open_prs');
207+
await homePage.expectCardHasMissingPermission('jira.open_issues');
205208
});
206209

207210
test('Manage scorecards on Home page', async () => {
@@ -276,15 +279,9 @@ test.describe('Scorecard Plugin Tests', () => {
276279

277280
await homePage.navigateToHome();
278281
await page.reload();
279-
await homePage.expectCardVisible('github.open_prs');
280-
await homePage.expectCardVisible('jira.open_issues');
281282

282-
await expect(page.locator('article')).toContainText(
283-
translations.errors.noDataFound,
284-
);
285-
await expect(page.locator('article')).toContainText(
286-
translations.errors.noDataFoundMessage,
287-
);
283+
await homePage.expectCardHasNoDataFound('github.open_prs');
284+
await homePage.expectCardHasNoDataFound('jira.open_issues');
288285
});
289286

290287
test('Verify threshold tooltips', async () => {

0 commit comments

Comments
 (0)