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

Playwright e2e reconfiguration #871

Conversation

atomicgamedeveloper
Copy link
Contributor

Resolving issues #45 and #320 regarding the e2e tests using playwright needing to be setup, mitigating issues about gitlab's CAPTCHA's and missing CodeCov in git actions for e2e tests.

@atomicgamedeveloper atomicgamedeveloper changed the title Reconfigure playwright, fix tests, update test:e2e and .gitignore Playwright e2e reconfiguration Jul 30, 2024
@prasadtalasila
Copy link
Contributor

@atomicgamedeveloper Thanks for the PR. Please update the README as well.

@prasadtalasila
Copy link
Contributor

@atomicgamedeveloper please rebase to the latest commit on feature/distributed-demo branch

Copy link
Contributor

@prasadtalasila prasadtalasila left a comment

Choose a reason for hiding this comment

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

@atomicgamedeveloper thanks for the PR. Please check the comments.

const coverageOptions: CoverageReportOptions = {
name: 'Playwright Monocart Coverage Report',

reports: ['codecov', 'v8'],
Copy link
Contributor

Choose a reason for hiding this comment

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

please add 'console-summary' as well

client/package.json Outdated Show resolved Hide resolved
client/playwright.config.ts Show resolved Hide resolved
client/test/e2e/tests/auth.setup.ts Show resolved Hide resolved
can run the tests by running `yarn test:e2e`.

By default, Playwright launches the react client website as specified in `config/test.js`
and terminates it afterwards. Running `yarn test:e2e:int` allows you to skip this so
Copy link

Choose a reason for hiding this comment

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

Line length

```

## OAuth Setup

You can follow the instructions in
[authorization page](../../docs/admin/client/auth.md) to setup oauth for the
You can follow the instructions in [authorization page](../../docs/admin/client/auth.md) to setup OAuth for the
Copy link

Choose a reason for hiding this comment

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

Line length

@@ -35,8 +39,7 @@ the details of your testing environment. For instance, you need to adjust:
* `REACT_APP_LOGOUT_REDIRECT_URI`

to reflect your test setup. More information on about the environment settings is
available in [authorization](../../docs/admin/client/auth.md) and
[client deployment](../../docs/admin/client/CLIENT.md) pages.
available in [authorization](../../docs/admin/client/auth.md) and [client deployment](../../docs/admin/client/CLIENT.md) pages.
Copy link

Choose a reason for hiding this comment

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

Line length

@@ -48,6 +51,8 @@ REACT_APP_REDIRECT_URI="http://localhost:4000/Library"
REACT_APP_LOGOUT_REDIRECT_URI="http://localhost:4000"
```

Finally, run `yarn config:test` to copy the config file into the `build` and `public` folders.
Copy link

Choose a reason for hiding this comment

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

Line length


```bash
yarn test:e2e
```
Or with manual website launch:
```bash
Copy link

Choose a reason for hiding this comment

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

Fenced code blocks should be surrounded by blank lines

Copy link
Contributor

@prasadtalasila prasadtalasila left a comment

Choose a reason for hiding this comment

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

@atomicgamedeveloper thanks for the update. Please see the comments.

@@ -8,13 +8,14 @@ on:
paths:
- 'client/**'
workflow_dispatch:
paths:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep this. Otherwise, this workflow runs too many times.

.github/workflows/client.yml Show resolved Hide resolved

By default, Playwright launches the react client website as specified in `config/test.js`
and terminates it afterwards. Running `yarn test:e2e:int` allows you to skip this so
you can host the website yourself.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that we can host the client at a doman address (say sandbox.cps.digit.au.dk) and perform E2E tests?

client/test/README.md Show resolved Hide resolved
client/test/README.md Show resolved Hide resolved
@prasadtalasila
Copy link
Contributor

prasadtalasila commented Sep 6, 2024

@atomicgamedeveloper Thanks for updates on the PR. List of pending changes:

  1. Rename "int" and "Int" strings with "ext" and "Ext" strings respectively in the playwright.config.js.
  2. Change monocart report output from "console-summary" to "console-detail"
  3. Resolve code conflicts

A quick question on the yarn test:e2e:ext command. To run this test successfully, I ran the following commands in sequence.

# update config/test.js
# Add test/.env file

yarn install
yarn build
yarn config:test
yarn test:e2e:ext

My question is the need to perform build and config:test tasks if we are not running the client website ourselves. Is there a simple way to skip these two steps for the case of externally hosted client? Thanks for the clarification.

@prasadtalasila
Copy link
Contributor

@atomicgamedeveloper please increment the packqge version number to 0.4.1.

@atomicgamedeveloper
Copy link
Contributor Author

@atomicgamedeveloper Thanks for updates on the PR. List of pending changes:

1. Rename "int" and "Int" strings with "ext" and "Ext" strings respectively in the playwright.config.js.

2. Change monocart report output from "console-summary" to "console-detail"

3. Resolve code conflicts

A quick question on the yarn test:e2e:ext command. To run this test successfully, I ran the following commands in sequence.

# update config/test.js
# Add test/.env file

yarn install
yarn build
yarn config:test
yarn test:e2e:ext

My question is the need to perform build and config:test tasks if we are not running the client website ourselves. Is there a simple way to skip these two steps for the case of externally hosted client? Thanks for the clarification.

Build and config:test are indeed not necessary for the case of the externally hosted client unless you are using yarn start from within the project, as Playwright draws the app URL from the test/.env anyway. I have updated the README.md to reflect this better.

@prasadtalasila
Copy link
Contributor

@atomicgamedeveloper

Test setup:

The tests on the external server are not running successfully for the following setup.

DTaaS server: dtl-server-2.st.lab.au.dk
gitlab: maestro.cps.digit.au.dk/gitlab
(please use your account credentials for this installation)

The logs on my machine are:

PS C:\Users\user\git\DTaaS\client> yarn install
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning Workspaces can only be enabled in private projects.
[4/4] Building fresh packages...
Done in 95.49s.
PS C:\Users\user\git\DTaaS\client> yarn test:e2e:ext
yarn run v1.22.19
$ cross-env ext=true yarn test:e2e
$ playwright test -c ./playwright.config.ts

Running 11 tests using 4 workers

  ✘  1 [setup] › auth.setup.ts:12:1 › authenticate (1.0m)
[MCR] Not found coverage data in dir(s): 


  1) [setup] › auth.setup.ts:12:1 › authenticate ───────────────────────────────────────────────────

    Test timeout of 60000ms exceeded.

    Error: locator.click: Test timeout of 60000ms exceeded.
    Call log:
      - waiting for getByRole('button', { name: 'GitLab logo Sign In with GitLab' })


      15 |   await page
      16 |     .getByRole('button', { name: 'GitLab logo Sign In with GitLab' })
    > 17 |     .click();
         |      ^
      18 |   try {
      19 |     await page.waitForSelector('label[for="user_login"]', { timeout: 10000 }); // wait up to 10 seconds
      20 |   } catch (error) {

        at C:\Users\au598657\git\DTaaS\client\test\e2e\tests\auth.setup.ts:17:6

    attachment #1: trace (application/zip) ─────────────────────────────────────────────────────────
    test-results\auth.setup.ts-authenticate-setup\trace.zip
    Usage:

        yarn playwright show-trace test-results\auth.setup.ts-authenticate-setup\trace.zip

    ────────────────────────────────────────────────────────────────────────────────────────────────

  Slow test file: [setup] › auth.setup.ts (1.0m)
  Consider splitting slow test files to speed up parallel execution
  1 failed
    [setup] › auth.setup.ts:12:1 › authenticate ────────────────────────────────────────────────────
  10 did not run

  Serving HTML report at http://localhost:9323. Press Ctrl+C to quit.
Terminate batch job (Y/N)? Y

Text Corrections

The yarn install and yarn config:test need to be run before yarn test:ext can be run successfully. Please mention this in test/README.md

The DEVELOPER.md has the following text which can be removed.

:bug: The end-to-end tests are extremely brittle.
They are not being used at present.

client/test/README.md Outdated Show resolved Hide resolved
client/test/README.md Outdated Show resolved Hide resolved
Copy link

codeclimate bot commented Sep 20, 2024

Code Climate has analyzed commit b4abc81 and detected 0 issues on this pull request.

View more on Code Climate.

@prasadtalasila prasadtalasila merged commit 14fbd92 into INTO-CPS-Association:feature/distributed-demo Sep 20, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants