@playq/core 0.2.77
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/README.md +41 -0
- package/bin/playq.js +175 -0
- package/cucumber.js +10 -0
- package/dist/exec/featureFileCache.d.ts +21 -0
- package/dist/exec/featureFileCache.js +124 -0
- package/dist/exec/featureFilePreProcess.d.ts +12 -0
- package/dist/exec/featureFilePreProcess.js +208 -0
- package/dist/exec/preLoader.d.ts +1 -0
- package/dist/exec/preLoader.js +72 -0
- package/dist/exec/preProcessEntry.d.ts +1 -0
- package/dist/exec/preProcessEntry.js +83 -0
- package/dist/exec/preProcess_old_todelete.d.ts +1 -0
- package/dist/exec/preProcess_old_todelete.js +258 -0
- package/dist/exec/runner.d.ts +1 -0
- package/dist/exec/runner.js +221 -0
- package/dist/exec/runner_orchestrator.d.ts +1 -0
- package/dist/exec/runner_orchestrator.js +85 -0
- package/dist/exec/sgGenerator.d.ts +11 -0
- package/dist/exec/sgGenerator.js +310 -0
- package/dist/global.d.ts +15 -0
- package/dist/global.js +185 -0
- package/dist/helper/actions/api/apiRequestActions.d.ts +117 -0
- package/dist/helper/actions/api/apiRequestActions.js +374 -0
- package/dist/helper/actions/api/apiValidationActions.d.ts +119 -0
- package/dist/helper/actions/api/apiValidationActions.js +615 -0
- package/dist/helper/actions/apiActions.d.ts +18 -0
- package/dist/helper/actions/apiActions.js +34 -0
- package/dist/helper/actions/apiStepDefs.d.ts +1 -0
- package/dist/helper/actions/apiStepDefs.js +64 -0
- package/dist/helper/actions/comm/commonActions.d.ts +58 -0
- package/dist/helper/actions/comm/commonActions.js +198 -0
- package/dist/helper/actions/comm/utilityActions.d.ts +131 -0
- package/dist/helper/actions/comm/utilityActions.js +351 -0
- package/dist/helper/actions/commActions.d.ts +18 -0
- package/dist/helper/actions/commActions.js +34 -0
- package/dist/helper/actions/commStepDefs.d.ts +1 -0
- package/dist/helper/actions/commStepDefs.js +57 -0
- package/dist/helper/actions/stepGroupStepDefs.d.ts +1 -0
- package/dist/helper/actions/stepGroupStepDefs.js +15 -0
- package/dist/helper/actions/web/alertActions.d.ts +61 -0
- package/dist/helper/actions/web/alertActions.js +224 -0
- package/dist/helper/actions/web/cookieActions.d.ts +45 -0
- package/dist/helper/actions/web/cookieActions.js +186 -0
- package/dist/helper/actions/web/downloadActions.d.ts +40 -0
- package/dist/helper/actions/web/downloadActions.js +153 -0
- package/dist/helper/actions/web/elementReaderActions.d.ts +95 -0
- package/dist/helper/actions/web/elementReaderActions.js +326 -0
- package/dist/helper/actions/web/formActions.d.ts +122 -0
- package/dist/helper/actions/web/formActions.js +423 -0
- package/dist/helper/actions/web/iframeActions.d.ts +23 -0
- package/dist/helper/actions/web/iframeActions.js +108 -0
- package/dist/helper/actions/web/javascriptActions.d.ts +14 -0
- package/dist/helper/actions/web/javascriptActions.js +77 -0
- package/dist/helper/actions/web/keyboardActions.d.ts +35 -0
- package/dist/helper/actions/web/keyboardActions.js +118 -0
- package/dist/helper/actions/web/localStorageActions.d.ts +51 -0
- package/dist/helper/actions/web/localStorageActions.js +163 -0
- package/dist/helper/actions/web/mouseActions.d.ts +240 -0
- package/dist/helper/actions/web/mouseActions.js +609 -0
- package/dist/helper/actions/web/reportingActions.d.ts +34 -0
- package/dist/helper/actions/web/reportingActions.js +58 -0
- package/dist/helper/actions/web/screenshotActions.d.ts +34 -0
- package/dist/helper/actions/web/screenshotActions.js +151 -0
- package/dist/helper/actions/web/testDataActions.d.ts +21 -0
- package/dist/helper/actions/web/testDataActions.js +211 -0
- package/dist/helper/actions/web/validationActions.d.ts +547 -0
- package/dist/helper/actions/web/validationActions.js +1754 -0
- package/dist/helper/actions/web/waitActions.d.ts +191 -0
- package/dist/helper/actions/web/waitActions.js +589 -0
- package/dist/helper/actions/web/webNavigation.d.ts +104 -0
- package/dist/helper/actions/web/webNavigation.js +288 -0
- package/dist/helper/actions/webActions.d.ts +32 -0
- package/dist/helper/actions/webActions.js +48 -0
- package/dist/helper/actions/webStepDefs.d.ts +1 -0
- package/dist/helper/actions/webStepDefs.js +455 -0
- package/dist/helper/browsers/browserManager.d.ts +1 -0
- package/dist/helper/browsers/browserManager.js +56 -0
- package/dist/helper/bundle/defaultEntries.d.ts +6 -0
- package/dist/helper/bundle/defaultEntries.js +200 -0
- package/dist/helper/bundle/env.d.ts +1 -0
- package/dist/helper/bundle/env.js +157 -0
- package/dist/helper/bundle/vars.d.ts +9 -0
- package/dist/helper/bundle/vars.js +375 -0
- package/dist/helper/faker/customFaker.d.ts +55 -0
- package/dist/helper/faker/customFaker.js +45 -0
- package/dist/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
- package/dist/helper/faker/modules/dateTime.d.ts +18 -0
- package/dist/helper/faker/modules/dateTime.js +106 -0
- package/dist/helper/faker/modules/mobile.d.ts +4 -0
- package/dist/helper/faker/modules/mobile.js +59 -0
- package/dist/helper/faker/modules/nric.d.ts +32 -0
- package/dist/helper/faker/modules/nric.js +84 -0
- package/dist/helper/faker/modules/passport.d.ts +3 -0
- package/dist/helper/faker/modules/passport.js +36 -0
- package/dist/helper/faker/modules/person.d.ts +14 -0
- package/dist/helper/faker/modules/person.js +73 -0
- package/dist/helper/faker/modules/postcode.d.ts +6 -0
- package/dist/helper/faker/modules/postcode.js +47 -0
- package/dist/helper/fixtures/locAggregate.d.ts +7 -0
- package/dist/helper/fixtures/locAggregate.js +94 -0
- package/dist/helper/fixtures/logFixture.d.ts +8 -0
- package/dist/helper/fixtures/logFixture.js +56 -0
- package/dist/helper/fixtures/webFixture.d.ts +19 -0
- package/dist/helper/fixtures/webFixture.js +186 -0
- package/dist/helper/fixtures/webLocFixture.d.ts +2 -0
- package/dist/helper/fixtures/webLocFixture.js +144 -0
- package/dist/helper/report/allureStepLogger.d.ts +0 -0
- package/dist/helper/report/allureStepLogger.js +25 -0
- package/dist/helper/report/customiseReport.d.ts +1 -0
- package/dist/helper/report/customiseReport.js +55 -0
- package/dist/helper/report/init.d.ts +1 -0
- package/dist/helper/report/init.js +14 -0
- package/dist/helper/report/report.d.ts +1 -0
- package/dist/helper/report/report.js +102 -0
- package/dist/helper/util/dataLoader.d.ts +10 -0
- package/dist/helper/util/dataLoader.js +73 -0
- package/dist/helper/util/logger.d.ts +4 -0
- package/dist/helper/util/logger.js +61 -0
- package/dist/helper/util/session/sessionUtil.d.ts +26 -0
- package/dist/helper/util/session/sessionUtil.js +729 -0
- package/dist/helper/util/stepHelpers.d.ts +2 -0
- package/dist/helper/util/stepHelpers.js +16 -0
- package/dist/helper/util/test-data/dataLoader.d.ts +7 -0
- package/dist/helper/util/test-data/dataLoader.js +145 -0
- package/dist/helper/util/test-data/dataTest.d.ts +10 -0
- package/dist/helper/util/test-data/dataTest.js +216 -0
- package/dist/helper/util/totp/totpHelper.d.ts +38 -0
- package/dist/helper/util/totp/totpHelper.js +117 -0
- package/dist/helper/util/utilities/cryptoUtil.d.ts +2 -0
- package/dist/helper/util/utilities/cryptoUtil.js +53 -0
- package/dist/helper/util/utilities/schemaGeneratorUtil.d.ts +2 -0
- package/dist/helper/util/utilities/schemaGeneratorUtil.js +129 -0
- package/dist/helper/util/utils.d.ts +2 -0
- package/dist/helper/util/utils.js +22 -0
- package/dist/helper/wrapper/PlaywrightWrappers.d.ts +8 -0
- package/dist/helper/wrapper/PlaywrightWrappers.js +26 -0
- package/dist/helper/wrapper/assert.d.ts +9 -0
- package/dist/helper/wrapper/assert.js +23 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +57 -0
- package/dist/scripts/get-versions.d.ts +1 -0
- package/dist/scripts/get-versions.js +98 -0
- package/dist/scripts/posttest.d.ts +1 -0
- package/dist/scripts/posttest.js +29 -0
- package/dist/scripts/pretest.d.ts +1 -0
- package/dist/scripts/pretest.js +57 -0
- package/dist/scripts/util.d.ts +1 -0
- package/dist/scripts/util.js +376 -0
- package/package.json +68 -0
- package/src/exec/featureFileCache.ts +80 -0
- package/src/exec/featureFilePreProcess.ts +239 -0
- package/src/exec/preLoader.ts +72 -0
- package/src/exec/preProcessEntry.ts +59 -0
- package/src/exec/preProcess_old_todelete.ts +289 -0
- package/src/exec/runner.ts +241 -0
- package/src/exec/runnerCuke.js +90 -0
- package/src/exec/runner_orchestrator.ts +91 -0
- package/src/exec/sgGenerator.ts +373 -0
- package/src/global.ts +130 -0
- package/src/helper/actions/api/apiRequestActions.ts +362 -0
- package/src/helper/actions/api/apiValidationActions.ts +594 -0
- package/src/helper/actions/apiActions.ts +18 -0
- package/src/helper/actions/apiStepDefs.ts +80 -0
- package/src/helper/actions/comm/commonActions.ts +165 -0
- package/src/helper/actions/comm/utilityActions.ts +344 -0
- package/src/helper/actions/commActions.ts +18 -0
- package/src/helper/actions/commStepDefs.ts +72 -0
- package/src/helper/actions/stepGroupStepDefs.ts +17 -0
- package/src/helper/actions/web/alertActions.ts +179 -0
- package/src/helper/actions/web/cookieActions.ts +124 -0
- package/src/helper/actions/web/downloadActions.ts +129 -0
- package/src/helper/actions/web/elementReaderActions.ts +323 -0
- package/src/helper/actions/web/formActions.ts +469 -0
- package/src/helper/actions/web/iframeActions.ts +67 -0
- package/src/helper/actions/web/javascriptActions.ts +38 -0
- package/src/helper/actions/web/keyboardActions.ts +101 -0
- package/src/helper/actions/web/localStorageActions.ts +109 -0
- package/src/helper/actions/web/mouseActions.ts +864 -0
- package/src/helper/actions/web/reportingActions.ts +53 -0
- package/src/helper/actions/web/screenshotActions.ts +124 -0
- package/src/helper/actions/web/testDataActions.ts +162 -0
- package/src/helper/actions/web/validationActions.ts +2287 -0
- package/src/helper/actions/web/waitActions.ts +757 -0
- package/src/helper/actions/web/webNavigation.ts +313 -0
- package/src/helper/actions/webActions.ts +33 -0
- package/src/helper/actions/webStepDefs.ts +505 -0
- package/src/helper/browsers/browserManager.ts +23 -0
- package/src/helper/bundle/defaultEntries.ts +208 -0
- package/src/helper/bundle/env.ts +119 -0
- package/src/helper/bundle/vars.ts +368 -0
- package/src/helper/faker/customFaker.ts +107 -0
- package/src/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
- package/src/helper/faker/modules/dateTime.ts +121 -0
- package/src/helper/faker/modules/mobile.ts +58 -0
- package/src/helper/faker/modules/nric.ts +109 -0
- package/src/helper/faker/modules/passport.ts +34 -0
- package/src/helper/faker/modules/person.ts +93 -0
- package/src/helper/faker/modules/postcode.ts +57 -0
- package/src/helper/fixtures/locAggregate.ts +61 -0
- package/src/helper/fixtures/logFixture.ts +57 -0
- package/src/helper/fixtures/webFixture.ts +206 -0
- package/src/helper/fixtures/webLocFixture.ts +143 -0
- package/src/helper/report/allureStepLogger.ts +26 -0
- package/src/helper/report/customiseReport.ts +61 -0
- package/src/helper/report/init.ts +18 -0
- package/src/helper/report/report.ts +72 -0
- package/src/helper/util/dataLoader.ts +42 -0
- package/src/helper/util/logger.ts +32 -0
- package/src/helper/util/session/sessionUtil.ts +839 -0
- package/src/helper/util/stepHelpers.ts +14 -0
- package/src/helper/util/test-data/dataLoader.ts +108 -0
- package/src/helper/util/test-data/dataTest.ts +191 -0
- package/src/helper/util/test-data/registerUser.json +7 -0
- package/src/helper/util/totp/totpHelper.ts +102 -0
- package/src/helper/util/utilities/cryptoUtil.ts +53 -0
- package/src/helper/util/utilities/schemaGeneratorUtil.ts +143 -0
- package/src/helper/util/utils.ts +28 -0
- package/src/helper/wrapper/PlaywrightWrappers.ts +28 -0
- package/src/helper/wrapper/assert.ts +25 -0
- package/src/index.ts +17 -0
- package/src/scripts/get-versions.ts +68 -0
- package/src/scripts/posttest.ts +32 -0
- package/src/scripts/pretest.ts +48 -0
- package/src/scripts/util.ts +406 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file localStorageActions.ts
|
|
3
|
+
*
|
|
4
|
+
* window.localStorage helpers for PlayQ web actions.
|
|
5
|
+
* Provides set/get/remove/clear with runner-aware step wrappers.
|
|
6
|
+
*
|
|
7
|
+
* Authors: PlayQ Team
|
|
8
|
+
* Version: v1.0.0
|
|
9
|
+
*/
|
|
10
|
+
import * as allure from "allure-js-commons";
|
|
11
|
+
import type { Page } from "playwright";
|
|
12
|
+
import { vars } from "../../../global";
|
|
13
|
+
|
|
14
|
+
function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
|
|
15
|
+
const __allureAny_ls: any = allure as any;
|
|
16
|
+
if (typeof __allureAny_ls.step !== 'function') { __allureAny_ls.step = async (_n: string, f: any) => await f(); }
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Web: LocalStorage Set -key: {param} -value: {param}
|
|
20
|
+
*
|
|
21
|
+
* Sets a key/value pair in window.localStorage.
|
|
22
|
+
*
|
|
23
|
+
* @param page - Playwright Page instance
|
|
24
|
+
* @param key - Storage key (required)
|
|
25
|
+
* @param value - Storage value
|
|
26
|
+
* @param options - Optional JSON string or object (reserved for future flags)
|
|
27
|
+
* @throws Error if page is not initialized or key is missing
|
|
28
|
+
*/
|
|
29
|
+
export async function setItem(page: Page, key: string, value: string, options?: any) {
|
|
30
|
+
const stepName = `Web: LocalStorage Set -key: ${key}`;
|
|
31
|
+
if (!page) throw new Error("Page not initialized");
|
|
32
|
+
if (!key) throw new Error("LocalStorage.setItem: 'key' is required");
|
|
33
|
+
const _opts = typeof options === 'string' ? vars.parseLooseJson(options) : (options || {}); // reserved for future flags
|
|
34
|
+
const run = async () => page.evaluate(([k, v]) => localStorage.setItem(k, v), [key, value]);
|
|
35
|
+
if (isPlaywrightRunner()) { await __allureAny_ls.step(stepName, run); } else { await run(); }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Friendly aliases
|
|
39
|
+
export const localStorageSet = setItem;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Web: LocalStorage Get -key: {param} -options: {param}
|
|
43
|
+
*
|
|
44
|
+
* Retrieves a value by key from window.localStorage.
|
|
45
|
+
*
|
|
46
|
+
* @param page - Playwright Page instance
|
|
47
|
+
* @param key - Storage key (required)
|
|
48
|
+
* @param options - Optional JSON string or object:
|
|
49
|
+
* - assert: [boolean] If true, throws when value is null/undefined (default: false)
|
|
50
|
+
* @returns Stored value or null
|
|
51
|
+
* @throws Error if page is not initialized or key is missing
|
|
52
|
+
*/
|
|
53
|
+
export async function getItem(page: Page, key: string, options?: any) {
|
|
54
|
+
const stepName = `Web: LocalStorage Get -key: ${key}`;
|
|
55
|
+
if (!page) throw new Error("Page not initialized");
|
|
56
|
+
if (!key) throw new Error("LocalStorage.getItem: 'key' is required");
|
|
57
|
+
const _opts = typeof options === 'string' ? vars.parseLooseJson(options) : (options || {});
|
|
58
|
+
const run = async () => page.evaluate((k) => localStorage.getItem(k), key);
|
|
59
|
+
const result = isPlaywrightRunner() ? await __allureAny_ls.step(stepName, run) : await run();
|
|
60
|
+
if (_opts?.assert === true && (result === null || result === undefined)) {
|
|
61
|
+
throw new Error(`LocalStorage.getItem: No value found for key '${key}'`);
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Friendly aliases
|
|
67
|
+
export const localStorageGet = getItem;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Web: LocalStorage Remove -key: {param}
|
|
71
|
+
*
|
|
72
|
+
* Removes a key from window.localStorage.
|
|
73
|
+
*
|
|
74
|
+
* @param page - Playwright Page instance
|
|
75
|
+
* @param key - Storage key (required)
|
|
76
|
+
* @param options - Optional JSON string or object (reserved for future flags)
|
|
77
|
+
* @throws Error if page is not initialized or key is missing
|
|
78
|
+
*/
|
|
79
|
+
export async function removeItem(page: Page, key: string, options?: any) {
|
|
80
|
+
const stepName = `Web: LocalStorage Remove -key: ${key}`;
|
|
81
|
+
if (!page) throw new Error("Page not initialized");
|
|
82
|
+
if (!key) throw new Error("LocalStorage.removeItem: 'key' is required");
|
|
83
|
+
const _opts = typeof options === 'string' ? vars.parseLooseJson(options) : (options || {}); // reserved for future flags
|
|
84
|
+
const run = async () => page.evaluate((k) => localStorage.removeItem(k), key);
|
|
85
|
+
if (isPlaywrightRunner()) { await __allureAny_ls.step(stepName, run); } else { await run(); }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Friendly aliases
|
|
89
|
+
export const localStorageRemove = removeItem;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Web: LocalStorage Clear -options: {param}
|
|
93
|
+
*
|
|
94
|
+
* Clears all keys from window.localStorage.
|
|
95
|
+
*
|
|
96
|
+
* @param page - Playwright Page instance
|
|
97
|
+
* @param options - Optional JSON string or object (reserved for future flags)
|
|
98
|
+
* @throws Error if page is not initialized
|
|
99
|
+
*/
|
|
100
|
+
export async function clearStorage(page: Page, options?: any) {
|
|
101
|
+
const stepName = `Web: LocalStorage Clear`;
|
|
102
|
+
if (!page) throw new Error("Page not initialized");
|
|
103
|
+
const _opts = typeof options === 'string' ? vars.parseLooseJson(options) : (options || {}); // reserved for future flags
|
|
104
|
+
const run = async () => page.evaluate(() => localStorage.clear());
|
|
105
|
+
if (isPlaywrightRunner()) { await __allureAny_ls.step(stepName, run); } else { await run(); }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Friendly aliases
|
|
109
|
+
export const localStorageClear = clearStorage;
|