@quickpickle/playwright 0.10.6 → 0.11.1

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/helpers.cjs DELETED
@@ -1,58 +0,0 @@
1
- 'use strict';
2
-
3
- // Locator helper function
4
- async function getLocator(el, identifier, role, text = null) {
5
- let locator;
6
- if (role === 'element')
7
- locator = await el.locator(identifier);
8
- else if (role === 'input')
9
- locator = await el.getByLabel(identifier).or(el.getByPlaceholder(identifier));
10
- else
11
- locator = await el.getByRole(role, { name: identifier });
12
- if (text)
13
- return await locator.filter({ hasText: text });
14
- return locator;
15
- }
16
- async function setValue(locator, value) {
17
- let { tag, type, role } = await locator.evaluate((el) => ({ tag: el.tagName.toLowerCase(), type: el.getAttribute('type')?.toLowerCase(), role: el.getAttribute('role')?.toLowerCase() }));
18
- if (tag === 'select') {
19
- let values = value.split(/\s*(?<!\\),\s*/).map((v) => v.replace(/\\,/g, ','));
20
- await locator.selectOption(values);
21
- }
22
- else if (type === 'checkbox' || type === 'radio' || role === 'checkbox') {
23
- let check = !(['false', 'no', 'unchecked', '', 'null', 'undefined', '0'].includes(value.toString().toLowerCase()));
24
- if (check)
25
- await locator.check();
26
- else
27
- await locator.uncheck();
28
- }
29
- else {
30
- await locator.fill(value);
31
- }
32
- }
33
- async function testMetatag(page, name, expected, exact, expectMatching = true) {
34
- let actual;
35
- if (name === 'title')
36
- actual = await page.title();
37
- else
38
- actual = await (await page.locator(`meta[name="${name}"]`)).getAttribute('content');
39
- let matches = exact ? actual === expected : actual?.includes(expected);
40
- if (matches !== expectMatching) {
41
- let word = exact ? 'exactly match' : 'contain';
42
- let not = expectMatching ? '' : 'not ';
43
- throw new Error(`Expected ${name} metatag ${not}to ${word} '${expected}' but got '${actual}'`);
44
- }
45
- }
46
- function sanitizeFilepath(filepath) {
47
- return filepath.replace(/\/\/+/g, '/').replace(/\/[\.~]+\//g, '/');
48
- }
49
- function defaultScreenshotPath(world) {
50
- return `${world.worldConfig.screenshotDir}/${world.toString().replace(/^.+?Feature: /, 'Feature: ').replace(' ' + world.info.step, '')}.png`;
51
- }
52
-
53
- exports.defaultScreenshotPath = defaultScreenshotPath;
54
- exports.getLocator = getLocator;
55
- exports.sanitizeFilepath = sanitizeFilepath;
56
- exports.setValue = setValue;
57
- exports.testMetatag = testMetatag;
58
- //# sourceMappingURL=helpers.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.cjs","sources":["../src/helpers.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;AACO,eAAe,UAAU,CAAC,EAAe,EAAE,UAAiB,EAAE,IAAW,EAAE,IAAA,GAAiB,IAAI,EAAA;AACrG,IAAA,IAAI,OAAe,CAAA;IACnB,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;SACzD,IAAI,IAAI,KAAK,OAAO;AAAE,QAAA,OAAO,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAA;;AACnG,QAAA,OAAO,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,IAAW,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;AACpE,IAAA,IAAI,IAAI;QAAE,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;AACxD,IAAA,OAAO,OAAO,CAAA;AAChB,CAAC;AAEM,eAAe,QAAQ,CAAC,OAAe,EAAE,KAAgB,EAAA;IAC9D,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAC,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,IAAI,EAAC,EAAE,CAAC,YAAY,CA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,CAAI,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAA;AAExF,IAAA,IAAI,OAAO,GAAG,KAAK,GAAI,MAAM,KAAK,QAAQ,GAAG,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAEvE,IAAA,IAAI,OAAO,KAAK,cAAc,EAAE;QAC9B,IAAI,IAAI,GAAG,KAAK,GAAG,eAAe,GAAG,SAAS,CAAA;QAC9C,IAAI,GAAG,GAAG,cAAc,GAAG,EAAE,GAAG,MAAM,CAAA;AACtC,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,SAAA,EAAY,IAAI,CAAY,SAAA,EAAA,GAAI,CAAM,GAAA,EAAA,IAAI,KAAK,QAAQ,CAAA,WAAA,EAAc,MAAM,CAAA,CAAA,CAAG,CAAC,CAAA;KAChG;AACH,CAAC;AAEK,SAAU,gBAAgB,CAAC,QAAe,EAAA;AAC9C,IAAA,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAA;AACpE,CAAC;AAEK,SAAU,qBAAqB,CAAC,KAAqB,EAAA;AACzD,IAAA,OAAO,CAAG,EAAA,KAAK,CAAC,WAAW,CAAC,aAAa,CAAA,CAAA,EAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAA;AAC9I;;;;;;;;"}
package/dist/helpers.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { Locator, Page } from "playwright-core";
2
- import { PlaywrightWorld } from "./PlaywrightWorld";
3
- export declare function getLocator(el: Locator | Page, identifier: string, role: string, text?: string | null): Promise<Locator>;
4
- export declare function setValue(locator: Locator, value: string | any): Promise<void>;
5
- export declare function testMetatag(page: Page, name: string, expected: string, exact: boolean, expectMatching?: boolean): Promise<void>;
6
- export declare function sanitizeFilepath(filepath: string): string;
7
- export declare function defaultScreenshotPath(world: PlaywrightWorld): string;
package/dist/helpers.mjs DELETED
@@ -1,52 +0,0 @@
1
- // Locator helper function
2
- async function getLocator(el, identifier, role, text = null) {
3
- let locator;
4
- if (role === 'element')
5
- locator = await el.locator(identifier);
6
- else if (role === 'input')
7
- locator = await el.getByLabel(identifier).or(el.getByPlaceholder(identifier));
8
- else
9
- locator = await el.getByRole(role, { name: identifier });
10
- if (text)
11
- return await locator.filter({ hasText: text });
12
- return locator;
13
- }
14
- async function setValue(locator, value) {
15
- let { tag, type, role } = await locator.evaluate((el) => ({ tag: el.tagName.toLowerCase(), type: el.getAttribute('type')?.toLowerCase(), role: el.getAttribute('role')?.toLowerCase() }));
16
- if (tag === 'select') {
17
- let values = value.split(/\s*(?<!\\),\s*/).map((v) => v.replace(/\\,/g, ','));
18
- await locator.selectOption(values);
19
- }
20
- else if (type === 'checkbox' || type === 'radio' || role === 'checkbox') {
21
- let check = !(['false', 'no', 'unchecked', '', 'null', 'undefined', '0'].includes(value.toString().toLowerCase()));
22
- if (check)
23
- await locator.check();
24
- else
25
- await locator.uncheck();
26
- }
27
- else {
28
- await locator.fill(value);
29
- }
30
- }
31
- async function testMetatag(page, name, expected, exact, expectMatching = true) {
32
- let actual;
33
- if (name === 'title')
34
- actual = await page.title();
35
- else
36
- actual = await (await page.locator(`meta[name="${name}"]`)).getAttribute('content');
37
- let matches = exact ? actual === expected : actual?.includes(expected);
38
- if (matches !== expectMatching) {
39
- let word = exact ? 'exactly match' : 'contain';
40
- let not = expectMatching ? '' : 'not ';
41
- throw new Error(`Expected ${name} metatag ${not}to ${word} '${expected}' but got '${actual}'`);
42
- }
43
- }
44
- function sanitizeFilepath(filepath) {
45
- return filepath.replace(/\/\/+/g, '/').replace(/\/[\.~]+\//g, '/');
46
- }
47
- function defaultScreenshotPath(world) {
48
- return `${world.worldConfig.screenshotDir}/${world.toString().replace(/^.+?Feature: /, 'Feature: ').replace(' ' + world.info.step, '')}.png`;
49
- }
50
-
51
- export { defaultScreenshotPath, getLocator, sanitizeFilepath, setValue, testMetatag };
52
- //# sourceMappingURL=helpers.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.mjs","sources":["../src/helpers.ts"],"sourcesContent":[null],"names":[],"mappings":"AAGA;AACO,eAAe,UAAU,CAAC,EAAe,EAAE,UAAiB,EAAE,IAAW,EAAE,IAAA,GAAiB,IAAI,EAAA;AACrG,IAAA,IAAI,OAAe,CAAA;IACnB,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;SACzD,IAAI,IAAI,KAAK,OAAO;AAAE,QAAA,OAAO,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAA;;AACnG,QAAA,OAAO,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,IAAW,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;AACpE,IAAA,IAAI,IAAI;QAAE,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;AACxD,IAAA,OAAO,OAAO,CAAA;AAChB,CAAC;AAEM,eAAe,QAAQ,CAAC,OAAe,EAAE,KAAgB,EAAA;IAC9D,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAC,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,IAAI,EAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,IAAI,EAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC,CA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