Skip to content

Commit

Permalink
Added playwright test
Browse files Browse the repository at this point in the history
  • Loading branch information
tjamesallen15 committed Sep 2, 2024
1 parent 4e5f918 commit 2910200
Showing 1 changed file with 51 additions and 28 deletions.
79 changes: 51 additions & 28 deletions tests/fileupload-advanced/fileupload-advanced.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,68 @@ import { expect } from '@playwright/test';
import { test } from '../base-fixture';

test.describe('FileuploadAdvanced tests', () => {
const url = '/components/fileupload-advanced/example-index.html';
test.describe('FileuploadAdvanced example tests', () => {
const url = '/components/fileupload-advanced/example-index.html';

test.beforeEach(async ({ page }) => {
await page.goto(url);
});
test.beforeEach(async ({ page }) => {
await page.goto(url);
});

test.describe('general page checks', () => {
test('should have a title', async ({ page }) => {
await expect(page).toHaveTitle('IDS Enterprise');
test.describe('general page checks', () => {
test('should have a title', async ({ page }) => {
await expect(page).toHaveTitle('IDS Enterprise');
});
});
});

test.describe('accessibility tests', () => {
test('should pass an Axe scan', async ({ page, browserName }) => {
if (browserName !== 'chromium') return;
const accessibilityScanResults = await new AxeBuilder({ page })
.disableRules(['meta-viewport'])
.exclude('[disabled]')
.analyze();
expect(accessibilityScanResults.violations).toEqual([]);
test.describe('accessibility tests', () => {
test('should pass an Axe scan', async ({ page, browserName }) => {
if (browserName !== 'chromium') return;
const accessibilityScanResults = await new AxeBuilder({ page })
.disableRules(['meta-viewport'])
.exclude('[disabled]')
.analyze();
expect(accessibilityScanResults.violations).toEqual([]);
});
});
});

test.describe('snapshot tests', () => {
test('should match innerHTML snapshot', async ({ page, browserName }) => {
if (browserName !== 'chromium') return;
const html = await page.evaluate(() => {
const elem = document.querySelector('.fileupload-advanced');
return elem?.outerHTML;
test.describe('snapshot tests', () => {
test('should match innerHTML snapshot', async ({ page, browserName }) => {
if (browserName !== 'chromium') return;
const html = await page.evaluate(() => {
const elem = document.querySelector('.fileupload-advanced');
return elem?.outerHTML;
});
await expect(html).toMatchSnapshot('fileupload-advanced-html');
});

test('should match the visual snapshot in percy', async ({ page, browserName }) => {
if (browserName !== 'chromium') return;
await percySnapshot(page, 'fileupload-advanced-light');
});
await expect(html).toMatchSnapshot('fileupload-advanced-html');
});

test('should match the visual snapshot in percy', async ({ page, browserName }) => {
if (browserName !== 'chromium') return;
await percySnapshot(page, 'fileupload-advanced-light');
test.describe('functionality tests', () => {
});
});

test.describe('functionality tests', () => {
test.describe('fileuploadadvanced tests', () => {
const url = '/components/fileupload-advanced/example-index.html';

test.beforeEach(async ({ page }) => {
await page.goto(url);
});

test.describe('open fileupload tests', () => {
test('value should have a file', async ({ page }) => {
const input = page.locator('.hyperlink');

await expect(input).toBeVisible();

await input.setInputFiles('./app/www/images/35.jpg');

await expect(page.locator('.drop-area + .container')).toBeVisible();
await expect(page.locator('.drop-area + .container')).toHaveClass('container');
});
});
});
});

0 comments on commit 2910200

Please sign in to comment.