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

feat: add playwright CI testing #1542

Merged
merged 38 commits into from
Sep 22, 2023
Merged

feat: add playwright CI testing #1542

merged 38 commits into from
Sep 22, 2023

Conversation

weboko
Copy link
Collaborator

@weboko weboko commented Sep 7, 2023

Problem

js-waku is a library dedicated for browser environment and sometimes it happens that something breaks at the point of integrations of js-waku and some web application (consumer).

Solution

To solve this problems I considered different options:

  • basic karma testing;
    discarded due to limitations of what can be tested (most common use is unit tests execution in browser context), poor integration with web frameworks;

  • jest with add-ons;
    the same goes here since, would require karma anyway and it is still not the answer to our problem. One thing that is good is to test React components - but we are not interested in it;

  • puppeteer;
    poor support of anything but Chrome;

  • playwright;
    this is what I choose to move forward. This tool allows easily run tests in different browsers and allows to treat web app under testing as a web site, which is the end goal of our testing - to make sure latest version builds and works in browser environment

How playwright will work:

  • right now it fetches web-chat example by using @waku/create-app and it injects links to repository's version of packages;
  • it runs the example as a production build web application on localhost:8080;
  • it runs checks over it in different browsers and gives report;

js-waku playwright drawio (1)

Current design allows us to do following (will document into Epic):

  • add some more tests and cover more functionality of js-waku;
  • add support for other examples, maybe apps crated by the community (bounties);
  • add more complex testing - spawning nwaku nodes, connecting from some example, doing send - receive test;
  • add tests for examples like logs testing to check if no errors are there - stability of examples;

Notes

@github-actions
Copy link

github-actions bot commented Sep 7, 2023

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku core 27.69 KB (0%) 554 ms (0%) 2.1 s (+49.36% 🔺) 2.6 s
Waku Simple Light Node 262.6 KB (+5.6% 🔺) 5.3 s (+5.6% 🔺) 6 s (+24.08% 🔺) 11.2 s
ECIES encryption 28.7 KB (0%) 574 ms (0%) 1.7 s (+68.79% 🔺) 2.3 s
Symmetric encryption 28.7 KB (0%) 575 ms (0%) 1.7 s (-5% 🔽) 2.3 s
DNS discovery 110.62 KB (0%) 2.3 s (0%) 2.6 s (-2.05% 🔽) 4.8 s
Privacy preserving protocols 117.38 KB (+0.32% 🔺) 2.4 s (+0.32% 🔺) 2.7 s (-23.12% 🔽) 5.1 s
Light protocols 25.83 KB (0%) 517 ms (0%) 1.5 s (-16.36% 🔽) 2 s
History retrieval protocols 24.9 KB (0%) 499 ms (0%) 1.5 s (-13.82% 🔽) 2 s
Deterministic Message Hashing 5.65 KB (0%) 113 ms (0%) 594 ms (+10.87% 🔺) 707 ms

@weboko weboko changed the title feat: add bundler ci run feat: add playwright CI testing Sep 11, 2023
@weboko weboko marked this pull request as ready for review September 11, 2023 21:12
@weboko weboko requested a review from a team as a code owner September 11, 2023 21:12
@@ -0,0 +1,3 @@
EXAMPLE_TEMPLATE="web-chat"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder what is the best practice here as I assume this will fail if we do any breaking change in the API.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Once breaking change is introduced to an example under testing it won't affect CI right away since examples are shipped with a particular version of @waku/create-app.

Or what API do you mean?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Once breaking change is introduced to an example under testing it won't affect CI right away since examples are shipped with a particular version of @waku/create-app.

From the PR's description:

it injects links to repository's version of packages;

what repository are we referring to? My understanding is:

  1. Pull latest web-chat code from js-waku-examples repo
  2. Does some symlink to replace web-chat's dependency with code from the current js-waku git branch
  3. build web-chat, runs some test

if a breaking change on any of the js-waku package happens, then the web-chat code pull cannot use the new changed js-waku API, and hence the CI would fail.

What part am I not understanding?

Copy link
Collaborator Author

@weboko weboko Sep 22, 2023

Choose a reason for hiding this comment

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

you are right, to solve this one should update an example to correspond to the breaking changes in js-waku
To do this there are two ways:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that means the flow for release will be something like:

  • check if test against example fails;
  • if yes - go and upgrade example to next package version;
  • check again - if ok - release;

Copy link
Collaborator

@danisharora099 danisharora099 left a comment

Choose a reason for hiding this comment

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

any specific reasons we're doing .js files and not .ts?

@@ -0,0 +1,3 @@
EXAMPLE_TEMPLATE="web-chat"
Copy link
Collaborator

Choose a reason for hiding this comment

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

should .env be pushed to GH?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is ok to push .env file, to make it explicit - renamed it to .env.local to imply it is defaults for local running

packages/browser-tests/.eslintrc.cjs Outdated Show resolved Hide resolved
@weboko
Copy link
Collaborator Author

weboko commented Sep 22, 2023

any specific reasons we're doing .js files and not .ts?

@danisharora099 yes, because they are simple scripts that are run over node.js as it is and there is no reason to complicate it

@weboko weboko merged commit 281d9b2 into master Sep 22, 2023
9 of 11 checks passed
@weboko weboko deleted the weboko/bundler-ci branch September 22, 2023 12:34
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.

Do a bundler run as part of the CI
4 participants