Skip to content

Commit d0eece3

Browse files
committed
refactor: add note to test.sh about --home
1 parent 2dc56ad commit d0eece3

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

ci/dev/test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ main() {
1717
echo " \$PASSWORD"
1818
echo " \$CODE_SERVER_ADDRESS"
1919
echo -e "\n"
20-
echo "Please make sure you have code-server running locally."
20+
echo "Please make sure you have code-server running locally with the flag:"
21+
echo " --home \$CODE_SERVER_ADDRESS/healthz "
2122
echo -e "\n"
2223
exit 1
2324
fi

src/common/util.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ export interface Cookie {
140140
* Checks if a cookie exists in array of cookies
141141
*/
142142
export function checkForCookie(cookies: Array<Cookie>, key: string): boolean {
143-
// Check for at least one cookie where the name is equal to key
144-
return cookies.filter((cookie) => cookie.name === key).length > 0
143+
// Check for a cookie where the name is equal to key
144+
return Boolean(cookies.find((cookie) => cookie.name === key))
145145
}
146146

147147
/**

test/goHome.test.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ describe("login", () => {
1212
// Create a new context with the saved storage state
1313
const storageState = JSON.parse(process.env.STORAGE || "")
1414

15-
//
1615
const cookieToStore = {
1716
sameSite: "Lax" as const,
1817
name: "key",
@@ -61,16 +60,20 @@ describe("login", () => {
6160

6261
// NOTE: this test will fail if you do not run code-server with --home $CODE_SERVER_ADDRESS/healthz
6362
it("should see a 'Go Home' button in the Application Menu that goes to /healthz", async (done) => {
63+
let requestedGoHomeUrl = false
6464
// Ideally, this test should pass and finish before the timeout set in the Jest config
6565
// However, if it doesn't, we don't want a memory leak so we set this backup timeout
6666
// Otherwise Jest may throw this error
6767
// "Jest did not exit one second after the test run has completed.
6868
// This usually means that there are asynchronous operations that weren't stopped in your tests.
6969
// Consider running Jest with `--detectOpenHandles` to troubleshoot this issue."
70-
const backupTimeout = setTimeout(() => done(), 20000)
70+
const backupTimeout = setTimeout(() => {
71+
// If it's not true by this point then the test should fail
72+
expect(requestedGoHomeUrl).toBeTruthy()
73+
done()
74+
}, 20000)
7175

7276
const GO_HOME_URL = `${process.env.CODE_SERVER_ADDRESS}/healthz`
73-
let requestedGoHomeUrl = false
7477
page.on("request", (request) => {
7578
// This ensures that we did make a request to the GO_HOME_URL
7679
// Most reliable way to test button

0 commit comments

Comments
 (0)