Skip to content

Commit

Permalink
Merge pull request #671 from ONLYOFFICE/feature/update-translation-tests
Browse files Browse the repository at this point in the history
Feature/update translation tests
  • Loading branch information
AlexeySafronov authored May 20, 2022
2 parents b0dd87a + dbeed86 commit 182b482
Show file tree
Hide file tree
Showing 220 changed files with 1,048 additions and 229 deletions.
4 changes: 0 additions & 4 deletions build/run.e2e.translations.tests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,10 @@ powershell -Command "(gc build\deploy\nginx\onlyoffice.conf) -replace '#', '' |
xcopy config\nginx\sites-enabled\* build\deploy\nginx\sites-enabled\ /E /R /Y

REM fix paths
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-calendar.conf) -replace 'ROOTPATH', '%~dp0deploy\products\ASC.Calendar\client' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-calendar.conf"
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-crm.conf) -replace 'ROOTPATH', '%~dp0deploy\products\ASC.CRM\client' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-crm.conf"
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-editor.conf) -replace 'ROOTPATH', '%~dp0deploy\products\ASC.Files\editor' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-editor.conf"
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-files.conf) -replace 'ROOTPATH', '%~dp0deploy\products\ASC.Files\client' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-files.conf"
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-login.conf) -replace 'ROOTPATH', '%~dp0deploy\studio\login' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-login.conf"
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-mail.conf) -replace 'ROOTPATH', '%~dp0deploy\products\ASC.Mail\client' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-mail.conf"
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-people.conf) -replace 'ROOTPATH', '%~dp0deploy\products\ASC.People\client' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-people.conf"
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-projects.conf) -replace 'ROOTPATH', '%~dp0deploy\products\ASC.Projects\client' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-projects.conf"
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-studio.conf) -replace 'ROOTPATH', '%~dp0deploy\studio\client' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-studio.conf"

REM restart nginx
Expand Down
67 changes: 67 additions & 0 deletions build/run.e2e.translations.tests.personal.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
@echo off

PUSHD %~dp0
call runasadmin.bat "%~dpnx0"

if %errorlevel% == 0 (
PUSHD %~dp0..


echo "mode="


REM call yarn wipe
call yarn install

call yarn build:test.translation:personal

REM call yarn wipe
call yarn deploy:personal



REM copy nginx configurations to deploy folder
xcopy config\nginx\onlyoffice.conf build\deploy\nginx\ /E /R /Y
powershell -Command "(gc build\deploy\nginx\onlyoffice.conf) -replace '#', '' | Out-File -encoding ASCII build\deploy\nginx\onlyoffice.conf"

xcopy config\nginx\sites-enabled\* build\deploy\nginx\sites-enabled\ /E /R /Y

REM fix paths
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-editor.conf) -replace 'ROOTPATH', '%~dp0deploy\products\ASC.Files\editor' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-editor.conf"
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-files.conf) -replace 'ROOTPATH', '%~dp0deploy\products\ASC.Files\client' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-files.conf"
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-login.conf) -replace 'ROOTPATH', '%~dp0deploy\studio\login' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-login.conf"
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-people.conf) -replace 'ROOTPATH', '%~dp0deploy\products\ASC.People\client' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-people.conf"
powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-studio.conf) -replace 'ROOTPATH', '%~dp0deploy\studio\client' -replace '\\', '/' | Out-File -encoding ASCII build\deploy\nginx\sites-enabled\onlyoffice-studio.conf"

REM restart nginx
echo service nginx stop
call sc stop nginx > nul

REM sleep 5 seconds
call ping 127.0.0.1 -n 6 > nul

echo service nginx start
call sc start nginx > nul

REM sleep 5 seconds
call ping 127.0.0.1 -n 6 > nul

call yarn e2e.test:translation:personal

exit



if NOT %errorlevel% == 0 (
echo Couldn't restarte Onlyoffice%%~nf service
)

)

