Skip to content

Commit

Permalink
feat(functional): Add visual regression tests using latest deploys
Browse files Browse the repository at this point in the history
fix: update workflows yml
  • Loading branch information
avattipalli committed May 2, 2024
1 parent dfd5b25 commit 782588d
Show file tree
Hide file tree
Showing 160 changed files with 409 additions and 836 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-foxes-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

Migrate visual regression tests
4 changes: 2 additions & 2 deletions .github/workflows/playwright-visual-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Run Visual Regression Tests
timeout-minutes: 30
runs-on: macos-14
if: ${{ contains(fromJson('["Production – catalyst-storybook", "Preview – catalyst-storybook"]'), github.event.deployment_status.environment) }}
if: ${{ contains(fromJson('["Production – catalyst-latest", "Preview – catalyst-latest"]'), github.event.deployment_status.environment) }}

steps:
- name: Checkout code
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:
VERCEL_PROTECTION_BYPASS: ${{ secrets.VERCEL_PROTECTION_BYPASS_STORYBOOK }}
run: |
cd apps/core
npx playwright test tests/visual-regression/reactant/components/ --project=tests-chromium
npx playwright test tests/visual-regression/packages/components/ --project=tests-chromium
- uses: actions/upload-artifact@v4
if: failure()
Expand Down
2 changes: 1 addition & 1 deletion apps/core/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ config();
export default defineConfig({
testDir: './tests',
expect: {
toHaveScreenshot: { maxDiffPixels: 100 },
toHaveScreenshot: { maxDiffPixels: 500 },
},
fullyParallel: true,
reporter: 'html',
Expand Down
7 changes: 0 additions & 7 deletions apps/core/tests/catalyst-home-example.spec.ts

This file was deleted.

13 changes: 13 additions & 0 deletions apps/core/tests/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default {
SHOP_ALL: '/shop-all',
SAMPLE_ABLE_BREWING_SYSTEM: '/sample-able-brewing-system',
ORBIT_TERRARIUM_LARGE: '/orbit-terrarium-large',
BLOG: '/blog',
BATH_LUXURY: '/bath/towels/luxury',
QUICK_ADD_77: '/shop-all/?showQuickAdd=77',
QUICK_ADD_93: '/?showQuickAdd=93',
CONTACT_US: '/contact-us',
LOGIN: '/login',
FOG_LINEN_CHAMBRAY: '/fog-linen-chambray-towel-beige-stripe/',
PARFAIT_JAR: '/1-l-le-parfait-jar',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

const divStateOpen = 'div[data-state="open"]';
const divStateClosed = 'div[data-state="closed"]';

test('accordion expanded', async ({ page }) => {
await page.goto(routes.SHOP_ALL);

await expect(page.locator(divStateOpen).first()).toHaveScreenshot();
});

test('accordion closed', async ({ page }) => {
await page.goto(routes.SHOP_ALL);
await page.getByRole('button', { name: 'Brand' }).click();
await page.waitForLoadState('networkidle');
await page.locator(divStateClosed).first().waitFor({ state: 'visible' });

await expect(page.locator(divStateClosed).first()).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('badge with icon', async ({ page }) => {
await page.goto(routes.SAMPLE_ABLE_BREWING_SYSTEM);
await expect(
page.getByRole('heading', { level: 1, name: '[Sample] Able Brewing System' }),
).toBeVisible();
await page.getByRole('button', { name: 'Add to Cart' }).first().click();
await page.getByRole('link', { name: 'Cart Items 1' }).click();
await expect(page.getByRole('heading', { level: 1, name: 'Your cart' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Cart Items 1' })).toHaveScreenshot();

await page.getByRole('button', { name: 'Remove item from cart' }).first().click();
await expect(page.getByRole('heading', { name: 'Your cart is empty' })).toBeVisible();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('blog post card', async ({ page }) => {
await page.goto(routes.BLOG);
await expect(page.getByRole('heading', { name: 'Blog', exact: true })).toBeVisible();

await expect(
page.getByRole('heading', { name: 'Blog', exact: true }).locator('..'),
).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('breadcrumbs', async ({ page }) => {
await page.goto(routes.BATH_LUXURY);
await expect(page.getByLabel('Breadcrumb')).toBeVisible();

await expect(page.getByLabel('Breadcrumb')).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Primary button', async ({ page }) => {
await page.goto(routes.ORBIT_TERRARIUM_LARGE);
await expect(page.getByRole('button', { name: 'Add to cart' })).toBeVisible();

await expect(page.getByRole('button', { name: 'Add to cart' })).toHaveScreenshot();
});

test('Secondary button', async ({ page }) => {
await page.goto(routes.SHOP_ALL);
await expect(page.getByRole('button', { name: 'Update price' })).toBeVisible();

await expect(page.getByRole('button', { name: 'Update price' })).toHaveScreenshot();
});

test('As a child', async ({ page }) => {
await page.goto(routes.SAMPLE_ABLE_BREWING_SYSTEM);
await expect(
page.getByRole('heading', { level: 1, name: '[Sample] Able Brewing System' }),
).toBeVisible();

await page.getByRole('button', { name: 'Add to Cart' }).first().click();
await page.getByRole('link', { name: 'Cart Items 1' }).click();
await expect(page.getByText('Shipping cost')).toBeVisible();

await expect(page.getByRole('button', { name: 'Add' }).first()).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { expect, test } from '@playwright/test';

test('Carousel', async ({ page }) => {
await page.goto('/');
await page
.getByRole('region')
.filter({ has: page.getByRole('heading', { name: 'Featured products' }) })
.getByRole('tablist', { name: 'Slides' })
.scrollIntoViewIfNeeded();

await expect(
page
.getByRole('region')
.filter({ has: page.getByRole('heading', { name: 'Featured products' }) }),
).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

// eslint-disable-next-line @typescript-eslint/no-empty-function
test.skip('Disabled checkbox', async () => {});

// eslint-disable-next-line @typescript-eslint/no-empty-function
test.skip('Disabled checked checkbox', async () => {});

// eslint-disable-next-line @typescript-eslint/no-empty-function
test.skip('Checkbox with error variant', async () => {});

test('Checked checkbox with label', async ({ page }) => {
await page.goto(routes.SHOP_ALL);
await page.getByLabel('Common Good1 products').click();

await expect(page.getByLabel('Common Good1 products')).toHaveScreenshot();
});

// eslint-disable-next-line @typescript-eslint/no-empty-function
test.skip('Checkbox with custom icon', async () => {});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Counter default', async ({ page }) => {
await page.goto(routes.QUICK_ADD_77);
await expect(page.getByRole('spinbutton', { name: 'Number' })).toBeVisible();

await expect(page.getByRole('spinbutton', { name: 'Number' })).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Date picker', async ({ page }) => {
await page.goto(routes.QUICK_ADD_77);
await expect(page.getByRole('dialog').getByPlaceholder('MM/DD/YYYY')).toBeVisible();

await expect(page.getByRole('dialog').getByPlaceholder('MM/DD/YYYY')).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expect, test } from '@playwright/test';

test('Footer', async ({ page }) => {
await page.goto('/');
await expect(page.locator('section').filter({ hasText: 'CategoriesShop' })).toBeVisible();

await expect(page.locator('section').filter({ hasText: 'CategoriesShop' })).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions apps/core/tests/visual-regression/packages/components/form.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Form', async ({ page }) => {
await page.goto(routes.CONTACT_US);
await expect(page.getByRole('heading', { name: 'Contact Us' })).toBeVisible();

await expect(
page.getByRole('heading', { name: 'Contact Us' }).locator('..').locator('..'),
).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Gallery image', async ({ page }) => {
await page.goto(routes.SAMPLE_ABLE_BREWING_SYSTEM);
await expect(page.getByRole('figure').locator('img')).toBeVisible();

await expect(page.getByRole('figure').locator('img')).toHaveScreenshot();
});

test('Gallery thumbnail image', async ({ page }) => {
await page.goto(routes.SAMPLE_ABLE_BREWING_SYSTEM);
await expect(page.getByLabel('Thumbnail navigation')).toBeVisible();

await expect(page.getByLabel('Thumbnail navigation')).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Input with placeholder', async ({ page }) => {
await page.goto(routes.SAMPLE_ABLE_BREWING_SYSTEM);
await expect(
page.getByRole('heading', { level: 1, name: '[Sample] Able Brewing System' }),
).toBeVisible();
await page.getByRole('button', { name: 'Add to Cart' }).first().click();
await page.getByRole('link', { name: 'Cart Items 1' }).click();
await expect(page.getByText('Shipping cost')).toBeVisible();
await page.getByRole('button', { name: 'Add' }).first().click();
await expect(page.getByLabel('Suburb/city')).toBeVisible();

await expect(page.getByLabel('Suburb/city')).toHaveScreenshot();
});

test('Input error state', async ({ page }) => {
await page.goto(routes.CONTACT_US);
await expect(page.getByRole('button', { name: 'Submit form' })).toBeVisible();
await page.getByRole('button', { name: 'Submit form' }).click();

expect(await page.getByLabel('EmailRequired').screenshot()).toMatchSnapshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Label with input', async ({ page }) => {
await page.goto(routes.LOGIN);
await expect(page.getByText('Password', { exact: true })).toBeVisible();

await expect(
page.getByText('Password', { exact: true }).locator('..').locator('..'),
).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expect, test } from '@playwright/test';

test('Navigation menu', async ({ page }) => {
await page.goto('/');
await expect(page.getByRole('navigation', { name: 'Main' })).toBeVisible();

await expect(page.getByRole('navigation', { name: 'Main' })).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Pick list', async ({ page }) => {
await page.goto(routes.FOG_LINEN_CHAMBRAY);
await expect(page.getByLabel('Pick List')).toBeVisible();

await expect(page.getByLabel('Pick List').locator('..')).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Default radio group', async ({ page }) => {
await page.goto(routes.QUICK_ADD_77);
await expect(page.getByRole('radiogroup', { name: 'Radio' })).toBeVisible();

await expect(page.getByRole('radiogroup', { name: 'Radio' })).toHaveScreenshot();
});

test('Default radio group selected', async ({ page }) => {
await page.goto(routes.QUICK_ADD_77);
await expect(page.getByRole('radiogroup', { name: 'Radio' })).toBeVisible();
await page.getByLabel('1', { exact: true }).click();

await expect(page.getByRole('radiogroup', { name: 'Radio' })).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Zero star rating', async ({ page }) => {
await page.goto(routes.FOG_LINEN_CHAMBRAY);
await expect(page.getByRole('paragraph').getByRole('img').first()).toBeVisible();

await expect(page.getByRole('paragraph').getByRole('img').first()).toHaveScreenshot();
});

test('Five start rating', async ({ page }) => {
await page.goto(routes.PARFAIT_JAR);
await expect(page.getByRole('paragraph').getByRole('img').first()).toBeVisible();
await expect(page.getByRole('paragraph').getByRole('img').first()).toHaveScreenshot();
});

test('Floating rating', async ({ page }) => {
await page.goto(routes.ORBIT_TERRARIUM_LARGE);
await expect(page.getByRole('paragraph').getByRole('img').first()).toBeVisible();

await expect(page.getByRole('paragraph').getByRole('img').first()).toHaveScreenshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Rectangle list', async ({ page }) => {
await page.goto(routes.PARFAIT_JAR);
await expect(page.getByRole('radiogroup', { name: 'Size' })).toBeVisible();

await expect(page.getByRole('radiogroup', { name: 'Size' })).toHaveScreenshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Select default', async ({ page }) => {
await page.goto(routes.FOG_LINEN_CHAMBRAY);
await expect(page.getByRole('combobox')).toBeVisible();

await expect(page.getByRole('combobox')).toHaveScreenshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, test } from '@playwright/test';

import routes from '~/tests/routes';

test('Sheet basic', async ({ page }) => {
await page.goto(routes.QUICK_ADD_93);
await expect(page.getByLabel('Choose options')).toBeVisible();

await expect(page.getByLabel('Choose options')).toHaveScreenshot();
});
Loading

0 comments on commit 782588d

Please sign in to comment.