Skip to content

Commit 2f63e2f

Browse files
committed
implement e2e testing for the webui
1 parent 091ae77 commit 2f63e2f

23 files changed

+399
-379
lines changed

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,11 +1103,6 @@ test-sh:
11031103
fi; \
11041104
bats $(BATSFLAGS) ./assets/aws/files/tests
11051105

1106-
1107-
.PHONY: test-e2e
1108-
test-e2e:
1109-
make -C e2e test
1110-
11111106
.PHONY: run-etcd
11121107
run-etcd:
11131108
docker build -f .github/services/Dockerfile.etcd -t etcdbox --build-arg=ETCD_VERSION=3.5.9 .
@@ -1906,3 +1901,7 @@ go-mod-tidy-all:
19061901
dump-preset-roles:
19071902
GOOS=$(OS) GOARCH=$(ARCH) $(CGOFLAG) go run ./build.assets/dump-preset-roles/main.go
19081903
pnpm test web/packages/teleport/src/Roles/RoleEditor/StandardEditor/standardmodel.test.ts
1904+
1905+
.PHONY: test-e2e
1906+
test-e2e: ensure-webassets
1907+
(cd e2e && pnpm install) && $(CGOFLAG) go test -tags=webassets_embed ./e2e/web_e2e_test.go

e2e/.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules/
2-
/test-results/
3-
/playwright-report/
4-
/playwright/.cache/
2+
test-results/
3+
playwright-report/
4+
playwright/.cache/

e2e/Makefile

Lines changed: 0 additions & 35 deletions
This file was deleted.

e2e/README.md

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
1-
## Teleport E2E Tests
1+
# E2E Testing with Playwright
22

3-
This directory contains end-to-end tests for Teleport. These tests are
4-
designed to be run against a live cluster. They are written in TS and use
5-
[Playwright](https://playwright.dev/) to interact with the browser.
6-
Docker compose is used to spin up a cluster for testing and to run the tests.
3+
This directory contains the configuration and tests for end-to-end testing against a real Teleport instance using Playwright.
74

8-
### Running the tests
9-
```bash
10-
# Make all removes the existing docker volumes to ensure a clean state
11-
# and rebuild the containers
12-
make all
13-
```
14-
or
5+
E2E tests should be run by a corresponding Go test in `web-e2e_test.go` and run
6+
using `make test-web-e2e`. To run only the Playwright test directly, you'll need a Teleport instance running locally.
7+
8+
Any test that involves an authenticated user should be run with a `START_URL` env variable that contains an invite link for the test user, this should be generated and provided by the corresponding Go test.
9+
10+
### Setup
11+
12+
Before being able to run any tests, you'll need to install the playwright package and the chromium browser.
1513

1614
```bash
17-
# Only run tests
18-
make test
15+
# Install packages
16+
pnpm install
17+
18+
# Install the Chromium browser
19+
pnpm exec playwright install chromium
1920
```
2021

21-
### MacOS building notes
22+
## Running Tests
2223

23-
Before running the tests on MacOS in Docker, you need to build Linux compatible binaries.
24-
Binaries are build using our Docker images inside `build.assets` directory. You can also
25-
build them manually using `make build-binaries` command.
24+
### Basic Commands
2625

27-
### Running tests for development
26+
```bash
27+
# Run a test with the default START_URL (https://localhost:3080/web/login)
28+
pnpm test signup.spec.ts
2829

29-
Docker compose setup is designed to run tests in CI and create the same environment
30-
locally, so debugging potential issues is easier. E2E tests make changes to the cluster,
31-
so the order of the tests is important. To run tests for development, you can use
32-
`yarn test` command to run the test against the existing cluster.
33-
`yarn codegen` starts the Playwright codegen tool that allows to record the test
34-
and generate the code for it. This improves the development speed as most code can be generated.
30+
# Run a test with a specific START_URL.
31+
START_URL=https://teleport.dev pnpm test signup.spec.ts
3532

36-
### Common issues
33+
# Run tests with the Playwright UI, useful for debugging.
34+
pnpm test --ui
3735

38-
`Cannot run macOS (Mach-O) executable in Docker: Exec format error`
36+
# Start the Playwright codegen to generate tests by recording your browser interactions.
37+
pnpm exec playwright codegen
3938

40-
This error means that you are trying to run MacOS binary on Linux. You need to build
41-
Linux compatible binaries to run them in Docker. You can rebuild them using `make build-binaries`
42-
or just remove existing binaries in `../build` as they will be rebuilt automatically.
39+
# View past test reports.
40+
pnpm report
41+
```

e2e/config/Dockerfile

Lines changed: 0 additions & 20 deletions
This file was deleted.

e2e/config/run-tests.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

e2e/config/state.yaml

Lines changed: 0 additions & 32 deletions
This file was deleted.

e2e/config/teleport.yaml

Lines changed: 0 additions & 42 deletions
This file was deleted.

e2e/docker-compose.yaml

Lines changed: 0 additions & 37 deletions
This file was deleted.

e2e/package.json

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
{
2-
"name": "teleport-e2e",
2+
"name": "playwright-e2e-testing",
33
"version": "1.0.0",
4-
"description": "Teleport E2E tests",
5-
"repository": "https://github.com/gravitational/teleport",
4+
"description": "Playwright tests for e2e testing.",
5+
"scripts": {
6+
"test": "playwright test --project=chromium",
7+
"report": "playwright show-report"
8+
},
69
"license": "Apache-2.0",
7-
"private": true,
8-
"dependencies": {},
910
"devDependencies": {
10-
"@playwright/test": "^1.35.1",
11-
"typescript": "^5.1.6"
12-
},
13-
"scripts": {
14-
"codegen": "playwright codegen https://localhost:3080",
15-
"test": "playwright test"
11+
"@playwright/test": "^1.51.1"
1612
}
1713
}

0 commit comments

Comments
 (0)