Skip to content

Commit ec595ea

Browse files
voidmatchaclaude
andcommitted
fix: re-enable skipped Heart tests and make non-asserting checks assert
- Remove a committed `it.only` (introduced in #7539) that silently skipped the 8 sibling Heart unit tests in CI, and repair the "isActive rejects" test that stopped passing while it was skipped (the timer callback's rejection handler runs on the microtask queue; the assertion ran first). - Convert 16 one-shot `page.isVisible()` reads in the e2e suite to web-first `await expect(locator).toBeVisible()/.not.toBeVisible()` — the one-shot form resolves immediately with no auto-retry. - Add the missing matcher to four `expect(await page.isVisible(...))` calls in login.test.ts that asserted nothing, and to a dangling `getByText()` locator in extensions.test.ts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6fd40c0 commit ec595ea

7 files changed

Lines changed: 27 additions & 21 deletions

File tree

test/e2e/codeServer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe("code-server", ["--disable-workspace-trust"], {}, () => {
3232

3333
test("should show the Integrated Terminal", async ({ codeServerPage }) => {
3434
await codeServerPage.focusTerminal()
35-
expect(await codeServerPage.page.isVisible("#terminal")).toBe(true)
35+
await expect(codeServerPage.page.locator("#terminal")).toBeVisible()
3636
})
3737

3838
test("should open a file", async ({ codeServerPage }) => {

test/e2e/downloads.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe("Downloads (enabled)", ["--disable-workspace-trust"], {}, async () => {
1818
// Action
1919
await codeServerPage.openContextMenu("text=unique-file.txt")
2020

21-
expect(await codeServerPage.page.isVisible("text=Download...")).toBe(true)
21+
await expect(codeServerPage.page.locator("text=Download...")).toBeVisible()
2222
})
2323

2424
test("should see the 'Show Local' button on Save As", async ({ codeServerPage }) => {
@@ -37,7 +37,7 @@ describe("Downloads (enabled)", ["--disable-workspace-trust"], {}, async () => {
3737
await codeServerPage.page.keyboard.type("Making some edits.")
3838
await codeServerPage.navigateMenus(["File", "Save As..."])
3939
await codeServerPage.page.waitForSelector(".quick-input-widget")
40-
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(true)
40+
await expect(codeServerPage.page.locator("text=Show Local")).toBeVisible()
4141
})
4242

4343
test("should see the 'Show Local' button on Save File", async ({ codeServerPage }) => {
@@ -46,14 +46,14 @@ describe("Downloads (enabled)", ["--disable-workspace-trust"], {}, async () => {
4646
await codeServerPage.waitForTab("Untitled-1")
4747
await codeServerPage.navigateMenus(["File", "Save"])
4848
await codeServerPage.page.waitForSelector(".quick-input-widget")
49-
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(true)
49+
await expect(codeServerPage.page.locator("text=Show Local")).toBeVisible()
5050
})
5151

5252
test("should see the 'Show Local' button on Save Workspace As", async ({ codeServerPage }) => {
5353
// Action
5454
await codeServerPage.navigateMenus(["File", "Save Workspace As..."])
5555
await codeServerPage.page.waitForSelector(".quick-input-widget")
56-
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(true)
56+
await expect(codeServerPage.page.locator("text=Show Local")).toBeVisible()
5757
})
5858
})
5959

@@ -72,7 +72,7 @@ describe("Downloads (disabled)", ["--disable-workspace-trust", "--disable-file-d
7272
// Action
7373
await codeServerPage.openContextMenu("text=unique-file.txt")
7474

75-
expect(await codeServerPage.page.isVisible("text=Download...")).toBe(false)
75+
await expect(codeServerPage.page.locator("text=Download...")).not.toBeVisible()
7676
})
7777

7878
test("should not see the 'Show Local' button on Save as", async ({ codeServerPage }) => {
@@ -87,7 +87,7 @@ describe("Downloads (disabled)", ["--disable-workspace-trust", "--disable-file-d
8787
await codeServerPage.openFile(fileName)
8888
await codeServerPage.page.click(".tab")
8989
await codeServerPage.navigateMenus(["File", "Save As..."])
90-
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(false)
90+
await expect(codeServerPage.page.locator("text=Show Local")).not.toBeVisible()
9191
})
9292

9393
test("should not see the 'Show Local' button on Save File", async ({ codeServerPage }) => {
@@ -96,13 +96,13 @@ describe("Downloads (disabled)", ["--disable-workspace-trust", "--disable-file-d
9696
await codeServerPage.waitForTab("Untitled-1")
9797
await codeServerPage.navigateMenus(["File", "Save"])
9898
await codeServerPage.page.waitForSelector(".quick-input-widget")
99-
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(false)
99+
await expect(codeServerPage.page.locator("text=Show Local")).not.toBeVisible()
100100
})
101101

102102
test("should not see the 'Show Local' button on Save Workspace As", async ({ codeServerPage }) => {
103103
// Action
104104
await codeServerPage.navigateMenus(["File", "Save Workspace As..."])
105105
await codeServerPage.page.waitForSelector(".quick-input-widget")
106-
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(false)
106+
await expect(codeServerPage.page.locator("text=Show Local")).not.toBeVisible()
107107
})
108108
})

test/e2e/extensions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function runTestExtensionTests() {
1313

1414
// Remove end slash in address.
1515
const normalizedAddress = address.replace(/\/+$/, "")
16-
await codeServerPage.page.getByText(`Info: proxyUri: ${normalizedAddress}/proxy/{{port}}/`)
16+
await expect(codeServerPage.page.getByText(`Info: proxyUri: ${normalizedAddress}/proxy/{{port}}/`)).toBeVisible()
1717
})
1818
}
1919

test/e2e/github.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (process.env.GITHUB_TOKEN) {
1212
await codeServerPage.page.click("text=Allow")
1313
// It should ask to select an account, one of which will be the one we
1414
// pre-injected.
15-
expect(await codeServerPage.page.isVisible("text=Select an account")).toBe(false)
15+
await expect(codeServerPage.page.locator("text=Select an account")).not.toBeVisible()
1616
})
1717
})
1818

@@ -26,7 +26,7 @@ if (process.env.GITHUB_TOKEN) {
2626
await codeServerPage.page.click("text=Allow")
2727
// Since there is no account it will ask directly for the token (because
2828
// we are on localhost; otherwise it would initiate the oauth flow).
29-
expect(await codeServerPage.page.isVisible("text=GitHub Personal Access Token")).toBe(false)
29+
await expect(codeServerPage.page.locator("text=GitHub Personal Access Token")).not.toBeVisible()
3030
})
3131
})
3232
} else {

test/e2e/login.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("login", ["--disable-workspace-trust", "--auth", "password"], {}, () =>
2525
// Click the submit button and login
2626
await codeServerPage.page.click(".submit")
2727
await codeServerPage.page.waitForLoadState("networkidle")
28-
expect(await codeServerPage.page.isVisible("text=Missing password"))
28+
await expect(codeServerPage.page.locator("text=Missing password")).toBeVisible()
2929
})
3030

3131
test("should see an error message for incorrect password", async ({ codeServerPage }) => {
@@ -34,7 +34,7 @@ describe("login", ["--disable-workspace-trust", "--auth", "password"], {}, () =>
3434
// Click the submit button and login
3535
await codeServerPage.page.click(".submit")
3636
await codeServerPage.page.waitForLoadState("networkidle")
37-
expect(await codeServerPage.page.isVisible("text=Incorrect password"))
37+
await expect(codeServerPage.page.locator("text=Incorrect password")).toBeVisible()
3838
})
3939

4040
test("should hit the rate limiter for too many unsuccessful logins", async ({ codeServerPage }) => {
@@ -49,13 +49,13 @@ describe("login", ["--disable-workspace-trust", "--auth", "password"], {}, () =>
4949
await codeServerPage.page.waitForLoadState("networkidle")
5050
// We double-check that the correct error message shows
5151
// which should be for incorrect password
52-
expect(await codeServerPage.page.isVisible("text=Incorrect password"))
52+
await expect(codeServerPage.page.locator("text=Incorrect password")).toBeVisible()
5353
}
5454

5555
// The 15th should fail for a different reason:
5656
// login rate
5757
await codeServerPage.page.click(".submit")
5858
await codeServerPage.page.waitForLoadState("networkidle")
59-
expect(await codeServerPage.page.isVisible("text=Login rate limited!"))
59+
await expect(codeServerPage.page.locator("text=Login rate limited!")).toBeVisible()
6060
})
6161
})

test/e2e/uploads.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ describe("Uploads (enabled)", ["--disable-workspace-trust"], {}, () => {
1818
// Action
1919
await codeServerPage.openContextMenu('span:has-text("test-directory")')
2020

21-
expect(await codeServerPage.page.isVisible("text=Upload...")).toBe(true)
21+
await expect(codeServerPage.page.locator("text=Upload...")).toBeVisible()
2222
})
2323

2424
test("should see the 'Show Local' button on Open File", async ({ codeServerPage }) => {
2525
// Action
2626
await codeServerPage.navigateMenus(["File", "Open File..."])
2727
await codeServerPage.page.waitForSelector(".quick-input-widget")
28-
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(true)
28+
await expect(codeServerPage.page.locator("text=Show Local")).toBeVisible()
2929
})
3030
})
3131

@@ -44,13 +44,13 @@ describe("Uploads (disabled)", ["--disable-workspace-trust", "--disable-file-upl
4444
// Action
4545
await codeServerPage.openContextMenu('span:has-text("test-directory")')
4646

47-
expect(await codeServerPage.page.isVisible("text=Upload...")).toBe(false)
47+
await expect(codeServerPage.page.locator("text=Upload...")).not.toBeVisible()
4848
})
4949

5050
test("should not see the 'Show Local' button on Open File", async ({ codeServerPage }) => {
5151
// Action
5252
await codeServerPage.navigateMenus(["File", "Open File..."])
5353
await codeServerPage.page.waitForSelector(".quick-input-widget")
54-
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(false)
54+
await expect(codeServerPage.page.locator("text=Show Local")).not.toBeVisible()
5555
})
5656
})

test/unit/node/heart.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ describe("heartbeatTimer", () => {
115115
const heart = new Heart(`${testDir}/shutdown.txt`, mockIsActive)
116116
await heart.beat()
117117
jest.advanceTimersByTime(60 * 1000)
118+
// advanceTimersByTime fires the timer callback synchronously, but the
119+
// callback awaits isActive() — drain the microtask queue so its rejection
120+
// handler (which logs the warning) actually runs before we assert.
121+
await Promise.resolve()
122+
await Promise.resolve()
123+
await Promise.resolve()
118124

119125
expect(mockIsActive).toHaveBeenCalled()
120126
expect(logger.warn).toHaveBeenCalledWith(errorMsg)
@@ -147,7 +153,7 @@ describe("stateChange", () => {
147153

148154
expect(mockOnChange.mock.calls[0][0]).toBe("alive")
149155
})
150-
it.only("should change to expired when not active", async () => {
156+
it("should change to expired when not active", async () => {
151157
jest.useFakeTimers()
152158
heart = new Heart(`${testDir}/shutdown.txt`, () => new Promise((resolve) => resolve(false)))
153159
const mockOnChange = jest.fn()

0 commit comments

Comments
 (0)