Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

[terra-functional-testing] Fixing Nexus screenshot bugs #839

Merged
merged 12 commits into from
Jan 23, 2024

Conversation

BenBoersma
Copy link
Contributor

Summary

Fixed Nexus upload/download of screenshots for multiple nodes.

Fixed PR commenting when mismatch was detected.
Fixed logging for when doing a PR build or Screenshot Branch commit build not showing which tests had mismatches.

What was changed:
Nexus screenshots are now stored as multiple directories for each node being run. Directories are named as following with undefined values not being present '$THEME-$LOCALE-$BROWSER-$FORMFACTOR$' I.E 'terra-default-theme-en-chrome-large'

PR commenting is now based on the existence of a file that is made during toMatchReference calls instead of via process.env variables. This file is deleted on test suite completion.

Validates.screenshot now passes in the test name to its 'toMatchReference' calls, so that when 'toMatchReference' is doing Nexus mismatch logic it can now output a log message of the test that fails due to mismatch so that in can be found by Nexus users.

Why it was changed:

Testing

This change was tested using:

  • WDIO
  • Jest
  • Visual testing (please attach a screenshot or recording)
  • Other (please describe below)
  • No tests are needed

Reviews

In addition to engineering reviews, this PR needs:

  • UX review
  • Accessibility review
  • Functional review

Additional Details

This PR resolves:

UXPLATFORM-9299


Thank you for contributing to Terra.
@cerner/terra

const outputDir = getOutputDir();
const fileName = path.join(outputDir, 'ignored-mismatch.json');
// Create the output directory if it does not already exist.
if (!fs.existsSync(outputDir)) {
Copy link
Contributor

@kenk2 kenk2 Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Is it possible to turn this into an async function? the Sync API from node is infamous for being a blocking API (meaning that it needs to wait for this to complete before doing anything else in node). This will affect performance down the road, especially when we change this to run multiple suites at a time. I might suggest using the equivalent promises API's from node: https://nodejs.org/docs/latest-v14.x/api/fs.html#fs_promises_api

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it is possible, at the very least I have a suspicion that would be a major version bump since we would be changing a main testing function to be async when it wasn't before.

static makeReferenceName(locale, theme, formFactor, browser) {
const referenceName = [theme, locale, browser, formFactor].filter(
(str) => {
if (str !== '' || str !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Are there any other types of falsey's we have to worry about? What would happen here with null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be but reconsidering this, we're just checking for falsy values so might as well filter them all out for an easy code run so changed here
0f73f13

try {
if (process.env.SCREENSHOT_MISMATCH_CHECK === 'true' && buildBranch.match(BUILD_BRANCH.pullRequest)) {
if (fs.existsSync(fileName) && buildBranch.match(BUILD_BRANCH.pullRequest)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the above comment: I'd try to avoid the sync api as much as possible. This is also already an async function so we should be using the async (Promises) api as much as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright finally got a moment to updated this, moved off the sync api and onto the async ones
3b352ec

@github-actions github-actions bot temporarily deployed to preview-pr-839 January 18, 2024 00:05 Destroyed
@BenBoersma BenBoersma merged commit 59131a2 into main Jan 23, 2024
6 checks passed
@BenBoersma BenBoersma deleted the functional-testing-debug branch January 23, 2024 15:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants