mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
test: remove deprecated getSnapshotSettings method (#28250)
Issue number: N/A --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> The `getSnapshotSettings` method was used in the pre-generator test infrastructure. It was deprecated at the start of the generator migration. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Now that the generator migration is complete, this method is no longer needed. As a result, I removed it. Developers should use the `screenshot` function: https://github.com/ionic-team/ionic-framework/blob/main/core/src/utils/test/playwright/docs/api.md#using-the-return-value-from-each-configuration ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
This commit is contained in:
@ -39,7 +39,7 @@ export async function testPickerColumn(
|
||||
await page.waitForChanges();
|
||||
|
||||
screenshots.push({
|
||||
name: `picker-${description}-column-diff-${i}-${page.getSnapshotSettings()}.png`,
|
||||
name: screenshot(`picker-${description}-column-diff-${i}`),
|
||||
screenshot: await page.screenshot(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -108,7 +108,6 @@ The [page fixture](https://playwright.dev/docs/test-fixtures) has been extended
|
||||
| `setIonViewport` | Resizes the browser window to fit the entire height of `ion-content` on screen. Only needed when taking fullsize screenshots with `ion-content`. |
|
||||
| `waitForChanges` | Waits for Stencil to re-render before proceeeding. This is typically only needed when you update a property on a component. |
|
||||
| `spyOnEvent` | Creates an event spy that can be used to wait for a [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) to be emitted. |
|
||||
| `getSnapshotSettings` (DEPRECATED) | Returns information about the current test (such as mode or direction) to generate a unique screenshot name. Deprecated: Use the `screenshot` function provided by the test [generator](#generators) instead. |
|
||||
|
||||
<details>
|
||||
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
import type { Page, TestInfo } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* This provides metadata that can be used to
|
||||
* create a unique screenshot URL.
|
||||
* For example, we need to be able to differentiate
|
||||
* between iOS in LTR mode and iOS in RTL mode.
|
||||
*/
|
||||
export const getSnapshotSettings = (page: Page, testInfo: TestInfo) => {
|
||||
const url = page.url();
|
||||
const splitUrl = url.split('?');
|
||||
const paramsString = splitUrl[1];
|
||||
|
||||
const { mode, rtl } = testInfo.project.metadata;
|
||||
|
||||
/**
|
||||
* Account for custom settings when overriding
|
||||
* the mode/rtl setting. Fall back to the
|
||||
* project metadata if nothing was found. This
|
||||
* will happen if you call page.getSnapshotSettings
|
||||
* before page.goto.
|
||||
*/
|
||||
const urlToParams = new URLSearchParams(paramsString);
|
||||
const formattedMode = urlToParams.get('ionic:mode') ?? mode;
|
||||
const formattedRtl = urlToParams.get('rtl') ?? rtl;
|
||||
|
||||
/**
|
||||
* If encoded in the search params, the rtl value
|
||||
* can be `'true'` instead of `true`.
|
||||
*/
|
||||
const rtlString = formattedRtl === true || formattedRtl === 'true' ? 'rtl' : 'ltr';
|
||||
return `${formattedMode}-${rtlString}`;
|
||||
};
|
||||
@ -1,6 +1,5 @@
|
||||
export * from './wait-for-changes';
|
||||
export * from './goto';
|
||||
export * from './get-snapshot-settings';
|
||||
export * from './set-ion-viewport';
|
||||
export * from './spy-on-event';
|
||||
export * from './set-content';
|
||||
|
||||
@ -78,11 +78,6 @@ export interface E2EPage extends Page {
|
||||
* Use this method when taking full-screen screenshots.
|
||||
*/
|
||||
setIonViewport: (options?: SetIonViewportOptions) => Promise<void>;
|
||||
/**
|
||||
* This provides metadata that can be used to create a unique screenshot URL.
|
||||
* For example, we need to be able to differentiate between iOS in LTR mode and iOS in RTL mode.
|
||||
*/
|
||||
getSnapshotSettings: () => string;
|
||||
/**
|
||||
* After changes have been made to a component, such as an update to a property or attribute,
|
||||
* we need to wait until the changes have been applied to the DOM.
|
||||
|
||||
@ -10,15 +10,7 @@ import { test as base } from '@playwright/test';
|
||||
import { PageUtils } from '../press-keys';
|
||||
|
||||
import { initPageEvents } from './page/event-spy';
|
||||
import {
|
||||
getSnapshotSettings,
|
||||
goto as goToPage,
|
||||
setContent,
|
||||
setIonViewport,
|
||||
spyOnEvent,
|
||||
waitForChanges,
|
||||
locator,
|
||||
} from './page/utils';
|
||||
import { goto as goToPage, setContent, setIonViewport, spyOnEvent, waitForChanges, locator } from './page/utils';
|
||||
import type { LocatorOptions } from './page/utils';
|
||||
import type {
|
||||
E2EPage,
|
||||
@ -57,7 +49,6 @@ export async function extendPageFixture(page: E2EPage, testInfo: TestInfo) {
|
||||
page.locator = (selector: string, options?: LocatorOptions) => locator(page, originalLocator, selector, options);
|
||||
|
||||
// Custom Ionic methods
|
||||
page.getSnapshotSettings = () => getSnapshotSettings(page, testInfo);
|
||||
page.setIonViewport = (options?: SetIonViewportOptions) => setIonViewport(page, options);
|
||||
page.waitForChanges = (timeoutMs?: number) => waitForChanges(page, timeoutMs);
|
||||
page.spyOnEvent = (eventName: string) => spyOnEvent(page, eventName);
|
||||
|
||||
Reference in New Issue
Block a user