1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2024-12-26 12:15:26 +00:00

refactor: test-e2e.sh script

This commit is contained in:
Joe Previte 2021-04-13 17:31:56 -07:00
parent 6c3bb101cd
commit 92b7c1e9a8
No known key found for this signature in database
GPG Key ID: 2C91590C6B742C24
3 changed files with 20 additions and 23 deletions

View File

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

View File

@ -2,12 +2,16 @@ import { test, expect } from "@playwright/test"
import { CODE_SERVER_ADDRESS } from "../utils/constants" import { CODE_SERVER_ADDRESS } from "../utils/constants"
test.describe("login page", () => { test.describe("login page", () => {
test.beforeEach(async ({ page }) => { // Reset the browser so no cookies are persisted
// TODO@jsjoeio reset context somehow // by emptying the storageState
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" }) const options = {
}) contextOptions: {
storageState: {},
},
}
test("should see the login page", async ({ page }) => { test("should see the login page", options, async ({ page }) => {
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
// It should send us to the login page // It should send us to the login page
expect(await page.title()).toBe("code-server login") expect(await page.title()).toBe("code-server login")
}) })

View File

@ -2,12 +2,15 @@ import { test, expect } from "@playwright/test"
import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants" import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
test.describe("logout", () => { test.describe("logout", () => {
test.beforeEach(async ({ page }) => { // Reset the browser so no cookies are persisted
// TODO@jsjoeio reset context // by emptying the storageState
const options = {
contextOptions: {
storageState: {},
},
}
test("should be able login and logout", options, async ({ page }) => {
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" }) await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
})
test("should be able login and logout", async ({ page }) => {
// Type in password // Type in password
await page.fill(".password", PASSWORD) await page.fill(".password", PASSWORD)
// Click the submit button and login // Click the submit button and login