@zeesoft/i18n-verify 3.3.7 → 3.3.9
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/executor.mjs +85 -47
- package/package.json +1 -1
package/dist/executor.mjs
CHANGED
|
@@ -302,7 +302,7 @@ const pathExists = (path2) => existsSync(path2);
|
|
|
302
302
|
const createFolder = (path2) => !pathExists(path2) && mkdirSync(path2, { recursive: true });
|
|
303
303
|
const ensureDirectoryExists = (path2, log2 = true) => {
|
|
304
304
|
if (!pathExists(path2) || !dirExists(path2)) {
|
|
305
|
-
log2 && Logger.debug(`Folder doesn't exists, creating \x1B[34m${path2}\x1B[0m`);
|
|
305
|
+
log2 && Logger$1.debug(`Folder doesn't exists, creating \x1B[34m${path2}\x1B[0m`);
|
|
306
306
|
createFolder(path2);
|
|
307
307
|
}
|
|
308
308
|
};
|
|
@@ -321,7 +321,7 @@ const addContentToFile = (path2, content, encoding = "utf-8") => {
|
|
|
321
321
|
flag: "a"
|
|
322
322
|
});
|
|
323
323
|
} catch (err) {
|
|
324
|
-
Logger.error(err);
|
|
324
|
+
Logger$1.error(err);
|
|
325
325
|
}
|
|
326
326
|
};
|
|
327
327
|
const getDirPath = (filePath) => dirname(filePath);
|
|
@@ -426,7 +426,7 @@ class BaseReport {
|
|
|
426
426
|
export(path2, name = DEFAULT_REPORT_NAME) {
|
|
427
427
|
this.write(path2, name, this.$generatedContent);
|
|
428
428
|
const runMode = Config.getMode();
|
|
429
|
-
Logger.info(
|
|
429
|
+
Logger$1.info(
|
|
430
430
|
`Exported consolidated ${runMode} Verification ${this.$type} report in ${path2}`
|
|
431
431
|
);
|
|
432
432
|
}
|
|
@@ -4188,7 +4188,7 @@ class TableReport extends BaseReport {
|
|
|
4188
4188
|
if (this.#hasData) {
|
|
4189
4189
|
this.#printer.printTable();
|
|
4190
4190
|
} else {
|
|
4191
|
-
Logger.info("There are no visible elements with UI strings");
|
|
4191
|
+
Logger$1.info("There are no visible elements with UI strings");
|
|
4192
4192
|
}
|
|
4193
4193
|
}
|
|
4194
4194
|
}
|
|
@@ -5070,21 +5070,21 @@ class Reports {
|
|
|
5070
5070
|
Reports.#generateReport(SUPPORTED_REPORT_TYPES.ASCII_TABLE);
|
|
5071
5071
|
}
|
|
5072
5072
|
}
|
|
5073
|
-
|
|
5073
|
+
let Logger$1 = class Logger2 {
|
|
5074
5074
|
static #isLogAppending = false;
|
|
5075
5075
|
static #appenderInterval;
|
|
5076
5076
|
static #appenderQueue = [];
|
|
5077
5077
|
static info(message) {
|
|
5078
|
-
|
|
5078
|
+
Logger2.#print("info", message);
|
|
5079
5079
|
}
|
|
5080
5080
|
static warn(message) {
|
|
5081
|
-
|
|
5081
|
+
Logger2.#print("warn", message);
|
|
5082
5082
|
}
|
|
5083
5083
|
static error(message, err) {
|
|
5084
|
-
|
|
5084
|
+
Logger2.#print("errr", message, err);
|
|
5085
5085
|
}
|
|
5086
5086
|
static debug(message) {
|
|
5087
|
-
|
|
5087
|
+
Logger2.#print("dbug", message);
|
|
5088
5088
|
}
|
|
5089
5089
|
static #print(type, message, additionalObj = "") {
|
|
5090
5090
|
if (type === "dbug" && !Config.isDebugMode()) {
|
|
@@ -5118,32 +5118,32 @@ class Logger {
|
|
|
5118
5118
|
console.log(logMessage);
|
|
5119
5119
|
}
|
|
5120
5120
|
logMessage = logMessage.replace(/\x1b\[\d+m/g, "");
|
|
5121
|
-
|
|
5121
|
+
Logger2.#customLog(`${logMessage}
|
|
5122
5122
|
`);
|
|
5123
5123
|
}
|
|
5124
5124
|
static #customLog = (message) => {
|
|
5125
|
-
if (
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
if (!
|
|
5129
|
-
clearInterval(
|
|
5130
|
-
message =
|
|
5131
|
-
|
|
5132
|
-
message &&
|
|
5125
|
+
if (Logger2.#isLogAppending) {
|
|
5126
|
+
Logger2.#appenderQueue.push(message);
|
|
5127
|
+
Logger2.#appenderInterval = setInterval(() => {
|
|
5128
|
+
if (!Logger2.#isLogAppending) {
|
|
5129
|
+
clearInterval(Logger2.#appenderInterval);
|
|
5130
|
+
message = Logger2.#appenderQueue.join("\n");
|
|
5131
|
+
Logger2.#appenderQueue = [];
|
|
5132
|
+
message && Logger2.#customLog(message);
|
|
5133
5133
|
}
|
|
5134
5134
|
}, 10);
|
|
5135
5135
|
} else {
|
|
5136
|
-
|
|
5136
|
+
Logger2.#isLogAppending = true;
|
|
5137
5137
|
const logsDir = joinPaths(Reports.getReportPath(), "logs");
|
|
5138
5138
|
if (logsDir) {
|
|
5139
5139
|
const logFilePath = joinPaths(logsDir, "log");
|
|
5140
5140
|
ensureDirectoryExists(logsDir, Config.isDebugMode());
|
|
5141
5141
|
fs.appendFileSync(logFilePath, message);
|
|
5142
5142
|
}
|
|
5143
|
-
|
|
5143
|
+
Logger2.#isLogAppending = false;
|
|
5144
5144
|
}
|
|
5145
5145
|
};
|
|
5146
|
-
}
|
|
5146
|
+
};
|
|
5147
5147
|
class NightWatchDriver extends BaseDriver {
|
|
5148
5148
|
constructor(driver) {
|
|
5149
5149
|
super(driver);
|
|
@@ -5229,7 +5229,13 @@ class NightWatchDriver extends BaseDriver {
|
|
|
5229
5229
|
return eleStr;
|
|
5230
5230
|
}
|
|
5231
5231
|
async captureScreenshot(file) {
|
|
5232
|
-
|
|
5232
|
+
const browserNameRaw = this.$driver.capabilities?.browserName;
|
|
5233
|
+
const browserNames = Array.isArray(browserNameRaw) ? browserNameRaw.map((b) => b?.toLowerCase?.()) : [browserNameRaw?.toLowerCase?.()];
|
|
5234
|
+
if (browserNames.includes("chrome") || browserNames.includes("chromium")) {
|
|
5235
|
+
await captureFullPage$1(this.$driver, file);
|
|
5236
|
+
} else {
|
|
5237
|
+
await captureScreenshotFallback$1(this.$driver, file);
|
|
5238
|
+
}
|
|
5233
5239
|
}
|
|
5234
5240
|
async getElementsCount(elements) {
|
|
5235
5241
|
return elements.length;
|
|
@@ -5297,9 +5303,22 @@ const captureFullPage$1 = async (driver, filePath) => {
|
|
|
5297
5303
|
});
|
|
5298
5304
|
const screenshotBuffer = Buffer.from(data2, "base64");
|
|
5299
5305
|
writeFileSync(filePath, screenshotBuffer);
|
|
5300
|
-
Logger.debug(`Screenshot saved as: ${filePath}`);
|
|
5306
|
+
Logger$1.debug(`Screenshot saved as: ${filePath}`);
|
|
5301
5307
|
await client.close();
|
|
5302
5308
|
};
|
|
5309
|
+
const captureScreenshotFallback$1 = async (driver, filePath) => {
|
|
5310
|
+
const screenshot = await new Promise((resolve2, reject) => {
|
|
5311
|
+
driver.screenshot(function(result) {
|
|
5312
|
+
if (result.status === 0) {
|
|
5313
|
+
resolve2(result.value);
|
|
5314
|
+
} else {
|
|
5315
|
+
reject(new Error("Screenshot capture failed"));
|
|
5316
|
+
}
|
|
5317
|
+
});
|
|
5318
|
+
});
|
|
5319
|
+
writeFileSync(filePath, Buffer.from(screenshot, "base64"));
|
|
5320
|
+
Logger$1.debug(`Screenshot saved as: ${filePath}`);
|
|
5321
|
+
};
|
|
5303
5322
|
const getRemoteDebuggerPort$1 = (driver) => {
|
|
5304
5323
|
const debuggerAddress = driver?.capabilities?.["goog:chromeOptions"]?.debuggerAddress;
|
|
5305
5324
|
if (debuggerAddress) {
|
|
@@ -5388,7 +5407,13 @@ class WebDriverIoDriver extends BaseDriver {
|
|
|
5388
5407
|
return eleStr;
|
|
5389
5408
|
}
|
|
5390
5409
|
async captureScreenshot(file) {
|
|
5391
|
-
|
|
5410
|
+
const browserNameRaw = this.$driver.capabilities?.browserName;
|
|
5411
|
+
const browserNames = Array.isArray(browserNameRaw) ? browserNameRaw.map((b) => b?.toLowerCase?.()) : [browserNameRaw?.toLowerCase?.()];
|
|
5412
|
+
if (browserNames.includes("chrome") || browserNames.includes("chromium")) {
|
|
5413
|
+
await captureFullPage(this.$driver, file);
|
|
5414
|
+
} else {
|
|
5415
|
+
await captureScreenshotFallback(this.$driver, file);
|
|
5416
|
+
}
|
|
5392
5417
|
}
|
|
5393
5418
|
async getElementsCount(elements) {
|
|
5394
5419
|
return elements.length;
|
|
@@ -5442,6 +5467,11 @@ const captureFullPage = async (driver, filePath) => {
|
|
|
5442
5467
|
fs.writeFileSync(filePath, Buffer.from(data2, "base64"));
|
|
5443
5468
|
await client.close();
|
|
5444
5469
|
};
|
|
5470
|
+
const captureScreenshotFallback = async (driver, filePath) => {
|
|
5471
|
+
const screenshot = await driver.takeScreenshot();
|
|
5472
|
+
fs.writeFileSync(filePath, Buffer.from(screenshot, "base64"));
|
|
5473
|
+
Logger.debug(`Screenshot saved as: ${filePath}`);
|
|
5474
|
+
};
|
|
5445
5475
|
const getRemoteDebuggerPort = (driver) => {
|
|
5446
5476
|
const debuggerAddress = driver.capabilities?.["goog:chromeOptions"]?.debuggerAddress;
|
|
5447
5477
|
return debuggerAddress ? debuggerAddress.split(":")[1] || 9229 : 9229;
|
|
@@ -5645,7 +5675,7 @@ class CypressDriver extends BaseDriver {
|
|
|
5645
5675
|
}
|
|
5646
5676
|
}
|
|
5647
5677
|
async captureScreenshot(file) {
|
|
5648
|
-
this.$driver.screenshot(file);
|
|
5678
|
+
await this.$driver.screenshot(file);
|
|
5649
5679
|
}
|
|
5650
5680
|
async getElementsCount(el) {
|
|
5651
5681
|
return new Promise((res) => {
|
|
@@ -5671,7 +5701,7 @@ class CypressDriver extends BaseDriver {
|
|
|
5671
5701
|
}
|
|
5672
5702
|
});
|
|
5673
5703
|
} catch (textError) {
|
|
5674
|
-
Logger.error("Error getting text of element:", textError);
|
|
5704
|
+
Logger$1.error("Error getting text of element:", textError);
|
|
5675
5705
|
}
|
|
5676
5706
|
return elementStrings;
|
|
5677
5707
|
}
|
|
@@ -5747,6 +5777,11 @@ class SeleniumDriver extends BaseDriver {
|
|
|
5747
5777
|
async getElementsCount(elements) {
|
|
5748
5778
|
return elements.length;
|
|
5749
5779
|
}
|
|
5780
|
+
async captureScreenshot(file) {
|
|
5781
|
+
const fs2 = require("fs");
|
|
5782
|
+
const screenshot = await this.$driver.takeScreenshot();
|
|
5783
|
+
fs2.writeFileSync(file, screenshot, "base64");
|
|
5784
|
+
}
|
|
5750
5785
|
}
|
|
5751
5786
|
const build$1 = (type, driver) => {
|
|
5752
5787
|
switch (type) {
|
|
@@ -6032,7 +6067,7 @@ const toLuxonLocale = (locale) => {
|
|
|
6032
6067
|
locale = locale.replace("_", "-");
|
|
6033
6068
|
return Intl.DateTimeFormat.supportedLocalesOf(locale)[0];
|
|
6034
6069
|
} catch (ex) {
|
|
6035
|
-
Logger.warn(`${locale} is unsupported by Intl`);
|
|
6070
|
+
Logger$1.warn(`${locale} is unsupported by Intl`);
|
|
6036
6071
|
return false;
|
|
6037
6072
|
}
|
|
6038
6073
|
};
|
|
@@ -6650,10 +6685,13 @@ class Resource {
|
|
|
6650
6685
|
static load() {
|
|
6651
6686
|
const bundle = {};
|
|
6652
6687
|
if (Config.getOptions()?.l10nResourcePath) {
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6688
|
+
let resourcePath = Config.getOptions().l10nResourcePath;
|
|
6689
|
+
if (resolve(resourcePath) === resourcePath) {
|
|
6690
|
+
resourcePath = joinPaths(
|
|
6691
|
+
Config.getOptions()?.isSelfManagedRun ? "" : process.cwd(),
|
|
6692
|
+
resourcePath
|
|
6693
|
+
);
|
|
6694
|
+
}
|
|
6657
6695
|
if (fileExists(resourcePath)) {
|
|
6658
6696
|
Resource.#processFile(resourcePath, bundle);
|
|
6659
6697
|
} else if (dirExists(resourcePath)) {
|
|
@@ -6829,7 +6867,7 @@ class Config {
|
|
|
6829
6867
|
Config.#isDebugMode = config?.debug ?? false;
|
|
6830
6868
|
Config.getGarbledChars();
|
|
6831
6869
|
} catch (ex) {
|
|
6832
|
-
Logger.error(ex.message);
|
|
6870
|
+
Logger$1.error(ex.message);
|
|
6833
6871
|
throw ex;
|
|
6834
6872
|
}
|
|
6835
6873
|
}
|
|
@@ -6985,7 +7023,7 @@ class BaseRunner {
|
|
|
6985
7023
|
await this.#executePageProcess();
|
|
6986
7024
|
}
|
|
6987
7025
|
} catch (ex) {
|
|
6988
|
-
Logger.error("unable to run the process", ex);
|
|
7026
|
+
Logger$1.error("unable to run the process", ex);
|
|
6989
7027
|
} finally {
|
|
6990
7028
|
await this.#postRun();
|
|
6991
7029
|
}
|
|
@@ -7008,10 +7046,10 @@ class BaseRunner {
|
|
|
7008
7046
|
async captureScreen(imagePath) {
|
|
7009
7047
|
try {
|
|
7010
7048
|
await this.#driver.captureScreenshot(imagePath);
|
|
7011
|
-
Logger.debug("reviewed image has been saved");
|
|
7049
|
+
Logger$1.debug("reviewed image has been saved");
|
|
7012
7050
|
return true;
|
|
7013
7051
|
} catch (ex) {
|
|
7014
|
-
Logger.error("unable to capture screenshot");
|
|
7052
|
+
Logger$1.error("unable to capture screenshot");
|
|
7015
7053
|
return false;
|
|
7016
7054
|
}
|
|
7017
7055
|
}
|
|
@@ -7048,7 +7086,7 @@ class BaseRunner {
|
|
|
7048
7086
|
await this.#processLocatorElements();
|
|
7049
7087
|
await this.#processIFrames();
|
|
7050
7088
|
} else {
|
|
7051
|
-
Logger.debug("No locators provided");
|
|
7089
|
+
Logger$1.debug("No locators provided");
|
|
7052
7090
|
}
|
|
7053
7091
|
}
|
|
7054
7092
|
async #executePageProcess() {
|
|
@@ -7107,19 +7145,19 @@ class BaseRunner {
|
|
|
7107
7145
|
}
|
|
7108
7146
|
}
|
|
7109
7147
|
if (!hasElements) {
|
|
7110
|
-
Logger.debug("No UI elements found from the provided locators");
|
|
7148
|
+
Logger$1.debug("No UI elements found from the provided locators");
|
|
7111
7149
|
}
|
|
7112
7150
|
}
|
|
7113
7151
|
async #processIFrames() {
|
|
7114
7152
|
if (await this.#driver.checkIfIframeIsPresent()) {
|
|
7115
7153
|
const frames = await this.#driver.getElements("//iframe");
|
|
7116
|
-
Logger.debug(
|
|
7154
|
+
Logger$1.debug(
|
|
7117
7155
|
`Total ${frames.length} iframes are located on the ${this.#description}`
|
|
7118
7156
|
);
|
|
7119
7157
|
for (let fID = 0; fID < frames.length; fID++) {
|
|
7120
7158
|
const frame = frames[fID];
|
|
7121
7159
|
const offsets = await this.getElementOffsets(frame);
|
|
7122
|
-
Logger.debug(`Switching to iFrame: ${fID}`);
|
|
7160
|
+
Logger$1.debug(`Switching to iFrame: ${fID}`);
|
|
7123
7161
|
await this.#driver.switchToIFrame(fID, frame);
|
|
7124
7162
|
this.#driver.pause(1);
|
|
7125
7163
|
const iframeBody = await this.#driver.getElement("//body");
|
|
@@ -7137,7 +7175,7 @@ class BaseRunner {
|
|
|
7137
7175
|
}
|
|
7138
7176
|
}
|
|
7139
7177
|
}
|
|
7140
|
-
!hasAtLeastOneString && Logger.debug("No valid UI elements found in the iFrame");
|
|
7178
|
+
!hasAtLeastOneString && Logger$1.debug("No valid UI elements found in the iFrame");
|
|
7141
7179
|
await this.#driver.switchToParentFrame();
|
|
7142
7180
|
}
|
|
7143
7181
|
}
|
|
@@ -7150,7 +7188,7 @@ class BaseRunner {
|
|
|
7150
7188
|
try {
|
|
7151
7189
|
await this.process(string, element, offsets, frameId);
|
|
7152
7190
|
} catch (ex) {
|
|
7153
|
-
Logger.error(
|
|
7191
|
+
Logger$1.error(
|
|
7154
7192
|
`unable to process the ${frameId ? `iframe-[${frameId}] ` : ""}string "${string}"`,
|
|
7155
7193
|
ex
|
|
7156
7194
|
);
|
|
@@ -7203,7 +7241,7 @@ class ContextRunner extends BaseRunner {
|
|
|
7203
7241
|
this.getBaseImageName(),
|
|
7204
7242
|
this.getDescription()
|
|
7205
7243
|
);
|
|
7206
|
-
Logger.debug(`context creation for "${string}"`);
|
|
7244
|
+
Logger$1.debug(`context creation for "${string}"`);
|
|
7207
7245
|
await this.#addToContext(string, element, offsets);
|
|
7208
7246
|
}
|
|
7209
7247
|
/**
|
|
@@ -7294,12 +7332,12 @@ class Graphic {
|
|
|
7294
7332
|
const targetDir = path.dirname(report_img);
|
|
7295
7333
|
const buffer = await image.getBufferAsync(Jimp.MIME_PNG);
|
|
7296
7334
|
if (!fs.existsSync(targetDir)) {
|
|
7297
|
-
Logger.debug("folder not found");
|
|
7335
|
+
Logger$1.debug("folder not found");
|
|
7298
7336
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
7299
7337
|
}
|
|
7300
7338
|
fs.writeFileSync(report_img, buffer);
|
|
7301
7339
|
} catch (err) {
|
|
7302
|
-
Logger.error(`Error: ${err}`);
|
|
7340
|
+
Logger$1.error(`Error: ${err}`);
|
|
7303
7341
|
}
|
|
7304
7342
|
}
|
|
7305
7343
|
static async drawRectangleOutline(image, x, y, width, height, color, thickness) {
|
|
@@ -7381,7 +7419,7 @@ class I18nRunner extends BaseRunner {
|
|
|
7381
7419
|
await Graphic.drawRectangle(elRec, color, image);
|
|
7382
7420
|
}
|
|
7383
7421
|
#defineColor(status, string) {
|
|
7384
|
-
Logger.debug(
|
|
7422
|
+
Logger$1.debug(
|
|
7385
7423
|
`"${string}" - ${STATUS_COLOR[status][1]}${STATUS_INFO[status]}${"\x1B[0m"}`
|
|
7386
7424
|
);
|
|
7387
7425
|
return STATUS_COLOR[status][0];
|
|
@@ -7402,7 +7440,7 @@ class SanityRunner extends BaseRunner {
|
|
|
7402
7440
|
* @override
|
|
7403
7441
|
*/
|
|
7404
7442
|
async process(page) {
|
|
7405
|
-
Logger.info(`${page} loaded`);
|
|
7443
|
+
Logger$1.info(`${page} loaded`);
|
|
7406
7444
|
const src_img = joinPaths(
|
|
7407
7445
|
Reports.reviewedReports(page, this.getBaseImageName()),
|
|
7408
7446
|
this.getBaseImageName()
|
|
@@ -7486,7 +7524,7 @@ class Executor {
|
|
|
7486
7524
|
export {
|
|
7487
7525
|
Config as C,
|
|
7488
7526
|
Executor as E,
|
|
7489
|
-
Logger as L,
|
|
7527
|
+
Logger$1 as L,
|
|
7490
7528
|
Reports as R,
|
|
7491
7529
|
SYSTEM_TYPES as S,
|
|
7492
7530
|
getRootProjectMainDir as a,
|
package/package.json
CHANGED