From 51b7ceb5bef81dc5367e313c96e8937483c06753 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Thu, 28 Sep 2023 12:02:18 -0400 Subject: [PATCH] test: remove deprecated getSnapshotSettings method (#28250) Issue number: N/A --------- ## What is the current behavior? 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? - 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 ## Other information --- .../picker-column/test/test.utils.ts | 2 +- core/src/utils/test/playwright/docs/api.md | 1 - .../page/utils/get-snapshot-settings.ts | 33 ------------------- .../utils/test/playwright/page/utils/index.ts | 1 - .../playwright/playwright-declarations.ts | 5 --- .../utils/test/playwright/playwright-page.ts | 11 +------ 6 files changed, 2 insertions(+), 51 deletions(-) delete mode 100644 core/src/utils/test/playwright/page/utils/get-snapshot-settings.ts diff --git a/core/src/components/picker-column/test/test.utils.ts b/core/src/components/picker-column/test/test.utils.ts index ded9d57f87..658b32a32f 100644 --- a/core/src/components/picker-column/test/test.utils.ts +++ b/core/src/components/picker-column/test/test.utils.ts @@ -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(), }); } diff --git a/core/src/utils/test/playwright/docs/api.md b/core/src/utils/test/playwright/docs/api.md index 627099220d..f3fea6d524 100644 --- a/core/src/utils/test/playwright/docs/api.md +++ b/core/src/utils/test/playwright/docs/api.md @@ -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. |
diff --git a/core/src/utils/test/playwright/page/utils/get-snapshot-settings.ts b/core/src/utils/test/playwright/page/utils/get-snapshot-settings.ts deleted file mode 100644 index 8e91d91a6e..0000000000 --- a/core/src/utils/test/playwright/page/utils/get-snapshot-settings.ts +++ /dev/null @@ -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}`; -}; diff --git a/core/src/utils/test/playwright/page/utils/index.ts b/core/src/utils/test/playwright/page/utils/index.ts index d5fad6cc12..e0caf9d01a 100644 --- a/core/src/utils/test/playwright/page/utils/index.ts +++ b/core/src/utils/test/playwright/page/utils/index.ts @@ -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'; diff --git a/core/src/utils/test/playwright/playwright-declarations.ts b/core/src/utils/test/playwright/playwright-declarations.ts index 74d4ff93e7..d900f37abe 100644 --- a/core/src/utils/test/playwright/playwright-declarations.ts +++ b/core/src/utils/test/playwright/playwright-declarations.ts @@ -78,11 +78,6 @@ export interface E2EPage extends Page { * Use this method when taking full-screen screenshots. */ setIonViewport: (options?: SetIonViewportOptions) => Promise; - /** - * 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. diff --git a/core/src/utils/test/playwright/playwright-page.ts b/core/src/utils/test/playwright/playwright-page.ts index bbab9b9b0c..1b20d6c271 100644 --- a/core/src/utils/test/playwright/playwright-page.ts +++ b/core/src/utils/test/playwright/playwright-page.ts @@ -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);