@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,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateMobileNumber = generateMobileNumber;
|
|
4
|
+
// src/helper/faker/modules/mobile.ts
|
|
5
|
+
const faker_1 = require("@faker-js/faker");
|
|
6
|
+
function generateMobileNumber(options) {
|
|
7
|
+
const { countryCode = 'AU', dialCodePrefix = true } = options || {};
|
|
8
|
+
switch (countryCode.toUpperCase()) {
|
|
9
|
+
case "AU": {
|
|
10
|
+
const prefix = "04";
|
|
11
|
+
const digits = faker_1.faker.string.numeric(8);
|
|
12
|
+
return dialCodePrefix ? `+61${prefix.slice(1)}${digits}` : `${prefix}${digits}`;
|
|
13
|
+
}
|
|
14
|
+
case "SG": {
|
|
15
|
+
const allowedPrefixes = ["855", "955"];
|
|
16
|
+
const prefix = faker_1.faker.helpers.arrayElement(allowedPrefixes);
|
|
17
|
+
const digits = faker_1.faker.string.numeric(5);
|
|
18
|
+
return dialCodePrefix ? `+65${prefix}${digits}` : `${prefix}${digits}`;
|
|
19
|
+
}
|
|
20
|
+
case "IN": {
|
|
21
|
+
const allowedPrefixes = ["6", "7", "8", "9"];
|
|
22
|
+
const prefix = faker_1.faker.helpers.arrayElement(allowedPrefixes);
|
|
23
|
+
const digits = faker_1.faker.string.numeric(9);
|
|
24
|
+
return dialCodePrefix ? `+91${prefix}${digits}` : `${prefix}${digits}`;
|
|
25
|
+
}
|
|
26
|
+
case "US": {
|
|
27
|
+
const allowedPrefixes = ["2", "3", "4", "5", "6", "7", "8", "9"];
|
|
28
|
+
const prefix = faker_1.faker.helpers.arrayElement(allowedPrefixes);
|
|
29
|
+
const digits = faker_1.faker.string.numeric(7);
|
|
30
|
+
return dialCodePrefix ? `+1${prefix}${digits}` : `${prefix}${digits}`;
|
|
31
|
+
}
|
|
32
|
+
case "UK": {
|
|
33
|
+
const allowedPrefixes = ["7", "8", "9"];
|
|
34
|
+
const prefix = faker_1.faker.helpers.arrayElement(allowedPrefixes);
|
|
35
|
+
const digits = faker_1.faker.string.numeric(8);
|
|
36
|
+
return dialCodePrefix ? `+44${prefix}${digits}` : `${prefix}${digits}`;
|
|
37
|
+
}
|
|
38
|
+
case "CA": {
|
|
39
|
+
const allowedPrefixes = ["2", "3", "4", "5", "6", "7", "8", "9"];
|
|
40
|
+
const prefix = faker_1.faker.helpers.arrayElement(allowedPrefixes);
|
|
41
|
+
const digits = faker_1.faker.string.numeric(7);
|
|
42
|
+
return dialCodePrefix ? `+1${prefix}${digits}` : `${prefix}${digits}`;
|
|
43
|
+
}
|
|
44
|
+
case "NZ": {
|
|
45
|
+
const allowedPrefixes = ["2", "3", "4", "5", "6", "7", "8", "9"];
|
|
46
|
+
const prefix = faker_1.faker.helpers.arrayElement(allowedPrefixes);
|
|
47
|
+
const digits = faker_1.faker.string.numeric(7);
|
|
48
|
+
return dialCodePrefix ? `+64${prefix}${digits}` : `${prefix}${digits}`;
|
|
49
|
+
}
|
|
50
|
+
case "PH": {
|
|
51
|
+
const allowedPrefixes = ["8", "9"];
|
|
52
|
+
const prefix = faker_1.faker.helpers.arrayElement(allowedPrefixes);
|
|
53
|
+
const digits = faker_1.faker.string.numeric(7);
|
|
54
|
+
return dialCodePrefix ? `+63${prefix}${digits}` : `${prefix}${digits}`;
|
|
55
|
+
}
|
|
56
|
+
default:
|
|
57
|
+
throw new Error(`Unsupported country code: ${countryCode}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a valid Singapore NRIC or FIN number according to official NRIC/FIN checksum rules.
|
|
3
|
+
*
|
|
4
|
+
* Rules:
|
|
5
|
+
* - The prefix is 'S' or 'T' for Singaporeans/PRs, 'F' or 'G' for foreigners.
|
|
6
|
+
* - 'S' and 'F' are for those registered before 2000, 'T' and 'G' for 2000 and after.
|
|
7
|
+
* - The 7 digits: first two are year of birth/registration, next five are random.
|
|
8
|
+
* - The checksum character is calculated using weights [2,7,6,5,4,3,2] and a modulo-11 algorithm.
|
|
9
|
+
* - For 'T' and 'G', add 4 to the sum before modulo.
|
|
10
|
+
* - The checksum character set differs for citizen/PR ('S','T') and foreigner ('F','G') prefixes.
|
|
11
|
+
* See: https://en.wikipedia.org/wiki/National_Registration_Identity_Card#Structure
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Options for NRIC generation.
|
|
15
|
+
*/
|
|
16
|
+
export interface NRICOptions {
|
|
17
|
+
prefix?: string;
|
|
18
|
+
yearOfBirth?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Generate a valid Singapore NRIC or FIN number according to official NRIC/FIN checksum rules.
|
|
22
|
+
* @param options - Options for NRIC generation.
|
|
23
|
+
* @returns A valid NRIC string.
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateNRIC(options?: NRICOptions): string;
|
|
26
|
+
/**
|
|
27
|
+
Function to extract the year from an NRIC number
|
|
28
|
+
@param nric - The NRIC number as a string
|
|
29
|
+
@returns The year of birth as a number, or null if the NRIC is invalid
|
|
30
|
+
*/
|
|
31
|
+
declare function getYearFromNRIC(nric: string): number | null;
|
|
32
|
+
export { getYearFromNRIC };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateNRIC = generateNRIC;
|
|
4
|
+
exports.getYearFromNRIC = getYearFromNRIC;
|
|
5
|
+
const faker_1 = require("@faker-js/faker");
|
|
6
|
+
const ST_CHECKSUM_CHARS = ["J", "Z", "I", "H", "G", "F", "E", "D", "C", "B", "A"];
|
|
7
|
+
const FG_CHECKSUM_CHARS = ["X", "W", "U", "T", "R", "Q", "P", "N", "M", "L", "K"];
|
|
8
|
+
function calculateNRICChecksum(prefix, digits) {
|
|
9
|
+
const WEIGHTS = [2, 7, 6, 5, 4, 3, 2];
|
|
10
|
+
const digitArr = digits.split('').map(Number);
|
|
11
|
+
let sum = digitArr.reduce((acc, digit, idx) => acc + digit * WEIGHTS[idx], 0);
|
|
12
|
+
if (prefix === 'T' || prefix === 'G') {
|
|
13
|
+
sum += 4;
|
|
14
|
+
}
|
|
15
|
+
const remainder = sum % 11;
|
|
16
|
+
if (prefix === 'S' || prefix === 'T') {
|
|
17
|
+
return ST_CHECKSUM_CHARS[remainder];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return FG_CHECKSUM_CHARS[remainder];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Generate a valid Singapore NRIC or FIN number according to official NRIC/FIN checksum rules.
|
|
25
|
+
* @param options - Options for NRIC generation.
|
|
26
|
+
* @returns A valid NRIC string.
|
|
27
|
+
*/
|
|
28
|
+
function generateNRIC(options = {}) {
|
|
29
|
+
let { prefix, yearOfBirth } = options;
|
|
30
|
+
yearOfBirth = yearOfBirth ? Number(yearOfBirth) : undefined;
|
|
31
|
+
if (typeof yearOfBirth === 'number' && yearOfBirth > new Date().getFullYear()) {
|
|
32
|
+
throw new Error(`❌ yearOfBirth ${yearOfBirth} is in the future.`);
|
|
33
|
+
}
|
|
34
|
+
let resolvedPrefix;
|
|
35
|
+
if (prefix) {
|
|
36
|
+
resolvedPrefix = prefix;
|
|
37
|
+
}
|
|
38
|
+
else if (typeof yearOfBirth === 'number') {
|
|
39
|
+
resolvedPrefix = yearOfBirth >= 2000 ? 'T' : 'S';
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
resolvedPrefix = faker_1.faker.helpers.arrayElement(['S', 'T', 'F', 'G']);
|
|
43
|
+
}
|
|
44
|
+
if (!['S', 'T', 'F', 'G'].includes(resolvedPrefix)) {
|
|
45
|
+
console.warn(`⚠️ Invalid prefix "${resolvedPrefix}" — choosing random valid prefix.`);
|
|
46
|
+
resolvedPrefix = faker_1.faker.helpers.arrayElement(['S', 'T', 'F', 'G']);
|
|
47
|
+
}
|
|
48
|
+
let digits;
|
|
49
|
+
if (typeof yearOfBirth === 'number') {
|
|
50
|
+
const yearDigits = String(yearOfBirth).slice(-2);
|
|
51
|
+
const randomDigits = faker_1.faker.string.numeric({ length: 5, allowLeadingZeros: true });
|
|
52
|
+
digits = `${yearDigits}${randomDigits}`;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
digits = faker_1.faker.string.numeric({ length: 7, allowLeadingZeros: true });
|
|
56
|
+
}
|
|
57
|
+
const checksum = calculateNRICChecksum(resolvedPrefix, digits);
|
|
58
|
+
return `${resolvedPrefix}${digits}${checksum}`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
Function to extract the year from an NRIC number
|
|
62
|
+
@param nric - The NRIC number as a string
|
|
63
|
+
@returns The year of birth as a number, or null if the NRIC is invalid
|
|
64
|
+
*/
|
|
65
|
+
function getYearFromNRIC(nric) {
|
|
66
|
+
if (!/^[STFG]\d{7}[A-Z]$/.test(nric)) {
|
|
67
|
+
console.warn(`❌ Invalid NRIC format: ${nric}`);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const prefix = nric.charAt(0).toUpperCase();
|
|
71
|
+
const yearDigits = parseInt(nric.slice(1, 3), 10);
|
|
72
|
+
if (isNaN(yearDigits))
|
|
73
|
+
return null;
|
|
74
|
+
switch (prefix) {
|
|
75
|
+
case "S": // Born before 2000 (Singaporean)
|
|
76
|
+
case "F": // Foreigner before 2000
|
|
77
|
+
return 1900 + yearDigits;
|
|
78
|
+
case "T": // Born in or after 2000 (Singaporean)
|
|
79
|
+
case "G": // Foreigner in or after 2000
|
|
80
|
+
return 2000 + yearDigits;
|
|
81
|
+
default:
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePassportNumber = generatePassportNumber;
|
|
4
|
+
// src/helper/faker/modules/passport.ts
|
|
5
|
+
const faker_1 = require("@faker-js/faker");
|
|
6
|
+
function generatePassportNumber(options) {
|
|
7
|
+
const { countryCode = 'AU' } = options;
|
|
8
|
+
switch (countryCode.toUpperCase()) {
|
|
9
|
+
case "IN":
|
|
10
|
+
return `${faker_1.faker.string.alpha({
|
|
11
|
+
length: 1,
|
|
12
|
+
casing: "upper",
|
|
13
|
+
})}${faker_1.faker.string.numeric(7)}`;
|
|
14
|
+
case "UK":
|
|
15
|
+
return `${faker_1.faker.string.alpha({
|
|
16
|
+
length: 2,
|
|
17
|
+
casing: "upper",
|
|
18
|
+
})}${faker_1.faker.string.numeric(7)}`;
|
|
19
|
+
case "US":
|
|
20
|
+
return faker_1.faker.string.numeric(9);
|
|
21
|
+
case "AU": {
|
|
22
|
+
const allowedPrefixes = ["PA", "PB", "PC", "PD", "PE", "PF", "PU", "PW", "PX", "PZ"];
|
|
23
|
+
const prefix = faker_1.faker.helpers.arrayElement(allowedPrefixes);
|
|
24
|
+
const digits = faker_1.faker.string.numeric(7);
|
|
25
|
+
return `${prefix}${digits}`;
|
|
26
|
+
}
|
|
27
|
+
case "SG": {
|
|
28
|
+
const allowedPrefixes = ["E", "K", "S"];
|
|
29
|
+
const prefix = faker_1.faker.helpers.arrayElement(allowedPrefixes);
|
|
30
|
+
const digits = faker_1.faker.string.numeric(7);
|
|
31
|
+
return `${prefix}${digits}`;
|
|
32
|
+
}
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(`Unsupported country code: ${countryCode}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface PersonNameOptions {
|
|
2
|
+
gender?: 'male' | 'female';
|
|
3
|
+
withPrefix?: boolean;
|
|
4
|
+
maxLength?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function generatePersonFullName(options?: PersonNameOptions): string;
|
|
7
|
+
interface BirthDateOptions {
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
year?: number;
|
|
11
|
+
format?: 'DD-MM-YYYY' | 'MM-DD-YYYY' | 'YYYY-MM-DD' | 'DD/MM/YYYY' | 'MM/DD/YYYY' | 'YYYY/MM/DD' | 'DD-MM-YY' | 'MM-DD-YY' | 'YY-MM-DD' | 'DD/MM/YY' | 'MM/DD/YY' | 'YY/MM/DD';
|
|
12
|
+
}
|
|
13
|
+
export declare function generateBirthDate(options?: BirthDateOptions): string;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePersonFullName = generatePersonFullName;
|
|
4
|
+
exports.generateBirthDate = generateBirthDate;
|
|
5
|
+
const faker_1 = require("@faker-js/faker");
|
|
6
|
+
function generatePersonFullName(options = {}) {
|
|
7
|
+
const { gender, withPrefix = false, maxLength } = options;
|
|
8
|
+
let firstName = faker_1.faker.person.firstName(gender);
|
|
9
|
+
let lastName = faker_1.faker.person.lastName(gender);
|
|
10
|
+
let fullName = withPrefix
|
|
11
|
+
? `${faker_1.faker.person.prefix(gender)} ${firstName} ${lastName}`
|
|
12
|
+
: `${firstName} ${lastName}`;
|
|
13
|
+
if (maxLength && fullName.length > maxLength) {
|
|
14
|
+
// Try trimming last name first, then first name
|
|
15
|
+
lastName = lastName.slice(0, Math.max(1, Math.floor((maxLength - firstName.length - 1))));
|
|
16
|
+
fullName = withPrefix
|
|
17
|
+
? `${faker_1.faker.person.prefix(gender)} ${firstName} ${lastName}`
|
|
18
|
+
: `${firstName} ${lastName}`;
|
|
19
|
+
if (fullName.length > maxLength) {
|
|
20
|
+
firstName = firstName.slice(0, Math.max(1, maxLength - lastName.length - 1));
|
|
21
|
+
fullName = withPrefix
|
|
22
|
+
? `${faker_1.faker.person.prefix(gender)} ${firstName} ${lastName}`
|
|
23
|
+
: `${firstName} ${lastName}`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return fullName.replace(/-/g, ' ');
|
|
27
|
+
}
|
|
28
|
+
function generateBirthDate(options = {}) {
|
|
29
|
+
const { min = 18, max = 65, year, format = 'DD-MM-YYYY' } = options;
|
|
30
|
+
let date;
|
|
31
|
+
// const date = faker.date.birthdate({ min, max, mode: 'age' });
|
|
32
|
+
if (year) {
|
|
33
|
+
// Generate a random date in the given year
|
|
34
|
+
const month = faker_1.faker.number.int({ min: 0, max: 11 });
|
|
35
|
+
const day = faker_1.faker.number.int({ min: 1, max: 28 }); // Safe for all months
|
|
36
|
+
date = new Date(year, month, day);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
date = faker_1.faker.date.birthdate({ min, max, mode: 'age' });
|
|
40
|
+
}
|
|
41
|
+
const dd = String(date.getDate()).padStart(2, '0');
|
|
42
|
+
const mm = String(date.getMonth() + 1).padStart(2, '0');
|
|
43
|
+
const yyyy = date.getFullYear();
|
|
44
|
+
const yy = String(yyyy).slice(-2);
|
|
45
|
+
switch (format) {
|
|
46
|
+
case 'YYYY-MM-DD':
|
|
47
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
48
|
+
case 'YYYY/MM/DD':
|
|
49
|
+
return `${yyyy}/${mm}/${dd}`;
|
|
50
|
+
case 'MM-DD-YYYY':
|
|
51
|
+
return `${mm}-${dd}-${yyyy}`;
|
|
52
|
+
case 'MM/DD/YYYY':
|
|
53
|
+
return `${mm}/${dd}/${yyyy}`;
|
|
54
|
+
case 'DD/MM/YYYY':
|
|
55
|
+
return `${dd}/${mm}/${yyyy}`;
|
|
56
|
+
case 'DD-MM-YYYY':
|
|
57
|
+
return `${dd}-${mm}-${yyyy}`;
|
|
58
|
+
case 'DD-MM-YY':
|
|
59
|
+
return `${dd}-${mm}-${yy}`;
|
|
60
|
+
case 'MM-DD-YY':
|
|
61
|
+
return `${mm}-${dd}-${yy}`;
|
|
62
|
+
case 'YY-MM-DD':
|
|
63
|
+
return `${yy}-${mm}-${dd}`;
|
|
64
|
+
case 'DD/MM/YY':
|
|
65
|
+
return `${dd}/${mm}/${yy}`;
|
|
66
|
+
case 'MM/DD/YY':
|
|
67
|
+
return `${mm}/${dd}/${yy}`;
|
|
68
|
+
case 'YY/MM/DD':
|
|
69
|
+
return `${yy}/${mm}/${dd}`;
|
|
70
|
+
default:
|
|
71
|
+
return `${dd}-${mm}-${yyyy}`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getValidPostCode = getValidPostCode;
|
|
7
|
+
// src/helper/faker/modules/passport.ts
|
|
8
|
+
const faker_1 = require("@faker-js/faker");
|
|
9
|
+
const postcodes_valid_sg_json_1 = __importDefault(require("./data/postcodes_valid_sg.json"));
|
|
10
|
+
function getValidPostCode(options = {}) {
|
|
11
|
+
// export function getValidPostCode(countryCode: string = "AU", stateCode?: string): string {
|
|
12
|
+
const { countryCode = "AU", stateCode = "" } = options;
|
|
13
|
+
switch (countryCode.toUpperCase()) {
|
|
14
|
+
case "SG": {
|
|
15
|
+
return faker_1.faker.helpers.arrayElement(postcodes_valid_sg_json_1.default);
|
|
16
|
+
}
|
|
17
|
+
case "AU":
|
|
18
|
+
const AU_STATE_RANGES = {
|
|
19
|
+
"NSW": [2000, 2999],
|
|
20
|
+
"ACT": [2600, 2639],
|
|
21
|
+
"VIC": [3000, 3999],
|
|
22
|
+
"QLD": [4000, 4999],
|
|
23
|
+
"SA": [5000, 5799],
|
|
24
|
+
"WA": [6000, 6797],
|
|
25
|
+
"TAS": [7000, 7799],
|
|
26
|
+
"NT": [800, 899]
|
|
27
|
+
};
|
|
28
|
+
if (stateCode) {
|
|
29
|
+
const range = AU_STATE_RANGES[stateCode.toUpperCase()];
|
|
30
|
+
if (!range) {
|
|
31
|
+
throw new Error(`Unsupported state code: ${stateCode}`);
|
|
32
|
+
}
|
|
33
|
+
const [min, max] = range;
|
|
34
|
+
const postcodeLength = max.toString().length;
|
|
35
|
+
const postcode = faker_1.faker.number.int({ min, max }).toString().padStart(postcodeLength, '0');
|
|
36
|
+
return postcode;
|
|
37
|
+
}
|
|
38
|
+
// If no state is specified, choose a random state and generate a postcode
|
|
39
|
+
const randomState = faker_1.faker.helpers.arrayElement(Object.keys(AU_STATE_RANGES));
|
|
40
|
+
const [min, max] = AU_STATE_RANGES[randomState];
|
|
41
|
+
const postcodeLength = max.toString().length;
|
|
42
|
+
const postcode = faker_1.faker.number.int({ min, max }).toString().padStart(postcodeLength, '0');
|
|
43
|
+
return postcode;
|
|
44
|
+
default:
|
|
45
|
+
throw new Error(`Unsupported country code: ${countryCode}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamically builds the `loc` namespace from the consumer project.
|
|
3
|
+
* - Scans PLAYQ_PROJECT_ROOT/resources/locators for *.loc.ts or *.ts files
|
|
4
|
+
* - Imports each module (requires ts-node registration in the child process)
|
|
5
|
+
* - Collects named exports and default object keys into a single namespace
|
|
6
|
+
*/
|
|
7
|
+
export declare function getLocNamespace(): Record<string, any>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getLocNamespace = getLocNamespace;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* Dynamically builds the `loc` namespace from the consumer project.
|
|
41
|
+
* - Scans PLAYQ_PROJECT_ROOT/resources/locators for *.loc.ts or *.ts files
|
|
42
|
+
* - Imports each module (requires ts-node registration in the child process)
|
|
43
|
+
* - Collects named exports and default object keys into a single namespace
|
|
44
|
+
*/
|
|
45
|
+
function getLocNamespace() {
|
|
46
|
+
const base = safeProjectRoot();
|
|
47
|
+
const dir = path.resolve(base, 'resources/locators');
|
|
48
|
+
const out = {};
|
|
49
|
+
if (!fs.existsSync(dir)) {
|
|
50
|
+
// Not an error—project may not provide locators
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
const files = fs.readdirSync(dir)
|
|
54
|
+
.filter(f => f.endsWith('.ts') || f.endsWith('.js'))
|
|
55
|
+
.map(f => path.join(dir, f));
|
|
56
|
+
for (const file of files) {
|
|
57
|
+
try {
|
|
58
|
+
// Clear module cache to reflect changes between runs
|
|
59
|
+
delete require.cache[require.resolve(file)];
|
|
60
|
+
const mod = require(file);
|
|
61
|
+
// Prefer named exports: export const lambdatest = {...}
|
|
62
|
+
for (const key of Object.keys(mod)) {
|
|
63
|
+
if (key === 'default')
|
|
64
|
+
continue;
|
|
65
|
+
out[key] = mod[key];
|
|
66
|
+
}
|
|
67
|
+
// If default export is an object (e.g., { lambdatest: {...} }), merge keys
|
|
68
|
+
const def = mod.default;
|
|
69
|
+
if (def && typeof def === 'object') {
|
|
70
|
+
for (const [k, v] of Object.entries(def)) {
|
|
71
|
+
// Do not overwrite explicitly named exports
|
|
72
|
+
if (!(k in out))
|
|
73
|
+
out[k] = v;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
console.warn(`⚠️ Failed to load loc module ${file}:`, (e === null || e === void 0 ? void 0 : e.message) || e);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
function safeProjectRoot() {
|
|
84
|
+
if (process.env.PLAYQ_PROJECT_ROOT)
|
|
85
|
+
return process.env.PLAYQ_PROJECT_ROOT;
|
|
86
|
+
// Walk up to find a package.json as fallback
|
|
87
|
+
let current = process.cwd();
|
|
88
|
+
while (current !== path.dirname(current)) {
|
|
89
|
+
if (fs.existsSync(path.join(current, 'package.json')))
|
|
90
|
+
return current;
|
|
91
|
+
current = path.dirname(current);
|
|
92
|
+
}
|
|
93
|
+
return process.cwd();
|
|
94
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.logFixture = void 0;
|
|
7
|
+
const winston_1 = require("winston");
|
|
8
|
+
const logger_1 = require("../util/logger");
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
let logger;
|
|
12
|
+
exports.logFixture = {
|
|
13
|
+
init(scenarioName) {
|
|
14
|
+
logger = (0, winston_1.createLogger)((0, logger_1.options)(scenarioName));
|
|
15
|
+
},
|
|
16
|
+
get() {
|
|
17
|
+
if (!logger)
|
|
18
|
+
throw new Error("Logger not initialized!");
|
|
19
|
+
return logger;
|
|
20
|
+
},
|
|
21
|
+
setLogger(log) {
|
|
22
|
+
logger = log;
|
|
23
|
+
},
|
|
24
|
+
getLogger() {
|
|
25
|
+
return logger;
|
|
26
|
+
},
|
|
27
|
+
async attach(name, data, type = 'application/octet-stream') {
|
|
28
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
29
|
+
const ext = type.includes('png') ? 'png' : type.includes('jpg') ? 'jpg' : 'txt';
|
|
30
|
+
const filename = `${timestamp}-${name.replace(/\s+/g, '_')}.${ext}`;
|
|
31
|
+
const attachmentDir = path_1.default.resolve('logs', 'attachments');
|
|
32
|
+
const filePath = path_1.default.join(attachmentDir, filename);
|
|
33
|
+
fs_1.default.mkdirSync(attachmentDir, { recursive: true });
|
|
34
|
+
fs_1.default.writeFileSync(filePath, data);
|
|
35
|
+
logger.info(`📎 Attached file: ${filePath}`);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
// // src/hooks/logFixture.ts
|
|
39
|
+
// import { Logger, createLogger, format, transports } from 'winston';
|
|
40
|
+
// let logger: Logger;
|
|
41
|
+
// export const logFixture = {
|
|
42
|
+
// init(scenarioName: string): void {
|
|
43
|
+
// logger = createLogger({
|
|
44
|
+
// level: 'info',
|
|
45
|
+
// format: format.combine(
|
|
46
|
+
// format.timestamp(),
|
|
47
|
+
// format.printf(({ timestamp, level, message }) => `[${timestamp}] ${level}: ${message}`)
|
|
48
|
+
// ),
|
|
49
|
+
// transports: [new transports.Console()]
|
|
50
|
+
// });
|
|
51
|
+
// },
|
|
52
|
+
// get(): Logger {
|
|
53
|
+
// if (!logger) throw new Error("Logger not initialized!");
|
|
54
|
+
// return logger;
|
|
55
|
+
// }
|
|
56
|
+
// };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Browser, BrowserContext, Page, Frame } from "playwright";
|
|
2
|
+
export declare const webFixture: {
|
|
3
|
+
pages: Map<string, Page>;
|
|
4
|
+
frames: Map<string, Frame>;
|
|
5
|
+
launchBrowser(): Promise<void>;
|
|
6
|
+
newContext(options?: Parameters<Browser["newContext"]>[0]): Promise<BrowserContext>;
|
|
7
|
+
newPage(name?: string): Promise<Page>;
|
|
8
|
+
getBrowser(): Browser;
|
|
9
|
+
getContext(): BrowserContext;
|
|
10
|
+
getCurrentPage(): Page | undefined;
|
|
11
|
+
setCurrentPage(name: string): void;
|
|
12
|
+
closeContext(): Promise<void>;
|
|
13
|
+
closeAll(): Promise<void>;
|
|
14
|
+
setWorld(world: any): void;
|
|
15
|
+
getWorld(): any;
|
|
16
|
+
setPlaywrightPage(page: Page): void;
|
|
17
|
+
getSmartIQData(): any[];
|
|
18
|
+
setSmartIQData(data: any[]): void;
|
|
19
|
+
};
|