Skip to content

Commit 20121c7

Browse files
committed
fix(e2e): remove redundant stylePath options in screenshot checks
- Simplify screenshot utility calls by removing unnecessary `stylePath` parameter in tests. - Refactor masks and parameters for clarity and consistency across multiplatform and compose tests.
1 parent 062b573 commit 20121c7

3 files changed

Lines changed: 18 additions & 32 deletions

File tree

test/e2e/compose-multiplatform.spec.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ test.describe('Compose Multiplatform landing page', async () => {
2121
const href = await composePage.heroActionButton.getAttribute('href');
2222

2323
await checkScreenshot(composePage.hero, {
24-
stylePath: 'test/e2e/hide-sticky-banner.css',
25-
mask: [composePage.heroCarousel],
24+
mask: [composePage.heroCarousel]
2625
});
2726

2827
await composePage.heroActionButton.click();
@@ -34,33 +33,27 @@ test.describe('Compose Multiplatform landing page', async () => {
3433
await expect(composePage.platformsContent).toBeVisible();
3534
await expect(composePage.platformsItems).toHaveCount(4);
3635

37-
await checkScreenshot(composePage.platformsBlock, {
38-
stylePath: 'test/e2e/hide-sticky-banner.css',
39-
});
40-
})
36+
await checkScreenshot(composePage.platformsBlock);
37+
});
4138

4239
test('check features block', async () => {
4340
await expect(composePage.featuresBlock).toBeVisible();
44-
41+
4542
await expect(composePage.featureItems).not.toHaveCount(0);
46-
43+
4744
for (const title of await composePage.featureTitles.all()) {
4845
await expect(title).toBeVisible();
4946
await expect(title).not.toBeEmpty();
5047
}
5148

52-
await checkScreenshot(composePage.featuresBlock, {
53-
stylePath: 'test/e2e/hide-sticky-banner.css',
54-
});
49+
await checkScreenshot(composePage.featuresBlock);
5550
});
5651

5752
test('check quote section', async () => {
5853
await expect(composePage.quoteSection).toBeVisible();
5954
await expect(composePage.quoteCards).not.toHaveCount(0);
6055

61-
await checkScreenshot(composePage.quoteSection, {
62-
stylePath: 'test/e2e/hide-sticky-banner.css',
63-
});
56+
await checkScreenshot(composePage.quoteSection);
6457
});
6558

6659
test('check CTA block', async () => {
@@ -70,9 +63,7 @@ test.describe('Compose Multiplatform landing page', async () => {
7063
await expect(composePage.ctaBlockButton).toBeVisible();
7164
const href = await composePage.ctaBlockButton.getAttribute('href');
7265

73-
await checkScreenshot(composePage.ctaBlock, {
74-
stylePath: 'test/e2e/hide-sticky-banner.css',
75-
});
66+
await checkScreenshot(composePage.ctaBlock);
7667

7768
await composePage.ctaBlockButton.click();
7869
await expect(composePage.page).toHaveURL(new RegExp(`.*${href}$`));

test/e2e/multiplatform/multiplatform.spec.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { expect, Locator, test } from '@playwright/test';
22
import { MultiplatformPage } from '../../page/multiplatform-page';
3-
import { checkAnchor, checkScreenshot } from '../../utils';
4-
import { checkFullPageScreenshot } from '../../utils';
3+
import { checkAnchor, checkFullPageScreenshot, checkScreenshot } from '../../utils';
54

65
test.describe('Multiplatform landing page', async () => {
76
let multiplatformPage: MultiplatformPage;
@@ -15,7 +14,9 @@ test.describe('Multiplatform landing page', async () => {
1514
const { main, page } = multiplatformPage;
1615

1716
await checkFullPageScreenshot(page, {
18-
mask: [main.locator('[data-testid*="share-what-chip-content-"]')],
17+
mask: [
18+
main.locator('[data-testid*="share-what-chip-content-"]')
19+
]
1920
});
2021
});
2122

@@ -32,9 +33,7 @@ test.describe('Multiplatform landing page', async () => {
3233
const heroActionButton = multiplatformPage.heroActionButon;
3334
await expect(heroActionButton).toBeVisible();
3435

35-
await checkScreenshot(multiplatformPage.heroBanner, {
36-
stylePath: 'test/e2e/hide-sticky-banner.css',
37-
});
36+
await checkScreenshot(multiplatformPage.heroBanner);
3837

3938
const href = await heroActionButton.getAttribute('href');
4039
await heroActionButton.click();
@@ -86,9 +85,7 @@ test.describe('Multiplatform landing page', async () => {
8685
await expect(multiplatformPage.ctaBlockAction).toBeVisible();
8786
await expect(multiplatformPage.ctaBlockAction).not.toBeEmpty();
8887

89-
await checkScreenshot(multiplatformPage.ctaBlock, {
90-
stylePath: 'test/e2e/hide-sticky-banner.css',
91-
});
88+
await checkScreenshot(multiplatformPage.ctaBlock);
9289

9390
const href = await multiplatformPage.ctaBlockAction.getAttribute('href');
9491
await multiplatformPage.ctaBlockAction.click();
@@ -121,9 +118,7 @@ async function checkChooseWhatToShare({ page, main, shareWhatBlock }: Multiplatf
121118
await expect(link).toBeVisible();
122119
await expect(link).not.toBeEmpty();
123120

124-
await checkScreenshot(shareWhatBlock, {
125-
stylePath: 'test/e2e/hide-sticky-banner.css',
126-
});
121+
await checkScreenshot(shareWhatBlock);
127122

128123
// Check that links work as links
129124
const href = await link.getAttribute('href');

test/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export async function checkScreenshot(element: Locator | Page, options?: CheckSc
5353
animations: 'disabled',
5454
...(options || {}),
5555
clip,
56-
stylePath: ['test/production/production.css'].concat(options?.stylePath || []),
56+
stylePath: ['test/production/production.css'].concat(options?.stylePath || [])
5757
});
5858
});
5959
}
@@ -70,7 +70,7 @@ async function getClippingRect(
7070
x: box.x - padding,
7171
y: box.y - padding,
7272
width: box.width + padding * 2,
73-
height: box.height + padding * 2,
73+
height: box.height + padding * 2
7474
};
7575
}
7676
}
@@ -84,7 +84,7 @@ export async function checkFullPageScreenshot(page: Page, options?: CheckScreens
8484
await checkScreenshot(page, {
8585
...options,
8686
fullPage: true,
87-
mask: [page.locator('video[autoplay]'), ...(options?.mask || [])],
87+
mask: [page.locator('video[autoplay]'), ...(options?.mask || [])]
8888
});
8989
}
9090

0 commit comments

Comments
 (0)