@shopware-ag/acceptance-test-suite 11.35.0 → 11.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +87 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -8,6 +8,14 @@ export { APIRequestContext, APIResponse, BrowserContext, Locator, Page, Request
|
|
|
8
8
|
import { components } from '@shopware/api-client/admin-api-types';
|
|
9
9
|
import { Image } from 'image-js';
|
|
10
10
|
|
|
11
|
+
declare global {
|
|
12
|
+
namespace PlaywrightTest {
|
|
13
|
+
interface Matchers<R> {
|
|
14
|
+
toHaveVisibleFocus(): Promise<R>;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
interface RequestOptions$1<PAYLOAD> {
|
|
12
20
|
[key: string]: unknown;
|
|
13
21
|
data?: PAYLOAD;
|
|
@@ -3982,6 +3990,10 @@ declare class Actor {
|
|
|
3982
3990
|
baseURL: string | undefined;
|
|
3983
3991
|
constructor(name: string, page: Page, baseURL?: string);
|
|
3984
3992
|
expects: playwright_test.Expect<{}>;
|
|
3993
|
+
a11y_checks(locator: Locator): Promise<void>;
|
|
3994
|
+
fillsIn(locator: Locator, input: string): Promise<void>;
|
|
3995
|
+
presses(locator: Locator, key?: string): Promise<void>;
|
|
3996
|
+
selectsRadioButton(radioGroup: Locator, inputLabel: string): Promise<void>;
|
|
3985
3997
|
attemptsTo(task: () => Promise<void>): Promise<void>;
|
|
3986
3998
|
goesTo(url: string, forceReload?: boolean): Promise<void>;
|
|
3987
3999
|
private camelCaseToLowerCase;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,14 @@ export { APIRequestContext, APIResponse, BrowserContext, Locator, Page, Request
|
|
|
8
8
|
import { components } from '@shopware/api-client/admin-api-types';
|
|
9
9
|
import { Image } from 'image-js';
|
|
10
10
|
|
|
11
|
+
declare global {
|
|
12
|
+
namespace PlaywrightTest {
|
|
13
|
+
interface Matchers<R> {
|
|
14
|
+
toHaveVisibleFocus(): Promise<R>;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
interface RequestOptions$1<PAYLOAD> {
|
|
12
20
|
[key: string]: unknown;
|
|
13
21
|
data?: PAYLOAD;
|
|
@@ -3982,6 +3990,10 @@ declare class Actor {
|
|
|
3982
3990
|
baseURL: string | undefined;
|
|
3983
3991
|
constructor(name: string, page: Page, baseURL?: string);
|
|
3984
3992
|
expects: playwright_test.Expect<{}>;
|
|
3993
|
+
a11y_checks(locator: Locator): Promise<void>;
|
|
3994
|
+
fillsIn(locator: Locator, input: string): Promise<void>;
|
|
3995
|
+
presses(locator: Locator, key?: string): Promise<void>;
|
|
3996
|
+
selectsRadioButton(radioGroup: Locator, inputLabel: string): Promise<void>;
|
|
3985
3997
|
attemptsTo(task: () => Promise<void>): Promise<void>;
|
|
3986
3998
|
goesTo(url: string, forceReload?: boolean): Promise<void>;
|
|
3987
3999
|
private camelCaseToLowerCase;
|
package/dist/index.mjs
CHANGED
|
@@ -3235,6 +3235,59 @@ class Actor {
|
|
|
3235
3235
|
this.baseURL = baseURL;
|
|
3236
3236
|
}
|
|
3237
3237
|
expects = expect;
|
|
3238
|
+
async a11y_checks(locator) {
|
|
3239
|
+
await locator.focus();
|
|
3240
|
+
await expect(locator).toBeFocused();
|
|
3241
|
+
await expect(locator).toHaveVisibleFocus();
|
|
3242
|
+
}
|
|
3243
|
+
async fillsIn(locator, input) {
|
|
3244
|
+
const stepTitle = `${this.name} fills ${locator} with text "${input}"`;
|
|
3245
|
+
await test$e.step(stepTitle, async () => {
|
|
3246
|
+
await this.a11y_checks(locator);
|
|
3247
|
+
await locator.fill(input);
|
|
3248
|
+
});
|
|
3249
|
+
}
|
|
3250
|
+
async presses(locator, key) {
|
|
3251
|
+
let defaultKey = "Space";
|
|
3252
|
+
const tagName = await locator.evaluate((el) => el.tagName);
|
|
3253
|
+
if (tagName === "BUTTON" || tagName === "A") {
|
|
3254
|
+
await this.page.keyboard.press("Shift");
|
|
3255
|
+
defaultKey = "Enter";
|
|
3256
|
+
}
|
|
3257
|
+
const inputKey = key ?? defaultKey;
|
|
3258
|
+
const stepTitle = `${this.name} presses ${inputKey} on ${locator}`;
|
|
3259
|
+
await test$e.step(stepTitle, async () => {
|
|
3260
|
+
await this.a11y_checks(locator);
|
|
3261
|
+
await locator.press(inputKey);
|
|
3262
|
+
});
|
|
3263
|
+
}
|
|
3264
|
+
async selectsRadioButton(radioGroup, inputLabel) {
|
|
3265
|
+
const stepTitle = `${this.name} selects radio button ${inputLabel}`;
|
|
3266
|
+
await test$e.step(stepTitle, async () => {
|
|
3267
|
+
const desiredOption = radioGroup.getByRole("radio", { name: inputLabel });
|
|
3268
|
+
if (!await desiredOption.isChecked()) {
|
|
3269
|
+
const options = [];
|
|
3270
|
+
for (const labelEl of await radioGroup.locator("label").all()) {
|
|
3271
|
+
const label = await labelEl.innerText();
|
|
3272
|
+
const radioButton = radioGroup.getByRole("radio", { name: label });
|
|
3273
|
+
const isChecked = await radioButton.isChecked();
|
|
3274
|
+
options.push({ label, locator: radioButton, isChecked });
|
|
3275
|
+
}
|
|
3276
|
+
const defaultOptionIndex = options.findIndex((opt) => opt.isChecked);
|
|
3277
|
+
const desiredOptionIndex = options.findIndex((opt) => opt.label === inputLabel);
|
|
3278
|
+
if (defaultOptionIndex === -1) {
|
|
3279
|
+
throw new Error(`No option is selected by default.`);
|
|
3280
|
+
}
|
|
3281
|
+
const step = defaultOptionIndex < desiredOptionIndex ? 1 : -1;
|
|
3282
|
+
const inputKey = step === 1 ? "ArrowDown" : "ArrowUp";
|
|
3283
|
+
for (let i = defaultOptionIndex; i !== desiredOptionIndex; i += step) {
|
|
3284
|
+
await this.presses(options[i].locator, inputKey);
|
|
3285
|
+
await this.page.waitForLoadState("domcontentloaded");
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
await this.a11y_checks(desiredOption);
|
|
3289
|
+
});
|
|
3290
|
+
}
|
|
3238
3291
|
async attemptsTo(task) {
|
|
3239
3292
|
const stepTitle = `${this.name} attempts to ${this.camelCaseToLowerCase(task.name)}`;
|
|
3240
3293
|
await test$e.step(stepTitle, async () => await task());
|
|
@@ -11705,6 +11758,40 @@ const test$1 = test$e.extend({
|
|
|
11705
11758
|
]
|
|
11706
11759
|
});
|
|
11707
11760
|
|
|
11761
|
+
expect.extend({
|
|
11762
|
+
async toHaveVisibleFocus(locator) {
|
|
11763
|
+
try {
|
|
11764
|
+
const boxShadowStyle = await locator.evaluate((element) => {
|
|
11765
|
+
const computedStyle = window.getComputedStyle(element);
|
|
11766
|
+
return computedStyle.boxShadow !== "none";
|
|
11767
|
+
});
|
|
11768
|
+
const borderStyle = await locator.evaluate((element) => {
|
|
11769
|
+
const computedStyle = window.getComputedStyle(element);
|
|
11770
|
+
return computedStyle.borderStyle !== "none" && computedStyle.borderWidth !== "0px" && computedStyle.borderColor !== "transparent" && !computedStyle.borderColor.includes("rgba(0, 0, 0, 0)");
|
|
11771
|
+
});
|
|
11772
|
+
const outlineStyle = await locator.evaluate((element) => {
|
|
11773
|
+
const computedStyle = window.getComputedStyle(element);
|
|
11774
|
+
return computedStyle.outline !== "none" && computedStyle.outlineWidth !== "0px" && computedStyle.borderColor !== "transparent" && !computedStyle.borderColor.includes("rgba(0, 0, 0, 0)");
|
|
11775
|
+
});
|
|
11776
|
+
if (!boxShadowStyle && !borderStyle && !outlineStyle) {
|
|
11777
|
+
return {
|
|
11778
|
+
message: () => `expected ${locator} to have visible focus, but no outline, border or box-shadow was detected`,
|
|
11779
|
+
pass: false
|
|
11780
|
+
};
|
|
11781
|
+
}
|
|
11782
|
+
return {
|
|
11783
|
+
message: () => `${locator} has visible focus`,
|
|
11784
|
+
pass: true
|
|
11785
|
+
};
|
|
11786
|
+
} catch (error) {
|
|
11787
|
+
return {
|
|
11788
|
+
message: () => `expected ${locator} to have visible focus, but it failed with error: ${error.message}`,
|
|
11789
|
+
pass: false
|
|
11790
|
+
};
|
|
11791
|
+
}
|
|
11792
|
+
}
|
|
11793
|
+
});
|
|
11794
|
+
|
|
11708
11795
|
async function applyToElements(page, selectors, stringHandler, locatorHandler) {
|
|
11709
11796
|
if (!selectors.length) return;
|
|
11710
11797
|
const stringSelectors = selectors.filter((s) => typeof s === "string");
|