Skip to content

Commit

Permalink
Refactor E2E tests for Dashboard; add E2E tests for User and Organiza…
Browse files Browse the repository at this point in the history
…tion settings pages (#10031)

- PARTIALLY implements enso-org/cloud-v2#1232
- Partially refactor E2E test actions into a state machine.
- The main goal of this is to _disallow_ invalid actions - for example going from a page to itself, which will fail at runtime, or trying to create a new Data Link on a page where that button is not accessible.
- An auxiliary goal is to have better namespacing of actions and better clarity:
- Previously, everything was a locator at the top level of a single module. This makes it very difficult to comprehend what kinds of actions are available.
- Note: There is also older `namespace`-based namespacing for the User and Organization settings pages, which were added before this refactor. They SHOULD be refactored to the new API, but I'm not sure whether it's worth spending the time right now.
- Add E2E tests for every input on the "user" settings page and the "organization" settings page.
- A skeletal E2E test for the Datalink modal has also been added - it does not actually test anything currently but should be sufficient for building upon.

# Important Notes
None
  • Loading branch information
somebody1234 authored Jun 20, 2024
1 parent c5853e0 commit 83ec24d
Show file tree
Hide file tree
Showing 44 changed files with 2,443 additions and 1,212 deletions.
53 changes: 53 additions & 0 deletions app/ide-desktop/lib/dashboard/e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# End-to-end tests

## Running tests

Execute all commands from the parent directory.

```sh
# Run tests normally
npm run test:e2e
# Open UI to run tests
npm run test:e2e:debug
# Run tests in a specific file only
npm run test:e2e -- e2e/file-name-here.spec.ts
npm run test:e2e:debug -- e2e/file-name-here.spec.ts
# Compile the entire app before running the tests.
# DOES NOT hot reload the tests.
# Prefer not using this when you are trying to fix a test;
# prefer using this when you just want to know which tests are failing (if any).
PROD=1 npm run test:e2e
PROD=1 npm run test:e2e:debug
PROD=1 npm run test:e2e -- e2e/file-name-here.spec.ts
PROD=1 npm run test:e2e:debug -- e2e/file-name-here.spec.ts
```

## Getting started

```ts
test.test("test name here", ({ page }) =>
actions.mockAllAndLogin({ page }).then(
// ONLY chain methods from `pageActions`.
// Using methods not in `pageActions` is UNDEFINED BEHAVIOR.
// If it is absolutely necessary though, please remember to `await` the method chain.
// Note that the `async`/`await` pair is REQUIRED, as `Actions` subclasses are `PromiseLike`s,
// not `Promise`s, which causes Playwright to output a type error.
async ({ pageActions }) => await pageActions.goToHomePage(),
),
);
```

### Perform arbitrary actions (e.g. actions on the API)

```ts
test.test("test name here", ({ page }) =>
actions.mockAllAndLogin({ page }).then(
async ({ pageActions, api }) =>
await pageActions.do(() => {
api.foo();
api.bar();
test.expect(api.baz()?.quux).toEqual("bar");
}),
),
);
```
Loading

0 comments on commit 83ec24d

Please sign in to comment.