Skip to content

Commit 969e8ba

Browse files
committed
feat: add test/videos & /screenshots to gitignore
1 parent 56aa515 commit 969e8ba

File tree

4 files changed

+39
-24
lines changed

4 files changed

+39
-24
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ node-*
1515
/lib/coder-cloud-agent
1616
.home
1717
coverage
18+
test/videos
19+
test/screenshots

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@
145145
"<rootDir>/lib/vscode",
146146
"<rootDir>/release-packages",
147147
"<rootDir>/release",
148-
"<rootDir>/release-standalone"
148+
"<rootDir>/release-standalone",
149+
"<rootDir>/release-npm-package",
150+
"<rootDir>/release-gcp",
151+
"<rootDir>/release-images"
149152
]
150153
}
151154
}

test/goHome.test.ts

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,29 @@ describe("login", () => {
55
let page: Page
66
let context: BrowserContext
77

8-
beforeAll(async () => {
8+
beforeAll(async (done) => {
99
browser = await chromium.launch()
1010
// Create a new context with the saved storage state
1111
const storageState = JSON.parse(process.env.STORAGE || "")
12-
context = await browser.newContext({ storageState })
12+
context = await browser.newContext({ storageState, recordVideo: { dir: "./test/videos/" } })
13+
done()
1314
})
1415

15-
afterAll(async () => {
16+
afterAll(async (done) => {
1617
// Remove password from local storage
1718
await context.clearCookies()
1819

1920
await browser.close()
2021
await context.close()
22+
done()
2123
})
2224

23-
beforeEach(async () => {
25+
beforeEach(async (done) => {
2426
page = await context.newPage()
27+
done()
2528
})
2629

27-
it("should see a 'Go Home' button in the Application Menu that goes to coder.com", async () => {
30+
it("should see a 'Go Home' button in the Application Menu that goes to /healthz", async (done) => {
2831
const GO_HOME_URL = `${process.env.CODE_SERVER_ADDRESS}/healthz`
2932
let requestedGoHomeUrl = false
3033
page.on("request", (request) => {
@@ -34,36 +37,43 @@ describe("login", () => {
3437
// only that it was made
3538
if (request.url() === GO_HOME_URL) {
3639
requestedGoHomeUrl = true
37-
console.log("woooo =>>>", requestedGoHomeUrl)
40+
expect(requestedGoHomeUrl).toBeTruthy()
41+
42+
// This ensures Jest knows we're done here.
43+
done()
3844
}
3945
})
46+
// Sometimes a dialog shows up when you navigate
47+
// asking if you're sure you want to leave
48+
// so we listen if it comes, we accept it
49+
page.on("dialog", (dialog) => dialog.accept())
4050

4151
// waitUntil: "domcontentloaded"
4252
// In case the page takes a long time to load
4353
await page.goto(process.env.CODE_SERVER_ADDRESS || "http://localhost:8080", { waitUntil: "domcontentloaded" })
54+
55+
// For some odd reason, the login method used in globalSetup.ts
56+
// I don't know if it's on playwright clearing our cookies by accident
57+
// or if it's our cookies disappearing.
58+
// This means we need an additional check to make sure we're logged in
59+
// otherwise this test will hang and fail.
60+
const currentPageURL = await page.url()
61+
const isLoginPage = currentPageURL.includes("login")
62+
if (isLoginPage) {
63+
await page.fill(".password", process.env.PASSWORD || "password")
64+
// Click the submit button and login
65+
await page.click(".submit")
66+
}
67+
4468
// Click the Application menu
4569
await page.click(".menubar-menu-button[title='Application Menu']")
4670
// See the Go Home button
4771
const goHomeButton = "a.action-menu-item span[aria-label='Go Home']"
4872
expect(await page.isVisible(goHomeButton))
49-
// Click it and navigate to coder.com
73+
74+
// Click it and navigate to /healthz
5075
// NOTE: ran into issues of it failing intermittently
5176
// without having button: "middle"
5277
await page.click(goHomeButton, { button: "middle" })
53-
54-
// If there are unsaved changes it will show a dialog
55-
// asking if you're sure you want to leave
56-
await page.on("dialog", (dialog) => dialog.accept())
57-
58-
// If it takes longer than 3 seconds to navigate, something is wrong
59-
await page.waitForRequest(GO_HOME_URL, { timeout: 10000 })
60-
expect(requestedGoHomeUrl).toBeTruthy()
61-
62-
// // Make sure the response for GO_HOME_URL was successful
63-
// const response = await page.waitForResponse(
64-
// (response) => response.url() === GO_HOME_URL && response.status() === 200,
65-
// )
66-
// We make sure a request was made to the GO_HOME_URL
67-
// expect(response.ok()).toBeTruthy()
6878
})
6979
})

test/login.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("login", () => {
2424
await context.clearCookies()
2525
})
2626

27-
it("should be able to login with the password from config.yml", async () => {
27+
it("should be able to login", async () => {
2828
await page.goto(process.env.CODE_SERVER_ADDRESS || "http://localhost:8080")
2929
// Type in password
3030
await page.fill(".password", process.env.PASSWORD || "password")

0 commit comments

Comments
 (0)