mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(datetime): arrow navigation respects min/max values (#25182)
Resolves #25073
This commit is contained in:
@@ -24,6 +24,18 @@ export const goto = async (page: Page, url: string, testInfo: TestInfo, original
|
||||
|
||||
const formattedUrl = `${splitUrl[0]}?ionic:_testing=${ionicTesting}&ionic:mode=${formattedMode}&rtl=${formattedRtl}`;
|
||||
|
||||
testInfo.annotations.push({
|
||||
type: 'mode',
|
||||
description: formattedMode,
|
||||
});
|
||||
|
||||
if (rtl) {
|
||||
testInfo.annotations.push({
|
||||
type: 'rtl',
|
||||
description: 'true',
|
||||
});
|
||||
}
|
||||
|
||||
const result = await Promise.all([
|
||||
page.waitForFunction(() => (window as any).testAppLoaded === true, { timeout: 4750 }),
|
||||
originalFn(formattedUrl),
|
||||
|
||||
@@ -3,3 +3,4 @@ export * from './goto';
|
||||
export * from './get-snapshot-settings';
|
||||
export * from './set-ion-viewport';
|
||||
export * from './spy-on-event';
|
||||
export * from './set-content';
|
||||
|
||||
59
core/src/utils/test/playwright/page/utils/set-content.ts
Normal file
59
core/src/utils/test/playwright/page/utils/set-content.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* Overwrites the default Playwright page.setContent method.
|
||||
*
|
||||
* Navigates to a blank page, sets the content, and waits for the
|
||||
* Stencil components to be hydrated before proceeding with the test.
|
||||
*
|
||||
* @param page The Playwright page object.
|
||||
* @param html The HTML content to set on the page.
|
||||
*/
|
||||
export const setContent = async (page: Page, html: string) => {
|
||||
if (page.isClosed()) {
|
||||
throw new Error('setContent unavailable: page is already closed');
|
||||
}
|
||||
|
||||
const baseUrl = process.env.PLAYWRIGHT_TEST_BASE_URL;
|
||||
|
||||
const output = `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
|
||||
<link href="${baseUrl}/css/ionic.bundle.css" rel="stylesheet" />
|
||||
<link href="${baseUrl}/scripts/testing/styles.css" rel="stylesheet" />
|
||||
<script src="${baseUrl}/scripts/testing/scripts.js"></script>
|
||||
<script type="module" src="${baseUrl}/dist/ionic/ionic.esm.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
${html}
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
|
||||
if (baseUrl) {
|
||||
await page.route(baseUrl, (route) => {
|
||||
if (route.request().url() === `${baseUrl}/`) {
|
||||
/**
|
||||
* Intercepts the empty page request and returns the
|
||||
* HTML content that was passed in.
|
||||
*/
|
||||
route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'text/html',
|
||||
body: output,
|
||||
});
|
||||
} else {
|
||||
// Allow all other requests to pass through
|
||||
route.continue();
|
||||
}
|
||||
});
|
||||
|
||||
await page.goto(`${baseUrl}#`);
|
||||
}
|
||||
|
||||
await page.waitForFunction(() => (window as any).testAppLoaded === true, { timeout: 4750 });
|
||||
};
|
||||
@@ -43,12 +43,6 @@ export interface E2EPage extends Page {
|
||||
* we need to wait until the changes have been applied to the DOM.
|
||||
*/
|
||||
waitForChanges: (timeoutMs?: number) => Promise<void>;
|
||||
/**
|
||||
* Listens on the window for a specific event to be dispatched.
|
||||
* Will wait a maximum of 5 seconds for the event to be dispatched.
|
||||
*/
|
||||
waitForCustomEvent: (eventName: string) => Promise<Page>;
|
||||
|
||||
/**
|
||||
* Creates a new EventSpy and listens
|
||||
* on the window for an event.
|
||||
|
||||
@@ -8,7 +8,14 @@ import type {
|
||||
import { test as base } from '@playwright/test';
|
||||
|
||||
import { initPageEvents } from './page/event-spy';
|
||||
import { getSnapshotSettings, goto as goToPage, setIonViewport, spyOnEvent, waitForChanges } from './page/utils';
|
||||
import {
|
||||
getSnapshotSettings,
|
||||
goto as goToPage,
|
||||
setContent,
|
||||
setIonViewport,
|
||||
spyOnEvent,
|
||||
waitForChanges,
|
||||
} from './page/utils';
|
||||
import type { E2EPage } from './playwright-declarations';
|
||||
|
||||
type CustomTestArgs = PlaywrightTestArgs &
|
||||
@@ -28,6 +35,7 @@ export const test = base.extend<CustomFixtures>({
|
||||
|
||||
// Overridden Playwright methods
|
||||
page.goto = (url: string) => goToPage(page, url, testInfo, originalGoto);
|
||||
page.setContent = (html: string) => setContent(page, html);
|
||||
// Custom Ionic methods
|
||||
page.getSnapshotSettings = () => getSnapshotSettings(page, testInfo);
|
||||
page.setIonViewport = () => setIonViewport(page);
|
||||
|
||||
Reference in New Issue
Block a user