test(content): migrate to Playwright (#25979)

This commit is contained in:
Amanda Johnston
2022-09-20 13:33:08 -05:00
committed by GitHub
parent e9a1195644
commit 3a5de7de9b
27 changed files with 60 additions and 103 deletions

View File

@ -0,0 +1,15 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('content: basic', () => {
test('should not have visual regressions', async ({ page, skip }) => {
skip.rtl();
skip.mode('ios', 'ion-content does not have mode-specific styling');
await page.goto(`/src/components/content/test/basic`);
await page.setIonViewport();
expect(await page.screenshot()).toMatchSnapshot(`content-diff-${page.getSnapshotSettings()}.png`);
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@ -1,10 +0,0 @@
import { newE2EPage } from '@stencil/core/testing';
test('content: basic', async () => {
const page = await newE2EPage({
url: '/src/components/content/test/basic?ionic:_testing=true',
});
const compare = await page.compareScreenshot();
expect(compare).toMatchScreenshot();
});

View File

@ -29,7 +29,6 @@
<ion-content class="ion-padding" style="text-align: center; flex: 2" id="content"> <ion-content class="ion-padding" style="text-align: center; flex: 2" id="content">
<ion-content id="content-part"> <ion-content id="content-part">
<f style="height: 50%"></f> <f style="height: 50%"></f>
<ion-button onclick="toggleFullscreen()">Toggle content.fullscreen</ion-button>
<p> <p>
<ion-button onclick="toggleDisplay('header')" color="secondary">Toggle header</ion-button> <ion-button onclick="toggleDisplay('header')" color="secondary">Toggle header</ion-button>
<ion-button onclick="toggleDisplay('footer')" color="secondary">Toggle footer</ion-button> <ion-button onclick="toggleDisplay('footer')" color="secondary">Toggle footer</ion-button>
@ -45,11 +44,6 @@
<f></f> <f></f>
<f></f> <f></f>
<f></f> <f></f>
<f></f>
<f></f>
<f></f>
<f></f>
<f></f>
</ion-content> </ion-content>
</ion-content> </ion-content>
<ion-content class="ion-padding" style="display: none" id="content3"> <ion-content class="ion-padding" style="display: none" id="content3">
@ -79,16 +73,7 @@
<script> <script>
const content = document.getElementById('content'); const content = document.getElementById('content');
content.scrollEvents = true;
content.addEventListener('ionScrollStart', () => console.log('scroll start'));
content.addEventListener('ionScroll', (ev) => console.log('scroll', ev.detail));
content.addEventListener('ionScrollEnd', () => console.log('scroll end'));
function toggleFullscreen() {
const content = document.getElementById('content');
content.fullscreen = !content.fullscreen;
console.log('content.fullscren =', content.fullscreen);
}
function toggleDisplay(id) { function toggleDisplay(id) {
const el = document.getElementById(id); const el = document.getElementById(id);
el.style.display = !el.style.display ? 'none' : null; el.style.display = !el.style.display ? 'none' : null;

View File

@ -0,0 +1,14 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('content: fixed', () => {
test('should not have visual regressions', async ({ page, skip }) => {
skip.mode('ios', 'ion-content does not have mode-specific styling');
await page.goto(`/src/components/content/test/fixed`);
await page.setIonViewport();
expect(await page.screenshot()).toMatchSnapshot(`content-fixed-${page.getSnapshotSettings()}.png`);
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -1,10 +0,0 @@
import { newE2EPage } from '@stencil/core/testing';
test('content: fixed', async () => {
const page = await newE2EPage({
url: '/src/components/content/test/fixed?ionic:_testing=true',
});
const compare = await page.compareScreenshot();
expect(compare).toMatchScreenshot();
});

View File

@ -27,7 +27,7 @@
<div slot="fixed"> <div slot="fixed">
<h1>Fixed content</h1> <h1>Fixed content</h1>
<p>Fixed paragraph</p> <p>Fixed paragraph</p>
<ion-button>Button</ion-button> <ion-button>Fixed button</ion-button>
</div> </div>
<ion-fab vertical="top" horizontal="end" slot="fixed"> <ion-fab vertical="top" horizontal="end" slot="fixed">
<ion-fab-button> <ion-fab-button>

View File

@ -0,0 +1,15 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('content: fullscreen', () => {
test('should not have visual regressions', async ({ page, skip }) => {
skip.rtl();
skip.mode('ios', 'ion-content does not have mode-specific styling');
await page.goto(`/src/components/content/test/fullscreen`);
await page.setIonViewport();
expect(await page.screenshot()).toMatchSnapshot(`content-fullscreen-${page.getSnapshotSettings()}.png`);
});
});

View File

@ -1,10 +0,0 @@
import { newE2EPage } from '@stencil/core/testing';
test('content: fullscreen', async () => {
const page = await newE2EPage({
url: '/src/components/content/test/fullscreen?ionic:_testing=true',
});
const compare = await page.compareScreenshot();
expect(compare).toMatchScreenshot();
});

View File

@ -49,18 +49,6 @@
Integer luctus faucibus nunc, non mattis nisl consectetur at. Interdum et malesuada fames ac ante ipsum primis Integer luctus faucibus nunc, non mattis nisl consectetur at. Interdum et malesuada fames ac ante ipsum primis
in faucibus. in faucibus.
</p> </p>
<p>
Suspendisse et arcu nec odio lobortis lacinia a congue ligula. Duis libero lacus, blandit ac lectus et,
laoreet condimentum est. Suspendisse potenti. Praesent ligula dui, laoreet sed pellentesque vitae, congue at
leo. Mauris pharetra, tellus vel viverra viverra, tellus felis mollis magna, volutpat pharetra augue nunc a
dolor. Donec ex turpis, iaculis id consectetur quis, posuere a purus. Morbi eu massa sed erat tristique
hendrerit. Morbi eleifend, nisi eleifend condimentum euismod, lacus erat porta arcu, consequat rutrum ipsum
arcu at metus. Sed tellus nulla, pellentesque sit amet justo at, venenatis imperdiet dui. Aenean odio eros,
posuere at dui pharetra, laoreet posuere nulla. Vestibulum interdum odio eu odio ornare, quis maximus lacus
semper. Quisque purus dolor, ullamcorper mollis lorem at, sodales aliquet velit. Interdum et malesuada fames
ac ante ipsum primis in faucibus. Vivamus purus felis, elementum ut est ut, finibus sagittis tellus. Etiam
neque mauris, lobortis sed orci in, dictum eleifend turpis. Morbi eu odio quis mauris gravida tristique.
</p>
<p> <p>
Vestibulum blandit quam a odio lobortis dictum. Nulla pellentesque mauris ornare neque ultricies sagittis. Vestibulum blandit quam a odio lobortis dictum. Nulla pellentesque mauris ornare neque ultricies sagittis.
Aenean molestie placerat fermentum. Morbi ac tortor vel felis imperdiet suscipit. Ut id pellentesque nulla. Aenean molestie placerat fermentum. Morbi ac tortor vel felis imperdiet suscipit. Ut id pellentesque nulla.

View File

@ -0,0 +1,15 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('content: standalone', () => {
test('should not have visual regressions', async ({ page, skip }) => {
skip.rtl();
skip.mode('ios', 'ion-content does not have mode-specific styling');
await page.goto(`/src/components/content/test/standalone`);
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot(
`content-standalone-${page.getSnapshotSettings()}.png`
);
});
});

View File

@ -1,10 +0,0 @@
import { newE2EPage } from '@stencil/core/testing';
test('content: standalone', async () => {
const page = await newE2EPage({
url: '/src/components/content/test/standalone?ionic:_testing=true',
});
const compare = await page.compareScreenshot();
expect(compare).toMatchScreenshot();
});

View File

@ -53,46 +53,11 @@
</ion-content> </ion-content>
</div> </div>
<div class="content-height">
<ion-content class="ion-padding outer-content">
<h1>Heading</h1>
<h2>Heading</h2>
<h3>Heading</h3>
<hr />
<h4>Heading</h4>
<h5>Heading</h5>
<h6>Heading</h6>
<p>Paragraph</p>
</ion-content>
</div>
<div class="content-height">
<ion-content class="ion-padding outer-content">
<h1>Heading</h1>
<h2>Heading</h2>
<h3>Heading</h3>
<hr />
<h4>Heading</h4>
<h5>Heading</h5>
<h6>Heading</h6>
<p>Paragraph</p>
</ion-content>
</div>
<style> <style>
.content-height { .content-height {
height: 200px; height: 200px;
} }
/* TODO should this be in content? */
ion-content {
height: 100%;
}
.outer-content {
--background: #f2f2f2;
}
.custom-color { .custom-color {
--background: blue; --background: blue;
--color: white; --color: white;