libreoffice-online/cypress_test/plugins/tasks.js
Ashod Nakashian de74eae245 cypress: give each test a unique test document
We copy each test document into the work-dir
and now we also give them a random prefix.
This is critical to ensure that parallel runs
do not re-use the same document.

Also, when closing a document, we wait for the
document-name to disappear from the admin
console. Sharing the same document, or even the
name, means we are likely to see random results.

Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit d998f2c1c8a163c3ef870bbe8581a364df3905bb)

Change-Id: I2f41566952c49c9c63ee206bcba6a4dd49cdd6d0
2022-01-11 09:28:03 +01:00

39 lines
946 B
JavaScript

/* global require Promise */
var fs = require('fs');
var list = require('./selectorList').list;
function copyFile(args) {
return new Promise(function(resolve) {
var sourceFile = args.sourceDir + args.fileName;
var destFileName;
if (args.destFileName) {
destFileName = args.destFileName;
} else {
destFileName = args.fileName;
}
var destFile = args.destDir + destFileName;
if (fs.existsSync(sourceFile)) {
fs.mkdirSync(args.destDir, { recursive: true });
if (fs.existsSync(destFile)) {
fs.unlinkSync(destFile);
}
fs.writeFileSync(destFile, fs.readFileSync(sourceFile));
resolve('File ${sourceFile} copied to ${destFile}');
}
resolve('File ${sourceFile} does not exist');
});
}
function getSelectors(args) {
if (args.mode === 'notebookbar') {
return list[args.name][0];
} else {
return list[args.name][1];
}
}
module.exports.copyFile = copyFile;
module.exports.getSelectors = getSelectors;