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

Integrate visual testing mechanism to the latest KDS version #901

Merged
merged 62 commits into from
Jan 29, 2025

Conversation

KshitijThareja
Copy link
Contributor

Description

This PR aims to integrate the visual testing mechanism to the latest version of KDS and ensure its proper working by implementing necessary changes.

Changelog

  • Description: Integrates visual testing setup to KDS.
  • Products impact: -
  • Addresses: -
  • Components: -
  • Breaking: -
  • Impacts a11y: -
  • Guidance: -

Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical and brittle code paths are covered by unit tests
  • The change is described in the changelog section above

Reviewer guidance

  • Is the code clean and well-commented?
  • Are there tests for this change?
  • Are all UI components LTR and RTL compliant (if applicable)?
  • Add other things to check for here

KshitijThareja and others added 30 commits January 19, 2025 01:02
…sting

Percy and jest-puppeteer environment setup for visual testing
…ncurrently

Replace custom checks from the server script to use concurrently
…ction

Add abstraction logic for simplifying writing visual tests
@MisRob MisRob requested review from bjester and AlexVelezLl January 21, 2025 14:20
Copy link
Member

@bjester bjester left a comment

Choose a reason for hiding this comment

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

A few comments, but nothing blocking that I can see from a quick pass

yarn --frozen-lockfile
npm rebuild node-sass
- name: Download Chromium
run: npx puppeteer browsers install chrome
Copy link
Member

Choose a reason for hiding this comment

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

Curious if this is cached, and if not, if we should

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

From what I can infer from the test run, puppeteer does cache the browser after the first workflow run and uses the same for successive runs. Is there a need to add another step to the workflow for the same?

@@ -0,0 +1,121 @@
const path = require('node:path');
const http = require('http');
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be node:http

@@ -64,4 +65,106 @@ describe('KButton', () => {
expect(wrapper.emitted().click).toBeTruthy();
});
});

describe.visual('KButton Visual Tests', () => {
Copy link
Member

Choose a reason for hiding this comment

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

I suppose Visual in the string is redundant with what describe.visual does

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'll just make it KButton Tests in that case 👍

@@ -60,7 +60,7 @@ require('./grids/globalStyles.js'); // global grid styles
* Also, set up global state, listeners, and styles.
*/
export default function KThemePlugin(Vue) {
if (!isNuxtServerSideRendering()) {
if (!isNuxtServerSideRendering() && process.env.VISUAL_TESTING !== 'true') {
Copy link
Member

Choose a reason for hiding this comment

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

Why wouldnt we install the KThemePlugin while running visual tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the introduction of KLiveRegion and the changes in the KThemePlugin, if we try to run visual tests, the variable 'document' will become undefined as for it to work as intended, we require a jsdom test environment. This will result in errors in visual test execution

Copy link
Member

Choose a reason for hiding this comment

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

Alright, thanks! Lets merge it, let it run and then if we need to activate it, we can look for alternatives. Thanks!

@AlexVelezLl
Copy link
Member

Thanks a lot for all your hard work @KshitijThareja!!! Merging! 🎉 🎉 🎉.

@AlexVelezLl AlexVelezLl merged commit f82e7e0 into learningequality:develop Jan 29, 2025
9 checks passed
learning-equality-bot bot pushed a commit that referenced this pull request Jan 29, 2025
@AlexVelezLl
Copy link
Member

Hey @KshitijThareja @bjester, we are getting this error on the execution. Do you have any idea why could it be happening? https://github.com/learningequality/kolibri-design-system/actions/runs/13038589590/job/36375439798

image

@bjester
Copy link
Member

bjester commented Jan 29, 2025

@AlexVelezLl ChatGPT says to possibly try using --no-sandbox first, and then possibly add --disable-setuid-sandbox. Also, we should ensure all dependencies are installed in the action's container

@KshitijThareja
Copy link
Contributor Author

Hi @AlexVelezLl @bjester
So I looked it up and found this. The easiest, and probably the best fix for now would be to just change the ubuntu version used for running visual test workflow to 22.04.
Should I go forward with making a PR for the same?

@bjester
Copy link
Member

bjester commented Jan 29, 2025

Hi @AlexVelezLl @bjester So I looked it up and found this. The easiest, and probably the best fix for now would be to just change the ubuntu version used for running visual test workflow to 22.04. Should I go forward with making a PR for the same?

Sounds like --no-sandbox is easier:

What if I don‘t have root access to the machine and can’t install anything?
You will need to run developer builds with the --no-sandbox command line flag, but be aware that this disables critical security features of Chromium and should never be used when browsing the open web.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants