|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | +import { configs, test } from '@utils/test/playwright'; |
| 3 | +import type { E2EPage, E2EPageOptions, ScreenshotFn } from '@utils/test/playwright'; |
| 4 | + |
| 5 | +class TabButtonFixture { |
| 6 | + readonly page: E2EPage; |
| 7 | + |
| 8 | + constructor(page: E2EPage) { |
| 9 | + this.page = page; |
| 10 | + } |
| 11 | + |
| 12 | + async goto(config: E2EPageOptions) { |
| 13 | + const { page } = this; |
| 14 | + await page.goto(`/src/components/tab-button/test/shape`, config); |
| 15 | + } |
| 16 | + |
| 17 | + async screenshot(screenshotModifier: string, screenshot: ScreenshotFn, buttonId: string) { |
| 18 | + const { page } = this; |
| 19 | + |
| 20 | + const screenshotString = screenshot(`tab-button-${screenshotModifier}`); |
| 21 | + const tabButton = page.locator(buttonId); |
| 22 | + |
| 23 | + await expect(tabButton).toHaveScreenshot(screenshotString); |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +/** |
| 28 | + * This behavior does not vary across directions. |
| 29 | + */ |
| 30 | +configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ config, screenshot, title }) => { |
| 31 | + test.describe(title('tab-button: shape'), () => { |
| 32 | + let tabButtonFixture: TabButtonFixture; |
| 33 | + |
| 34 | + test.beforeEach(async ({ page }) => { |
| 35 | + tabButtonFixture = new TabButtonFixture(page); |
| 36 | + await tabButtonFixture.goto(config); |
| 37 | + }); |
| 38 | + |
| 39 | + test('should render the default toast', async () => { |
| 40 | + await tabButtonFixture.screenshot('shape-round', screenshot, '#default-tab-button'); |
| 41 | + }); |
| 42 | + |
| 43 | + test('should render a soft toast', async () => { |
| 44 | + await tabButtonFixture.screenshot('shape-soft', screenshot, '#soft-tab-button'); |
| 45 | + }); |
| 46 | + |
| 47 | + test('should render a round toast', async () => { |
| 48 | + await tabButtonFixture.screenshot('shape-round', screenshot, '#round-tab-button'); |
| 49 | + }); |
| 50 | + |
| 51 | + test('should render a rectangular toast', async () => { |
| 52 | + await tabButtonFixture.screenshot('shape-rectangular', screenshot, '#rect-tab-button'); |
| 53 | + }); |
| 54 | + }); |
| 55 | +}); |
0 commit comments