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

Initial Playwright E2E Test for App Mode in Electron #2344

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

vyncent-t
Copy link
Contributor

@vyncent-t vyncent-t commented Sep 19, 2024

Description

This PR introduces a functional Playwright end-to-end (E2E) test for the app mode of the Headlamp project using Electron. In previous attempts, we tried leveraging the current E2E test configuration used in live production; however, this setup proved incompatible with the app mode.

As a result, we are focusing on developing and stabilizing app mode tests locally. For now, test execution will remain local-only, ensuring smoother development until we revisit integration with other environments.

This PR also introduces scripts that simplify running tests in both app mode and web mode. These scripts will help streamline the testing process and ensure a more consistent workflow across different environments.

A future PR will introduce further automation to improve the ease of switching between local app mode and local web mode. Earlier attempts to combine app mode with in-cluster configurations were unstable, so these modes will remain separate for now.


Steps to Use This Test

Prerequisites

  1. Ensure Minikube is installed and running with an instance named 'minikube'.
  2. Navigate to the E2E test directory:
    cd headlamp/app/e2e-tests

Manual Testing

  • Set the environment variable to app before running tests:
    export PLAYWRIGHT_TEST_MODE='app'

  • To test in web mode, switch the environment variable:
    export PLAYWRIGHT_TEST_MODE='web'


Automated Script Testing

These scripts simplify running the Playwright tests for both app mode and web mode. Note that switching between modes will likely cause the backend to disconnect, and you’ll need to restart the backend if switching from app to web mode during testing.

Available Scripts

  • test-app: Runs the tests in app mode.
    PLAYWRIGHT_TEST_MODE=app playwright test

  • test-web: Runs the tests in web mode.
    PLAYWRIGHT_TEST_MODE=web playwright test

Flags:

Add the following flags at the end of each script command to use

  • ui: run flag --ui to launch in ui mode
  • headed: run flag --headed to view the test

@vyncent-t vyncent-t added frontend Issues related to the frontend app e2e-tests End to end tests labels Sep 19, 2024
@vyncent-t vyncent-t self-assigned this Sep 19, 2024
@illume illume marked this pull request as draft September 23, 2024 11:40
@vyncent-t
Copy link
Contributor Author

last push fixes failing tests for web / app / incluster and are all now working for namespace playwright test

note: remove headless use

@vyncent-t
Copy link
Contributor Author

NOTE: trying to see if rebasing to the current main fixes the build failure, also removing 'incluster' just to try letting the CI work

@vyncent-t vyncent-t force-pushed the playwright-test-modes branch 6 times, most recently from 9542194 to 89ba8af Compare October 14, 2024 17:27
package-lock.json Outdated Show resolved Hide resolved
@illume
Copy link
Collaborator

illume commented Oct 15, 2024

Suggestion for how to proceed.

  • backup of your branch
  • introduce one small change at a time using (atomic commits) and check CI passes for each commit

@vyncent-t
Copy link
Contributor Author

last push adds the working app playwright test for namespaces

Note: The testing for app mode coverage must be done locally at this point as it is too unstable to add to into the CI builder. This test is meant to be the foundation for later app coverage test.

The test will require some pre set up steps before running

  • run a minikube cluster running named 'minikube'
  • set the env var PLAYWRIGHT_TEST_MODE=app in the dir where you will be running the test locally

@vyncent-t
Copy link
Contributor Author

I will be creating a different PR later for enabling of faster and easier testing using scripts

@vyncent-t vyncent-t requested a review from illume October 16, 2024 20:30
@vyncent-t vyncent-t changed the title Multi-Environment Testing for Playwright (Web/App/In-Cluster) Initial Playwright E2E Test for App Mode in Electron Oct 18, 2024
app/e2e-tests/tests/namespaces.spec.ts Outdated Show resolved Hide resolved
app/e2e-tests/package.json Outdated Show resolved Hide resolved
@vyncent-t vyncent-t force-pushed the playwright-test-modes branch 3 times, most recently from 1eb401b to 0871dd5 Compare October 24, 2024 14:31
@illume
Copy link
Collaborator

illume commented Oct 24, 2024

  • need to add instructions for how to use to README
  • test-web needs instructions to start
  • test-app fails with
  1) [chromium] › namespaces.spec.ts:43:7 › create a namespace with the minimal editor › create a namespace with the minimal editor then delete it

    Error: page.waitForSelector: Target page, context or browser has been closed
    Call log:
      - waiting for locator('span:has-text("Namespaces")') to be visible


       at namespacesPage.ts:10

       8 |     await this.page.waitForSelector('span:has-text("Cluster")');
       9 |     await this.page.getByText('Cluster', { exact: true }).click();
    > 10 |     await this.page.waitForSelector('span:has-text("Namespaces")');
         |                     ^
      11 |     await this.page.click('span:has-text("Namespaces")');
      12 |     await this.page.waitForLoadState('load');
      13 |   }

        at NamespacesPage.navigateToNamespaces (/home/rene/dev/headlamp/app/e2e-tests/tests/namespacesPage.ts:10:21)
        at /home/rene/dev/headlamp/app/e2e-tests/tests/namespaces.spec.ts:53:5

@skoeva
Copy link
Contributor

skoeva commented Oct 24, 2024

Seems to be working on my end:

image

@vyncent-t vyncent-t marked this pull request as ready for review October 29, 2024 14:22
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 29, 2024
@vyncent-t
Copy link
Contributor Author

removed a dialog line that was spelled wrong

Add working scripts

Signed-off-by: Vincent T <[email protected]>
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 27, 2024
@joaquimrocha joaquimrocha merged commit 82eb285 into main Nov 27, 2024
17 of 18 checks passed
@joaquimrocha joaquimrocha deleted the playwright-test-modes branch November 27, 2024 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app e2e-tests End to end tests frontend Issues related to the frontend lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants