Skip to content

fix(testing): revert change & fix playwright tests #4310

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 39 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d1e36dd
fix(testing): revert change & fix playwright tests
jsjoeio Oct 4, 2021
53743af
fix(constants): add type to import statement
jsjoeio Oct 5, 2021
1e64920
refactor(e2e): delete browser test
jsjoeio Oct 6, 2021
35381c0
chore(e2e): use 1 worker for e2e test
jsjoeio Oct 7, 2021
4805186
revert(vscode): add missing route with redirect
jsjoeio Oct 7, 2021
0b080f5
chore(vscode): update to latest fork
jsjoeio Oct 7, 2021
d7e7e43
Touch up compilation step.
GirlBossRush Oct 15, 2021
717bb79
Bump vendor.
GirlBossRush Oct 15, 2021
5a28626
Fix VS Code minification step
code-asher Oct 18, 2021
e22a0e5
Move ClientConfiguration to common
code-asher Oct 13, 2021
036ee86
Ensure lib directory exists before curling
code-asher Oct 13, 2021
1acb0a1
Update incorrect e2e test help output
code-asher Oct 13, 2021
467eaef
Add back extension compilation step
code-asher Oct 19, 2021
fd7f1ec
Include missing resources in release
code-asher Oct 19, 2021
70edeb9
Set quality property in product configuration
code-asher Oct 19, 2021
6208a2b
Update VS Code
code-asher Oct 20, 2021
2d628cc
Bump vscode.
GirlBossRush Oct 21, 2021
891eb61
Bump.
GirlBossRush Oct 21, 2021
e81a37e
Bump.
GirlBossRush Oct 21, 2021
b4bda04
Use CLI directly.
GirlBossRush Oct 21, 2021
353c2a1
Update tests to reflect new upstream behavior.
GirlBossRush Oct 7, 2021
c1b40a5
Move unit tests to after the build
code-asher Oct 21, 2021
fd42387
Upgrade proxy-agent dependencies
code-asher Oct 21, 2021
dd8124f
Symlink VS Code output directory before unit tests
code-asher Oct 21, 2021
6efc7b4
Fix issues surrounding persistent processes between tests.
GirlBossRush Oct 22, 2021
6d777c1
Update VS Code cache directories
code-asher Oct 22, 2021
64b6f71
Move test symlink to script
code-asher Oct 22, 2021
752fe7c
Fix listening on a socket
code-asher Oct 22, 2021
0cfd245
Update VS Code
code-asher Oct 26, 2021
51a48ba
Standardize disposals
code-asher Oct 26, 2021
fc81fc3
Dispose HTTP server
code-asher Oct 26, 2021
070d131
Dispose app on exit
code-asher Oct 26, 2021
a343efe
Fix logging link errors
code-asher Oct 26, 2021
8857e67
Update regex used by e2e to extract address
code-asher Oct 27, 2021
7a52cb8
Log browser console in e2e tests
code-asher Oct 27, 2021
44602cc
Add base back to login page
code-asher Oct 28, 2021
6fbbd83
Remove login page test
code-asher Oct 28, 2021
f4a8c9d
Use path.posix for static base
code-asher Oct 28, 2021
02f4e00
Add test for invalid password
code-asher Oct 28, 2021
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
Update regex used by e2e to extract address
The address was recently changed to use URL which seems to add a
trailing slash when using toString, causing the regex match to fail.
  • Loading branch information
code-asher committed Oct 27, 2021
commit 8857e67a3534da3da903e532b5d52823adb3344e
20 changes: 15 additions & 5 deletions test/e2e/models/CodeServer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Logger, logger } from "@coder/logger"
import { field, Logger, logger } from "@coder/logger"
import * as cp from "child_process"
import { promises as fs } from "fs"
import * as path from "path"
import { Page } from "playwright"
import { onLine } from "../../../src/node/util"
import { PASSWORD, workspaceDir } from "../../utils/constants"
import { tmpdir } from "../../utils/helpers"
import { idleTimer, tmpdir } from "../../utils/helpers"

interface CodeServerProcess {
process: cp.ChildProcess
Expand Down Expand Up @@ -99,34 +99,44 @@ export class CodeServer {
},
)

const timer = idleTimer("Failed to extract address; did the format change?", reject)

proc.on("error", (error) => {
this.logger.error(error.message)
timer.dispose()
reject(error)
})

proc.on("close", () => {
proc.on("close", (code) => {
const error = new Error("closed unexpectedly")
if (!this.closed) {
this.logger.error(error.message)
this.logger.error(error.message, field("code", code))
}
timer.dispose()
reject(error)
})

let resolved = false
proc.stdout.setEncoding("utf8")
onLine(proc, (line) => {
// As long as we are actively getting input reset the timer. If we stop
// getting input and still have not found the address the timer will
// reject.
timer.reset()

// Log the line without the timestamp.
this.logger.trace(line.replace(/\[.+\]/, ""))
if (resolved) {
return
}
const match = line.trim().match(/HTTP server listening on (https?:\/\/[.:\d]+)$/)
const match = line.trim().match(/HTTP server listening on (https?:\/\/[.:\d]+)\/?$/)
if (match) {
// Cookies don't seem to work on IP address so swap to localhost.
// TODO: Investigate whether this is a bug with code-server.
const address = match[1].replace("127.0.0.1", "localhost")
this.logger.debug(`spawned on ${address}`)
resolved = true
timer.dispose()
resolve({ process: proc, address })
}
})
Expand Down
18 changes: 18 additions & 0 deletions test/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,21 @@ export const getAvailablePort = (options?: net.ListenOptions): Promise<number> =
})
})
})

/**
* Return a timer that will not reject as long as it is disposed or continually
* reset before the delay elapses.
*/
export function idleTimer(message: string, reject: (error: Error) => void, delay = 5000) {
const start = () => setTimeout(() => reject(new Error(message)), delay)
let timeout = start()
return {
reset: () => {
clearTimeout(timeout)
timeout = start()
},
dispose: () => {
clearTimeout(timeout)
},
}
}