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

Add simple end2end testing with playwright #86

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fjahr
Copy link
Contributor

@fjahr fjahr commented Apr 18, 2023

No description provided.

@FelixWeis FelixWeis requested a review from sectore April 19, 2023 13:04
@sectore
Copy link
Collaborator

sectore commented Apr 19, 2023

Got following error:

browserType.launch: Executable doesn't exist at /root/.cache/ms-playwright/chromium-1055/chrome-linux/chrome

Full output:

sudo just e2e-test
# Setup
cd docker && docker compose up -d
[+] Running 8/0
 ✔ Container ol-live-mempool-web-1   Running                                                                                                                                              0.0s 
 ✔ Container ol-live-electrs-1       Running                                                                                                                                              0.0s 
 ✔ Container ol-live-bitcoin-core-1  Running                                                                                                                                              0.0s 
 ✔ Container ol-live-ord-1           Running                                                                                                                                              0.0s 
 ✔ Container ol-live-fixtures-1      Running                                                                                                                                              0.0s 
 ✔ Container ol-live-mempool-db-1    Running                                                                                                                                              0.0s 
 ✔ Container ol-live-mempool-api-1   Running                                                                                                                                              0.0s 
 ✔ Container ol-live-nginx-proxy-1   Running                                                                                                                                              0.0s 
just watch > /dev/null 2>&1 & echo $! > pidfile # record pid to kill process later
sleep 5 # Wait for just watch finish starting
# test
node test/end2end/runner.ts
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

browserType.launch: Executable doesn't exist at /root/.cache/ms-playwright/chromium-1055/chrome-linux/chrome
╔═════════════════════════════════════════════════════════════════════════╗
║ Looks like Playwright Test or Playwright was just installed or updated. ║
║ Please run the following command to download new browsers:              ║
║                                                                         ║
║     npx playwright install                                              ║
║                                                                         ║
║ <3 Playwright Team                                                      ║
╚═════════════════════════════════════════════════════════════════════════╝
    at ordilabs/repos/live/test/end2end/runner.ts:4:34
    at Object.<anonymous> (ordilabs/repos/live/test/end2end/runner.ts:22:3) {
  name: 'Error'
}

Node.js v18.15.0
error: Recipe `e2e-test` failed on line 173 with exit code 1

Notes:

  • npx playwright install did not help
  • I have to run just e2e-test with sudo. In other case I got a permission issue:
    just watch > /dev/null 2>&1 & echo $! > pidfile # record pid to kill process later
    sh: 1: cannot create pidfile: Permission denied
  • Test on Ubuntu 22.04.2 LTS

@sectore
Copy link
Collaborator

sectore commented Apr 19, 2023

Update #test section with following works to me (Note: node vs. node-ts):

    # test
    npx playwright install
    npx ts-node test/end2end/runner.ts

In case use sudo can't find node, nvm and/or npx aliases are needed

sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/node" "/usr/local/bin/node"
sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/nvm" "/usr/local/bin/nvm"
sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/npx" "/usr/local/bin/npx"

^ nvm-sh/nvm#43 (comment)

@sectore
Copy link
Collaborator

sectore commented Apr 19, 2023

http://live-ol.local/ gives me 502 Bad Gateway. just 2e2-test fails for same reason:

page.goto: net::ERR_CONNECTION_RESET at http://live-ol.local/
=========================== logs ===========================
navigating to "http://live-ol.local/", waiting until "load"
============================================================
    at live/test/end2end/runner.ts:8:14 {
  name: 'Error'
}
error: Recipe `e2e-test` failed on line 171 with exit code 1

@fjahr What are your entries in hosts?

cat /etc/hosts

127.0.0.1 mempool-ol.local
::1 mempool-ol.local
127.0.0.1 ord-ol.local
::1 ord-ol.local
127.0.0.1 live-ol.local
::1 live-ol.local

const context = await browser.newContext();
const page = await context.newPage();

await page.goto('http://live-ol.local');
Copy link
Collaborator

@sectore sectore Apr 19, 2023

Choose a reason for hiding this comment

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

Port 3000 (http://live-ol.local:3000) is needed to me to fix #86 (comment)

# test
npx playwright install
npx ts-node test/end2end/runner.ts
Test passed

@sectore
Copy link
Collaborator

sectore commented Apr 19, 2023

Only (last) issue now:

# Teardown
kill $(cat pidfile) && rm pidfile # kill watch process
sh: 1: kill: No such process

error: Recipe `e2e-test` failed on line 173 with exit code 1

@fjahr
Copy link
Contributor Author

fjahr commented Apr 19, 2023

@sectore Did you try running just install first? I added playwright in the npm dependencies and that was enough on my setup. I have added a note in the readme on typescript as an additional dependency.

@fjahr
Copy link
Contributor Author

fjahr commented Apr 19, 2023

Only (last) issue now:

# Teardown
kill $(cat pidfile) && rm pidfile # kill watch process
sh: 1: kill: No such process

error: Recipe `e2e-test` failed on line 173 with exit code 1

Looks like a second order effect when the watch process wasn't actually started. Did the test pass on this run?

@fjahr
Copy link
Contributor Author

fjahr commented Apr 19, 2023

cat /etc/hosts

I have the same, for me it wasn't needed. Can you suggest changes that make it work in your environment?

127.0.0.1 mempool-ol.local
::1 mempool-ol.local
127.0.0.1 ord-ol.local
::1 ord-ol.local
127.0.0.1 live-ol.local
::1 live-ol.local

@fjahr
Copy link
Contributor Author

fjahr commented Apr 19, 2023

So is this in general the setup that we want conceptually and I can remove the draft mode? @FelixWeis

@FelixWeis
Copy link
Collaborator

Aproach ACK. few ideas

  • docker compose should a testing namespace to not tear down less ephemeral dev fixtures
  • instance just watch on a different port than :3000 using LEPTOS_SITE_ADDR env
  • these setting probably should all just be in a testing.env that just loads

@sectore
Copy link
Collaborator

sectore commented Apr 20, 2023

@fjahr Trying to answer your questions here:

Did you try running just install first?

Yes

Can you suggest changes that make it work in your environment?

I've just added http://live-ol.local:3000 to include port 3000 in line 8 of test/end2end/runner.ts

Looks like a second order effect when the watch process wasn't actually started. Did the test pass on this run?

Yes, tests did pass.

@fjahr
Copy link
Contributor Author

fjahr commented Apr 21, 2023

@sectore addressed your comments as far as I could without breaking my own environment, please give it another try.

But I guess @FelixWeis is right, this should be dockerized. I haven't worked with docker for a while so this would take me some time. How about you @sectore ? Are you familiar with Docker and want to take it over from here?

@sectore
Copy link
Collaborator

sectore commented Apr 21, 2023

How about you @sectore ? Are you familiar with Docker and want to take it over from here?

Sorry, I'm not that deep into Docker as well. But I think dockerizing tests would solve issues I have locally with sudo etc.

@@ -10,6 +10,7 @@ We use Docker to containerize all micro-services and you `just` need to run a fe

- [Rust ^1.68](https://rustup.rs/)
- [nodejs ^18.15](https://nodejs.org/en)
- [Typescript](https://www.typescriptlang.org/)
Copy link
Collaborator

Choose a reason for hiding this comment

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

To avoid mismatch of users global installed TypeScript version I would recommend to put it into devDependencies of package.json.

@FelixWeis
Copy link
Collaborator

Thanks until here! Assigning this to myself now to explore the dockerization.

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