Skip to content

test(site): improve E2E framework #9438

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

Merged
merged 6 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more improvements
  • Loading branch information
mtojek committed Aug 30, 2023
commit 5fcd53d076fd20b85946aa4b393eccab23e57d8c
5 changes: 3 additions & 2 deletions site/e2e/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ export const beforeCoderTest = async (page: Page) => {
let responseText = ""
try {
if (shouldLogResponse) {
const buffer = await response.body() // Read the response as a buffer
responseText = buffer.toString("utf-8") // Convert the buffer to text
const buffer = await response.body()
responseText = buffer.toString("utf-8")
responseText = responseText.replace(/\n$/g, "")
} else {
responseText = "skipped..."
}
Expand Down
2 changes: 2 additions & 0 deletions site/e2e/tests/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { randomUUID } from "crypto"
import * as http from "http"
import { createTemplate, createWorkspace, startAgent } from "../helpers"

test.beforeEach(async ({ page }) => await beforeCoderTest(page))

test("app", async ({ context, page }) => {
const appContent = "Hello World"
const token = randomUUID()
Expand Down
3 changes: 3 additions & 0 deletions site/e2e/tests/gitAuth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { gitAuth } from "../constants"
import { Endpoints } from "@octokit/types"
import { GitAuthDevice } from "api/typesGenerated"
import { Awaiter, createServer } from "../helpers"
import { beforeCoderTest } from "../hooks"

test.beforeEach(async ({ page }) => await beforeCoderTest(page))

// Ensures that a Git auth provider with the device flow functions and completes!
test("git auth device", async ({ page }) => {
Expand Down
3 changes: 3 additions & 0 deletions site/e2e/tests/outdatedAgent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import {
sshIntoWorkspace,
startAgentWithCommand,
} from "../helpers"
import { beforeCoderTest } from "../hooks"

const agentVersion = "v0.14.0"

test.beforeEach(async ({ page }) => await beforeCoderTest(page))

test("ssh with agent " + agentVersion, async ({ page }) => {
const token = randomUUID()
const template = await createTemplate(page, {
Expand Down
3 changes: 3 additions & 0 deletions site/e2e/tests/outdatedCLI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import {
sshIntoWorkspace,
startAgent,
} from "../helpers"
import { beforeCoderTest } from "../hooks"

const clientVersion = "v0.14.0"

test.beforeEach(async ({ page }) => await beforeCoderTest(page))

test("ssh with client " + clientVersion, async ({ page }) => {
const token = randomUUID()
const template = await createTemplate(page, {
Expand Down
3 changes: 3 additions & 0 deletions site/e2e/tests/restartWorkspace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {

import { firstBuildOption, secondBuildOption } from "../parameters"
import { RichParameter } from "../provisionerGenerated"
import { beforeCoderTest } from "../hooks"

test.beforeEach(async ({ page }) => await beforeCoderTest(page))

test("restart workspace with ephemeral parameters", async ({ page }) => {
const richParameters: RichParameter[] = [firstBuildOption, secondBuildOption]
Expand Down
3 changes: 3 additions & 0 deletions site/e2e/tests/webTerminal.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { test } from "@playwright/test"
import { createTemplate, createWorkspace, startAgent } from "../helpers"
import { randomUUID } from "crypto"
import { beforeCoderTest } from "../hooks"

test.beforeEach(async ({ page }) => await beforeCoderTest(page))

test("web terminal", async ({ context, page }) => {
const token = randomUUID()
Expand Down