Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve visual tests setup, update screenshots #244

Merged
merged 4 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified screenshots/lumo/chrome/baseline/grid-pro/edit-column-select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/lumo/chrome/baseline/rich-text-editor/max-height.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 30 additions & 3 deletions wtr-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,30 @@ const getAllPackages = () => {
.filter((dir) => fs.statSync(`packages/${dir}`).isDirectory() && fs.existsSync(`packages/${dir}/test`));
};

/**
* Get all available packages with visual tests.
*/
const getAllVisualPackages = () => {
return fs
.readdirSync('packages')
.filter((dir) => fs.statSync(`packages/${dir}`).isDirectory() && fs.existsSync(`packages/${dir}/test/visual`));
};

/**
* Gel all packages with updated reference screenshots.
*/
const getUpdatedScreenshotsPackages = () => {
const packages = new Set();
const log = execSync('git diff --name-only origin/master HEAD').toString();
log.split('\n').forEach((line) => {
if (line.startsWith('screenshots')) {
const data = line.split('/');
packages.add(`vaadin-${data[data.length - 2]}`);
}
});
return [...packages];
};

/**
* Get packages for running unit tests.
*/
Expand Down Expand Up @@ -61,12 +85,13 @@ const getUnitTestPackages = () => {
const getVisualTestPackages = () => {
// If --group flag is passed, return all packages.
if (group) {
return getAllPackages();
return getAllVisualPackages();
}

let packages = getChangedPackages()
.map((project) => project.name.replace('@vaadin/', ''))
.filter((project) => NO_UNIT_TESTS.indexOf(project) === -1 && project.indexOf('mixin') === -1);
.filter((project) => NO_UNIT_TESTS.indexOf(project) === -1 && project.indexOf('mixin') === -1)
.concat(getUpdatedScreenshotsPackages());

if (packages.length == 0) {
// When running in GitHub Actions, do nothing.
Expand All @@ -75,9 +100,11 @@ const getVisualTestPackages = () => {
process.exit(0);
} else {
console.log(`No local packages have changed, testing all packages.`);
packages = getAllPackages();
packages = getAllVisualPackages();
}
} else {
// Filter out possible duplicates from packages list
packages = packages.filter((v, i, a) => a.indexOf(v) === i);
console.log(`Running tests for changed packages:\n${packages.join('\n')}`);
}

Expand Down