chore(playwright): mode and direction are now set when using setContent (#25435)
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 46 KiB |
@ -10,7 +10,7 @@ test.describe('range: basic', () => {
|
|||||||
expect(await page.screenshot()).toMatchSnapshot(`range-diff-${page.getSnapshotSettings()}.png`);
|
expect(await page.screenshot()).toMatchSnapshot(`range-diff-${page.getSnapshotSettings()}.png`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should emit start/end events', async ({ page }) => {
|
test('should emit start/end events', async ({ page }, testInfo) => {
|
||||||
await page.setContent(`<ion-range value="20"></ion-range>`);
|
await page.setContent(`<ion-range value="20"></ion-range>`);
|
||||||
|
|
||||||
const rangeStart = await page.spyOnEvent('ionKnobMoveStart');
|
const rangeStart = await page.spyOnEvent('ionKnobMoveStart');
|
||||||
@ -18,7 +18,7 @@ test.describe('range: basic', () => {
|
|||||||
|
|
||||||
const rangeEl = page.locator('ion-range');
|
const rangeEl = page.locator('ion-range');
|
||||||
|
|
||||||
await dragElementBy(rangeEl, page, 300, 0);
|
await dragElementBy(rangeEl, page, testInfo.project.metadata.rtl ? -300 : 300, 0);
|
||||||
await page.waitForChanges();
|
await page.waitForChanges();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { Page } from '@playwright/test';
|
import type { Page, TestInfo } from '@playwright/test';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwrites the default Playwright page.setContent method.
|
* Overwrites the default Playwright page.setContent method.
|
||||||
@ -8,8 +8,9 @@ import type { Page } from '@playwright/test';
|
|||||||
*
|
*
|
||||||
* @param page The Playwright page object.
|
* @param page The Playwright page object.
|
||||||
* @param html The HTML content to set on the page.
|
* @param html The HTML content to set on the page.
|
||||||
|
* @param testInfo The TestInfo associated with the current test run.
|
||||||
*/
|
*/
|
||||||
export const setContent = async (page: Page, html: string) => {
|
export const setContent = async (page: Page, html: string, testInfo: TestInfo) => {
|
||||||
if (page.isClosed()) {
|
if (page.isClosed()) {
|
||||||
throw new Error('setContent unavailable: page is already closed');
|
throw new Error('setContent unavailable: page is already closed');
|
||||||
}
|
}
|
||||||
@ -18,7 +19,7 @@ export const setContent = async (page: Page, html: string) => {
|
|||||||
|
|
||||||
const output = `
|
const output = `
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html dir="${testInfo.project.metadata.rtl ? 'rtl' : 'ltr'}">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
|
||||||
@ -26,7 +27,13 @@ export const setContent = async (page: Page, html: string) => {
|
|||||||
<link href="${baseUrl}/scripts/testing/styles.css" rel="stylesheet" />
|
<link href="${baseUrl}/scripts/testing/styles.css" rel="stylesheet" />
|
||||||
<script src="${baseUrl}/scripts/testing/scripts.js"></script>
|
<script src="${baseUrl}/scripts/testing/scripts.js"></script>
|
||||||
<script type="module" src="${baseUrl}/dist/ionic/ionic.esm.js"></script>
|
<script type="module" src="${baseUrl}/dist/ionic/ionic.esm.js"></script>
|
||||||
|
<script>
|
||||||
|
window.Ionic = {
|
||||||
|
config: {
|
||||||
|
mode: '${testInfo.project.metadata.mode}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
${html}
|
${html}
|
||||||
|
@ -43,7 +43,7 @@ export async function extendPageFixture(page: E2EPage, testInfo: TestInfo) {
|
|||||||
|
|
||||||
// Overridden Playwright methods
|
// Overridden Playwright methods
|
||||||
page.goto = (url: string, options) => goToPage(page, url, options, testInfo, originalGoto);
|
page.goto = (url: string, options) => goToPage(page, url, options, testInfo, originalGoto);
|
||||||
page.setContent = (html: string) => setContent(page, html);
|
page.setContent = (html: string) => setContent(page, html, testInfo);
|
||||||
page.locator = (selector: string, options?: LocatorOptions) => locator(page, originalLocator, selector, options);
|
page.locator = (selector: string, options?: LocatorOptions) => locator(page, originalLocator, selector, options);
|
||||||
|
|
||||||
// Custom Ionic methods
|
// Custom Ionic methods
|
||||||
|