Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent committed Oct 6, 2023
2 parents 65650e6 + e417dd7 commit 44cc429
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/helpers/FileSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ I.waitForFile('largeFilesName.txt', 10); // wait 10 seconds for file

### writeToFile

Writes test to file
Writes text to file

#### Parameters

Expand Down
24 changes: 24 additions & 0 deletions lib/command/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,27 @@ module.exports = async function (path) {
output.print('Please copy environment info when you report issues on GitHub: https://github.com/Codeception/CodeceptJS/issues');
output.print('***************************************');
};

module.exports.getMachineInfo = async () => {
const info = {
nodeInfo: await envinfo.helpers.getNodeInfo(),
osInfo: await envinfo.helpers.getOSInfo(),
cpuInfo: await envinfo.helpers.getCPUInfo(),
chromeInfo: await envinfo.helpers.getChromeInfo(),
edgeInfo: await envinfo.helpers.getEdgeInfo(),
firefoxInfo: await envinfo.helpers.getFirefoxInfo(),
safariInfo: await envinfo.helpers.getSafariInfo(),
};

output.print('***************************************');
for (const [key, value] of Object.entries(info)) {
if (Array.isArray(value)) {
output.print(`${key}: ${value[1]}`);
} else {
output.print(`${key}: ${JSON.stringify(value, null, ' ')}`);
}
}
output.print('If you need more detailed info, just run this: npx codeceptjs info');
output.print('***************************************');
return info;
};
4 changes: 2 additions & 2 deletions lib/command/run-workers.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ module.exports = async function (workerCount, selectedRuns, options) {
try {
if (options.verbose) {
global.debugMode = true;
const getInfo = require('./info');
await getInfo();
const { getMachineInfo } = require('./info');
await getMachineInfo();
}
await workers.bootstrapAll();
await workers.run();
Expand Down
4 changes: 2 additions & 2 deletions lib/command/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ module.exports = async function (test, options) {

if (options.verbose) {
global.debugMode = true;
const getInfo = require('./info');
await getInfo();
const { getMachineInfo } = require('./info');
await getMachineInfo();
}

await codecept.run();
Expand Down
20 changes: 14 additions & 6 deletions lib/data/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = function (context) {
.inject({ current: dataRow.data }));
}
});
maskSecretInTitle(scenarios);
return new DataScenarioConfig(scenarios);
},
only: {
Expand All @@ -42,6 +43,7 @@ module.exports = function (context) {
.inject({ current: dataRow.data }));
}
});
maskSecretInTitle(scenarios);
return new DataScenarioConfig(scenarios);
},
},
Expand Down Expand Up @@ -71,12 +73,6 @@ function replaceTitle(title, dataRow) {
// it should be printed
if (Object.prototype.toString.call(dataRow.data) === (Object()).toString()
&& dataRow.data.toString() !== (Object()).toString()) {
Object.entries(dataRow.data).forEach(entry => {
const [key, value] = entry;
if (value instanceof Secret) {
dataRow.data[key] = value.getMasked();
}
});
return `${title} | ${dataRow.data}`;
}

Expand Down Expand Up @@ -119,3 +115,15 @@ function detectDataType(dataTable) {

throw new Error('Invalid data type. Data accepts either: DataTable || generator || Array || function');
}

function maskSecretInTitle(scenarios) {
scenarios.forEach(scenario => {
const res = [];

scenario.test.title.split(',').forEach(item => {
res.push(item.replace(/{"_secret":"(.*)"}/, '"*****"'));
});

scenario.test.title = res.join(',');
});
}
2 changes: 1 addition & 1 deletion lib/helper/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FileSystem extends Helper {
}

/**
* Writes test to file
* Writes text to file
* @param {string} name
* @param {string} text
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -3259,7 +3259,7 @@ async function findElement(matcher, locator) {
if (locator.react) return findReact(matcher, locator);
locator = new Locator(locator, 'css');

return matcher.locator(buildLocatorString(locator));
return matcher.locator(buildLocatorString(locator)).first();
}

async function getVisibleElements(elements) {
Expand Down
2 changes: 1 addition & 1 deletion lib/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const savedSessions = {};
* @param {CodeceptJS.LocatorOrString} sessionName
* @param {Function | Object<string, *>} config
* @param {Function} [fn]
* @return {Promise<*> | undefined}
* @return {any}
*/
function session(sessionName, config, fn) {
if (typeof config === 'function') {
Expand Down
3 changes: 1 addition & 2 deletions test/runner/interface_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ describe('CodeceptJS Interface', () => {
it('should not propagate retries to non retried steps', (done) => {
exec(`${config_run_config('codecept.retry.json')} --grep @test2 --verbose`, (err, stdout) => {
expect(stdout).toContain('Retry'); // feature
expect(stdout).toContain('Retries: 5'); // test name
expect(err).toBeFalsy();
expect(stdout).toContain('Retries: 1'); // test name
done();
});
});
Expand Down
8 changes: 8 additions & 0 deletions test/unit/helper/FileSystem_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,12 @@ describe('FileSystem', () => {
for FileSystem helper
test`);
});

it('should write text to file', () => {
const outputFilePath = 'data/output/fs_output.txt';
const text = '123';
fs.writeToFile(outputFilePath, text);
fs.seeFile(outputFilePath);
fs.seeInThisFile(text);
});
});
14 changes: 13 additions & 1 deletion translations/fr-FR.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ module.exports = {
amOutsideAngularApp: 'suisALExtérieurDeLApplicationAngular',
amInsideAngularApp: 'suisALIntérieurDeLApplicationAngular',
waitForElement: 'attendsLElément',
waitForClickable: 'attends',
waitForClickable: 'attendsDeCliquer',
waitForVisible: 'attendsPourVoir',
waitForEnabled: 'attendsLActivationDe',
waitForInvisible: 'attendsLInvisibilitéDe',
waitInUrl: 'attendsDansLUrl',
waitForText: 'attendsLeTexte',
moveTo: 'vaisSur',
refresh: 'rafraîchis',
refreshPage: 'rafraîchisLaPage',
haveModule: 'ajouteLeModule',
resetModule: 'réinitialiseLeModule',
amOnPage: 'suisSurLaPage',
Expand Down Expand Up @@ -59,5 +63,13 @@ module.exports = {
grabCookie: 'prendsLeCookie',
resizeWindow: 'redimensionneLaFenêtre',
wait: 'attends',
clearField: 'effaceLeChamp',
dontSeeElementInDOM: 'neVoisPasDansLeDOM',
moveCursorTo: 'bougeLeCurseurSur',
scrollTo: 'défileVers',
sendGetRequest: 'envoieLaRequêteGet',
sendPutRequest: 'envoieLaRequêtePut',
sendDeleteRequest: 'envoieLaRequêteDelete',
sendPostRequest: 'envoieLaRequêtePost',
},
};

0 comments on commit 44cc429

Please sign in to comment.