mirror of
https://github.com/maputnik/editor.git
synced 2026-08-27 15:37:27 +00:00
Remove cypress related comments.
This commit is contained in:
@@ -49,7 +49,6 @@ export class MaputnikDriver {
|
|||||||
private readonly helper = new PlaywrightHelper();
|
private readonly helper = new PlaywrightHelper();
|
||||||
private readonly modalDriver = new ModalDriver(this);
|
private readonly modalDriver = new ModalDriver(this);
|
||||||
|
|
||||||
/** The page for the currently running test (resolved lazily, like Cypress' `cy`). */
|
|
||||||
private get page(): Page {
|
private get page(): Page {
|
||||||
return currentPage();
|
return currentPage();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export function readFixture(name: string): any {
|
|||||||
return JSON.parse(contents);
|
return JSON.parse(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Retries `assertion` until it stops throwing, mirroring Cypress' retry-ability. */
|
/** Retries `assertion` until it stops throwing */
|
||||||
export async function retry(
|
export async function retry(
|
||||||
assertion: () => Promise<void> | void,
|
assertion: () => Promise<void> | void,
|
||||||
timeout = 10000,
|
timeout = 10000,
|
||||||
@@ -39,7 +39,7 @@ export async function retry(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A lazily-evaluated value (e.g. the style in localStorage). Assertions on a
|
* A lazily-evaluated value (e.g. the style in localStorage). Assertions on a
|
||||||
* Query re-read the value until they pass, mirroring Cypress' retry-ability.
|
* Query re-read the value until they pass.
|
||||||
*/
|
*/
|
||||||
export class Query<T> {
|
export class Query<T> {
|
||||||
readonly __query = true as const;
|
readonly __query = true as const;
|
||||||
@@ -139,10 +139,6 @@ export class Assertable<T> {
|
|||||||
this.assertValue((actual) => assertDeepNestedInclude(actual, value));
|
this.assertValue((actual) => assertDeepNestedInclude(actual, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Translates a Cypress-style key sequence (e.g. "{meta}z", "{esc}", "0.") into
|
|
||||||
* Playwright keyboard actions on the currently focused element.
|
|
||||||
*/
|
|
||||||
export async function typeSequence(page: Page, text: string): Promise<void> {
|
export async function typeSequence(page: Page, text: string): Promise<void> {
|
||||||
const tokens = text.match(/\{[^}]+\}|[^{]+/g) ?? [];
|
const tokens = text.match(/\{[^}]+\}|[^{]+/g) ?? [];
|
||||||
const modifierMap: Record<string, string> = { meta: "Meta", ctrl: "Control", shift: "Shift", alt: "Alt" };
|
const modifierMap: Record<string, string> = { meta: "Meta", ctrl: "Control", shift: "Shift", alt: "Alt" };
|
||||||
@@ -187,15 +183,12 @@ async function centerOf(locator: Locator): Promise<{ x: number; y: number }> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A thin, framework-level wrapper over Playwright — the equivalent of the
|
* This is where all plywright-specific test helpers live.
|
||||||
* `CypressHelper` the suite used before, with the gaps it left (real-events
|
* It is used by the MaputnikDriver to implement the Maputnik-specific test helpers.
|
||||||
* style drag/drop, file uploads, key sequences, …) filled in here since we own
|
|
||||||
* this helper. Domain concepts live in `MaputnikDriver`, which builds on it.
|
|
||||||
*/
|
*/
|
||||||
export class PlaywrightHelper {
|
export class PlaywrightHelper {
|
||||||
private readonly recordedRequests = new Map<string, Request[]>();
|
private readonly recordedRequests = new Map<string, Request[]>();
|
||||||
|
|
||||||
/** The page for the currently running test (resolved lazily, like Cypress' `cy`). */
|
|
||||||
private get page(): Page {
|
private get page(): Page {
|
||||||
return currentPage();
|
return currentPage();
|
||||||
}
|
}
|
||||||
@@ -300,9 +293,8 @@ export class PlaywrightHelper {
|
|||||||
|
|
||||||
type: async (testId: string, text: string) => {
|
type: async (testId: string, text: string) => {
|
||||||
await this.testId(testId).focus();
|
await this.testId(testId).focus();
|
||||||
// Place the caret at the start of the field (matching how the original
|
// Place the caret at the start of the field, so a leading "{backspace}"
|
||||||
// Cypress suite typed), so a leading "{backspace}" is a no-op rather than
|
// is a no-op rather than clearing an already-committed value.
|
||||||
// clearing an already-committed value.
|
|
||||||
await this.page.keyboard.press("Home");
|
await this.page.keyboard.press("Home");
|
||||||
await typeSequence(this.page, text);
|
await typeSequence(this.page, text);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user