echo.

POPD

if "%1"=="nopause" goto start
pause
:start
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"build:personal": "lerna run build:personal --parallel --scope {@appserver/studio,@appserver/people,@appserver/files,@appserver/editor}",
"build:test": "lerna run build:test --parallel --ignore @appserver/common --ignore @appserver/components --ignore @appserver/browserslist-config-asc --ignore @appserver/debug-info",
"build:test.translation": "lerna run build:test.translation --parallel --ignore @appserver/common --ignore @appserver/components --ignore @appserver/browserslist-config-asc --ignore @appserver/debug-info",
"build:test.translation:personal": "lerna run build:test.translation:personal --parallel --ignore @appserver/common --ignore @appserver/components --ignore @appserver/browserslist-config-asc --ignore @appserver/debug-info",
"bump": "lerna version --no-push --no-git-tag-version",
"clean": "lerna run clean --parallel",
"deploy": "shx rm -rf build/deploy/products && shx rm -rf build/deploy/public && shx rm -rf build/deploy/studio && lerna run deploy --parallel --ignore @appserver/common --ignore @appserver/components --ignore @appserver/browserslist-config-asc && shx cp -r public build/deploy",
Expand Down Expand Up @@ -44,7 +45,8 @@
"e2e.test": "lerna run test:sequential --parallel --scope {@appserver/people,@appserver/files,@appserver/login}",
"e2e.test:sequential": "yarn workspace @appserver/people test:sequential && yarn workspace @appserver/files test:sequential && yarn workspace @appserver/login test:sequential",
"e2e.test:model": "yarn workspace @appserver/people test:model && yarn workspace @appserver/files test:model && yarn workspace @appserver/login test:model",
"e2e.test:translation": "lerna run test:translation --parallel --scope {@appserver/people,@appserver/files}"
"e2e.test:translation": "lerna run test:translation:model --parallel --scope {@appserver/people,@appserver/files} && lerna run test:translation --parallel --scope {@appserver/people,@appserver/files}",
"e2e.test:translation:personal": "lerna run test:translation:model:personal --parallel --scope {@appserver/people,@appserver/files} && lerna run test:translation:personal --parallel --scope {@appserver/people,@appserver/files}"
},
"devDependencies": {
"auto-changelog": "https://github.com/ONLYOFFICE/auto-changelog.git#master",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ const StyledTableHeaderCell = styled.div`
color: ${(props) =>
props.isActive
? props.theme.tableContainer.header.activeTextColor
: props.theme.tableContainer.header.textColor} !important;
: props.theme.tableContainer.header.textColor};
&:hover {
color: ${(props) =>
Expand Down
1 change: 1 addition & 0 deletions products/ASC.Files/Client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/coverage
/tests/output
/tests/reports
/tests/screenshots/translation

# production
/build
Expand Down
12 changes: 9 additions & 3 deletions products/ASC.Files/Client/codecept.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ const isModel = !!process.env.MODEL;

const screenshotOutput = isTranslation
? isModel
? `./tests/screenshots/translation/${browser}/${deviceType}`
: `./tests/output/translation/${browser}/${deviceType}`
? `./tests/screenshots/translation/`
: `./tests/output/translation/`
: isModel
? `./tests/screenshots/${browser}/${deviceType}`
: `./tests/output/${browser}/${deviceType}`;

const baseFolder = isTranslation
? `./tests/screenshots/translation/${browser}/${deviceType}`
? `./tests/screenshots/translation`
: `./tests/screenshots/${browser}/${deviceType}`;

const tests = isTranslation
Expand Down Expand Up @@ -63,6 +63,12 @@ if (isTranslation) {
fs.mkdir(diffFolder, { recursive: true }, (err) => {
if (err) throw err;
});

if (isModel) {
fs.rmdir(screenshotOutput, { recursive: true }, (err) => {
if (err) throw err;
});
}
}

exports.config = {
Expand Down
7 changes: 5 additions & 2 deletions products/ASC.Files/Client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"build:personal": "webpack --mode production --env personal=true",
"build:test": "webpack --env minimize=false --mode production",
"build:test.translation": "webpack --env minimize=false hideText=true --mode production",
"build:test.translation:personal": "webpack --env minimize=false hideText=true personal=true --mode production",
"clean": "shx rm -rf dist",
"deploy": "shx --silent mkdir -p ../../../build/deploy/products/ASC.Files/client && shx cp -r dist/* ../../../build/deploy/products/ASC.Files/client",
"serve": "serve dist -p 5008",
Expand All @@ -19,12 +20,14 @@
"test:smallTablet": "cross-env DEVICE_TYPE=smallTablet yarn test:codeceptjs",
"test:tablet": "cross-env DEVICE_TYPE=tablet yarn test:codeceptjs",
"test:desktop": "cross-env DEVICE_TYPE=desktop yarn test:codeceptjs ",
"test:translation": "cross-env DEVICE_TYPE=desktop translation=true yarn test:codeceptjs --profile chromium",
"test:translation": "cross-env DEVICE_TYPE=desktop translation=true yarn test:codeceptjs --profile chromium ",
"test:translation:personal": "cross-env DEVICE_TYPE=desktop translation=true personal=true yarn test:codeceptjs --profile chromium ",
"test:mobile:model": "cross-env DEVICE_TYPE=mobile MODEL=true yarn test:codeceptjs",
"test:smallTablet:model": "cross-env DEVICE_TYPE=smallTablet MODEL=true yarn test:codeceptjs",
"test:tablet:model": "cross-env DEVICE_TYPE=tablet MODEL=true yarn test:codeceptjs",
"test:desktop:model": "cross-env DEVICE_TYPE=desktop MODEL=true yarn test:codeceptjs",
"test:translation:model": "cross-env DEVICE_TYPE=desktop MODEL=true TRANSLATION=true yarn test:codeceptjs --profile chromium",
"test:translation:model": "cross-env DEVICE_TYPE=desktop MODEL=true translation=true yarn test:codeceptjs --profile chromium && node tests/helpers/cloneModelScreenshot.js",
"test:translation:model:personal": "cross-env DEVICE_TYPE=desktop MODEL=true translation=true personal=true yarn test:codeceptjs --profile chromium && node tests/helpers/cloneModelScreenshot.js",
"test:chromium:parallel": "run-p -c \"test:mobile --profile chromium \" \"test:smallTablet --profile chromium \" \"test:tablet --profile chromium \" \"test:desktop --profile chromium \" && yarn test:parse-xml",
"test:chromium:sequential": "run-s -c \"test:mobile --profile chromium \" \"test:smallTablet --profile chromium \" \"test:tablet --profile chromium \" \"test:desktop --profile chromium \" && yarn test:parse-xml",
"test:chromium:model": "run-s -c \"test:mobile:model --profile chromium \" \"test:smallTablet:model --profile chromium \" \"test:tablet:model --profile chromium \" \"test:desktop:model --profile chromium \" && yarn test:parse-xml",
Expand Down
1 change: 1 addition & 0 deletions products/ASC.Files/Client/steps_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = function () {
this.mockEndpoint(Endpoints.capabilities, "capabilities");
this.mockEndpoint(Endpoints.thirdparty, "thirdparty");
this.mockEndpoint(Endpoints.thumbnails, "thumbnails");
this.mockEndpoint(Endpoints.getFolder(1), "1");
},

selectAuthor: function () {
Expand Down
37 changes: 26 additions & 11 deletions products/ASC.Files/Client/tests/helpers/changeCulture.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,49 @@
const fs = require('fs');
const path = require('path');
const fs = require("fs");
const path = require("path");

const settingsFile = require(path.resolve(
__dirname,
'../mocking/mock-data/settings/settingsTranslation.json',
"../mocking/mock-data/settings/settingsTranslation.json"
));

const settingsFilePersonal = require(path.resolve(
__dirname,
"../mocking/mock-data/settings/settingsTranslationPersonal.json"
));

const selfFile = require(path.resolve(
__dirname,
'../mocking/mock-data/people/selfTranslation.json',
"../mocking/mock-data/people/selfTranslation.json"
));

function changeCulture(culture) {
settingsFile.response.culture = culture;
function changeCulture(culture, isPersonal) {
if (isPersonal) {
settingsFilePersonal.response.culture = culture;
} else {
settingsFile.response.culture = culture;
}
selfFile.response.cultureName = culture;

fs.writeFile(
path.resolve(__dirname, '../mocking/mock-data/settings/settingsTranslation.json'),
JSON.stringify(settingsFile, null, 2),
path.resolve(
__dirname,
`../mocking/mock-data/settings/settingsTranslation${
isPersonal ? "Personal" : ""
}.json`
),

JSON.stringify(isPersonal ? settingsFilePersonal : settingsFile, null, 2),
function writeJSON(err) {
if (err) return console.log(err);
},
}
);

fs.writeFile(
path.resolve(__dirname, '../mocking/mock-data/people/selfTranslation.json'),
path.resolve(__dirname, "../mocking/mock-data/people/selfTranslation.json"),
JSON.stringify(selfFile, null, 2),
function writeJSON(err) {
if (err) return console.log(err);
},
}
);
}

Expand Down
80 changes: 80 additions & 0 deletions products/ASC.Files/Client/tests/helpers/cloneModelScreenshot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
var path = require("path");
var fs = require("fs");
var async = require("async");

const config = require("../../../../../config/appsettings.json");
const cultures = config.web.cultures.split(",");

function getFiles(dirPath, callback) {
fs.readdir(dirPath, function (err, files) {
if (err) return callback(err);

var filePaths = [];
async.eachSeries(
files,
function (fileName, eachCallback) {
var filePath = path.join(dirPath, fileName);

fs.stat(filePath, function (err, stat) {
if (err) return eachCallback(err);

if (stat.isDirectory()) {
getFiles(filePath, function (err, subDirFiles) {
if (err) return eachCallback(err);

filePaths = filePaths.concat(subDirFiles);
eachCallback(null);
});
} else {
if (stat.isFile() && /\.png$/.test(filePath)) {
filePaths.push(filePath);
}

eachCallback(null);
}
});
},
function (err) {
callback(err, filePaths);
}
);
});
}

function getClonePath(filePath, culture) {
const splitFilePath = filePath.split("\\");

const splitFileName = splitFilePath[splitFilePath.length - 1].split("-");

splitFileName[0] = culture;

splitFilePath[splitFilePath.length - 1] = splitFileName.join("-");

const copyPath = splitFilePath.join("\\");

return copyPath;
}

function copyFile(filePath) {
cultures.forEach((culture) => {
const copyPath = getClonePath(filePath, culture);

fs.copyFile(filePath, copyPath, (err) => {
if (err) console.log(err);
});
});
}

const pathToModels = path.resolve(__dirname, "../screenshots/translation");

function cloneModelScreenshot() {
getFiles(pathToModels, function (err, files) {
if (err) console.log(err);

files.forEach((file) => {
copyFile(file);
});
});
}

cloneModelScreenshot();
6 changes: 5 additions & 1 deletion products/ASC.Files/Client/tests/ignoringCultures.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"mainPage": ["en"],
"profileMenu": ["en"],
"mainButton": ["en"],
"tableSettings": ["en"]
"tableSettings": ["en"],
"addButton": ["en"],
"sortMenu": ["en"],
"filterBlock": ["en"],
"contextMenu": ["en"]
}
Loading

0 comments on commit 182b482

Please sign in to comment.