Skip to content

Commit 7f749ba

Browse files
committed
refactor: test-e2e.sh script
1 parent e17659e commit 7f749ba

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

ci/dev/test-e2e.sh

+3-13
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,9 @@ set -euo pipefail
33

44
main() {
55
cd "$(dirname "$0")/../.."
6-
# We must keep jest in a sub-directory. See ../../test/package.json for more
7-
# information. We must also run it from the root otherwise coverage will not
8-
# include our source files.
9-
if [[ -z ${PASSWORD-} ]] || [[ -z ${CODE_SERVER_ADDRESS-} ]]; then
10-
echo "The end-to-end testing suites rely on your local environment"
11-
echo -e "\n"
12-
echo "Please set the following environment variables locally:"
13-
echo " \$PASSWORD"
14-
echo " \$CODE_SERVER_ADDRESS"
15-
echo -e "\n"
16-
exit 1
17-
fi
18-
CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" --config ./test/jest.e2e.config.ts --runInBand
6+
cd test
7+
# TODO@jsjoeio remove the test-match
8+
PASSWORD=e45432jklfdsab CODE_SERVER_ADDRESS=http://localhost:8080 yarn folio --config=config.ts --test-match login.test.ts --reporter=list
199
}
2010

2111
main "$@"

test/e2e/loginPage.test.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ import { test, expect } from "@playwright/test"
22
import { CODE_SERVER_ADDRESS } from "../utils/constants"
33

44
test.describe("login page", () => {
5-
test.beforeEach(async ({ page }) => {
6-
// TODO@jsjoeio reset context somehow
7-
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
8-
})
5+
// Reset the browser so no cookies are persisted
6+
// by emptying the storageState
7+
const options = {
8+
contextOptions: {
9+
storageState: {},
10+
},
11+
}
912

10-
test("should see the login page", async ({ page }) => {
13+
test("should see the login page", options, async ({ page }) => {
14+
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
1115
// It should send us to the login page
1216
expect(await page.title()).toBe("code-server login")
1317
})

test/e2e/logout.test.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import { test, expect } from "@playwright/test"
22
import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
33

44
test.describe("logout", () => {
5-
test.beforeEach(async ({ page }) => {
6-
// TODO@jsjoeio reset context
5+
// Reset the browser so no cookies are persisted
6+
// by emptying the storageState
7+
const options = {
8+
contextOptions: {
9+
storageState: {},
10+
},
11+
}
12+
test("should be able login and logout", options, async ({ page }) => {
713
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
8-
})
9-
10-
test("should be able login and logout", async ({ page }) => {
1114
// Type in password
1215
await page.fill(".password", PASSWORD)
1316
// Click the submit button and login

0 commit comments

Comments
 (0)