conda-incubator / conda-store-ui

conda-store-ui is a frontend for conda-store powered by react
https://conda-incubator.github.io/conda-store-ui/
BSD 3-Clause "New" or "Revised" License
13 stars 18 forks source link

Fix playwright tests #372

Closed nkaretnikov closed 4 months ago

nkaretnikov commented 5 months ago

Fixes playwright test failures introduced by a yarn update.

Description

This pull request:

Pull request checklist

Additional information

gabalafou commented 4 months ago

Could you please explain the process you used to update the yarn lockfile in detailed steps?

As it stands, I don't know how to recreate this PR.

nkaretnikov commented 4 months ago

@gabalafou Happy to help, LMK if the following doesn't answer your questions.

I need to know how to generate the lockfile changes.

I did yarn install locally, it updated the lockfile, I committed the lockfile to the repo, see: https://stackoverflow.com/a/77300807

I need to know how to run the tests locally.

playwright_env.sh:

# export REACT_APP_AUTH_TOKEN=
export CONDA_STORE_SERVER_PORT='8000'
export CONDA_STORE_BASE_URL='http://localhost:8000'
export CONDA_STORE_AUTH='basic'
export CONDA_STORE_USERNAME='username'
export CONDA_STORE_PASSWORD='password'
export REACT_APP_API_URL='http://localhost:8080/conda-store/'
export REACT_APP_AUTH_METHOD='cookie'
export REACT_APP_LOGIN_PAGE_URL='http://localhost:8080/conda-store/login?next='
export REACT_APP_STYLE_TYPE='green-accent'
export REACT_APP_CONTEXT='webapp'
export REACT_APP_SHOW_AUTH_BUTTON='true'
export REACT_APP_LOGOUT_PAGE_URL='http://localhost:8080/conda-store/logout?next=/'
export YARN_ENABLE_IMMUTABLE_INSTALLS='false'

python test/playwright/test_ux.py
# pytest -rfxs test/playwright/test_ux.py -vvv --capture=no
╔════════════════════════════════════════════════════════════════════════════════════════════════╗
║ Looks like you launched a headed browser without having a XServer running.                     ║
║ Set either 'headless: true' or use 'xvfb-run <your-playwright-app>' before running Playwright. ║
║                                                                                                ║
║ <3 Playwright Team                                                                             ║
╚════════════════════════════════════════════════════════════════════════════════════════════════╝
diff --git a/test/playwright/test_ux.py b/test/playwright/test_ux.py
index dcf0782..ab7c42f 100644
--- a/test/playwright/test_ux.py
+++ b/test/playwright/test_ux.py
@@ -306,7 +306,7 @@ if __name__ == "__main__":
     # Use playwright.chromium, playwright.firefox or playwright.webkit
     # Pass headless=False to launch() to see the browser UI
     # slow_mo adds milliseconds to each playwright command so humans can follow along
-    browser = playwright.chromium.launch(headless=False, slow_mo=500)
+    browser = playwright.chromium.launch(headless=True, slow_mo=500)
     page = browser.new_page()

     # Go to http://localhost:{server_port}

I'd also add that these tests are passing on CI. So if there are any problems, make sure you have no other instances of conda-store running, etc.