Skip to content

Commit 7c518b2

Browse files
committed
test(ktl-4093): added test to case study anchor scrolling
1 parent ba8605f commit 7c518b2

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

test/e2e/case-studies.spec.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,17 @@ test.describe('Case-studies landing page', async () => {
7070

7171
expect(page.url()).toContain('type=server-side');
7272
});
73-
});
73+
74+
75+
test('Case-studies: should show the case card in the viewport when opening the page with anchor link', async ({ page }) => {
76+
const caseStudiesPage = new CaseStudiesPage(page);
77+
await caseStudiesPage.init();
78+
79+
const lastCaseCardId = await caseStudiesPage.gridItem.last().getAttribute('id');
80+
81+
await caseStudiesPage.init(lastCaseCardId);
82+
83+
const lastCard = caseStudiesPage.gridBlock.locator(`#${lastCaseCardId}`).first();
84+
await expect(lastCard).toBeInViewport();
85+
});
86+
});

test/page/case-studies-page.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ export class CaseStudiesPage implements PageWithGlobalSearch {
3838
this.gridItem = this.gridBlock.getByTestId('case-studies-card');
3939
}
4040

41-
async init() {
42-
await this.page.goto('/case-studies/');
41+
async init(caseId? : string) {
42+
const hash = caseId ? `#${caseId}` : '';
43+
await this.page.goto(`/case-studies/${hash}`);
4344
await this.layout.waitFor();
4445
}
4546

0 commit comments

Comments
 (0)