feat: add test/videos & /screenshots to gitignore
This commit is contained in:
parent
236717ee98
commit
ffdbf3a730
2
.gitignore
vendored
2
.gitignore
vendored
@ -16,3 +16,5 @@ node-*
|
|||||||
.home
|
.home
|
||||||
coverage
|
coverage
|
||||||
**/.DS_Store
|
**/.DS_Store
|
||||||
|
test/videos
|
||||||
|
test/screenshots
|
||||||
|
@ -152,7 +152,10 @@
|
|||||||
"<rootDir>/lib/vscode",
|
"<rootDir>/lib/vscode",
|
||||||
"<rootDir>/release-packages",
|
"<rootDir>/release-packages",
|
||||||
"<rootDir>/release",
|
"<rootDir>/release",
|
||||||
"<rootDir>/release-standalone"
|
"<rootDir>/release-standalone",
|
||||||
|
"<rootDir>/release-npm-package",
|
||||||
|
"<rootDir>/release-gcp",
|
||||||
|
"<rootDir>/release-images"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,26 +5,29 @@ describe("login", () => {
|
|||||||
let page: Page
|
let page: Page
|
||||||
let context: BrowserContext
|
let context: BrowserContext
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async (done) => {
|
||||||
browser = await chromium.launch()
|
browser = await chromium.launch()
|
||||||
// Create a new context with the saved storage state
|
// Create a new context with the saved storage state
|
||||||
const storageState = JSON.parse(process.env.STORAGE || "")
|
const storageState = JSON.parse(process.env.STORAGE || "")
|
||||||
context = await browser.newContext({ storageState })
|
context = await browser.newContext({ storageState, recordVideo: { dir: "./test/videos/" } })
|
||||||
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async (done) => {
|
||||||
// Remove password from local storage
|
// Remove password from local storage
|
||||||
await context.clearCookies()
|
await context.clearCookies()
|
||||||
|
|
||||||
await browser.close()
|
await browser.close()
|
||||||
await context.close()
|
await context.close()
|
||||||
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async (done) => {
|
||||||
page = await context.newPage()
|
page = await context.newPage()
|
||||||
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should see a 'Go Home' button in the Application Menu that goes to coder.com", async () => {
|
it("should see a 'Go Home' button in the Application Menu that goes to /healthz", async (done) => {
|
||||||
const GO_HOME_URL = `${process.env.CODE_SERVER_ADDRESS}/healthz`
|
const GO_HOME_URL = `${process.env.CODE_SERVER_ADDRESS}/healthz`
|
||||||
let requestedGoHomeUrl = false
|
let requestedGoHomeUrl = false
|
||||||
page.on("request", (request) => {
|
page.on("request", (request) => {
|
||||||
@ -34,36 +37,43 @@ describe("login", () => {
|
|||||||
// only that it was made
|
// only that it was made
|
||||||
if (request.url() === GO_HOME_URL) {
|
if (request.url() === GO_HOME_URL) {
|
||||||
requestedGoHomeUrl = true
|
requestedGoHomeUrl = true
|
||||||
console.log("woooo =>>>", requestedGoHomeUrl)
|
expect(requestedGoHomeUrl).toBeTruthy()
|
||||||
|
|
||||||
|
// This ensures Jest knows we're done here.
|
||||||
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// Sometimes a dialog shows up when you navigate
|
||||||
|
// asking if you're sure you want to leave
|
||||||
|
// so we listen if it comes, we accept it
|
||||||
|
page.on("dialog", (dialog) => dialog.accept())
|
||||||
|
|
||||||
// waitUntil: "domcontentloaded"
|
// waitUntil: "domcontentloaded"
|
||||||
// In case the page takes a long time to load
|
// In case the page takes a long time to load
|
||||||
await page.goto(process.env.CODE_SERVER_ADDRESS || "http://localhost:8080", { waitUntil: "domcontentloaded" })
|
await page.goto(process.env.CODE_SERVER_ADDRESS || "http://localhost:8080", { waitUntil: "domcontentloaded" })
|
||||||
|
|
||||||
|
// For some odd reason, the login method used in globalSetup.ts
|
||||||
|
// I don't know if it's on playwright clearing our cookies by accident
|
||||||
|
// or if it's our cookies disappearing.
|
||||||
|
// This means we need an additional check to make sure we're logged in
|
||||||
|
// otherwise this test will hang and fail.
|
||||||
|
const currentPageURL = await page.url()
|
||||||
|
const isLoginPage = currentPageURL.includes("login")
|
||||||
|
if (isLoginPage) {
|
||||||
|
await page.fill(".password", process.env.PASSWORD || "password")
|
||||||
|
// Click the submit button and login
|
||||||
|
await page.click(".submit")
|
||||||
|
}
|
||||||
|
|
||||||
// Click the Application menu
|
// Click the Application menu
|
||||||
await page.click(".menubar-menu-button[title='Application Menu']")
|
await page.click(".menubar-menu-button[title='Application Menu']")
|
||||||
// See the Go Home button
|
// See the Go Home button
|
||||||
const goHomeButton = "a.action-menu-item span[aria-label='Go Home']"
|
const goHomeButton = "a.action-menu-item span[aria-label='Go Home']"
|
||||||
expect(await page.isVisible(goHomeButton))
|
expect(await page.isVisible(goHomeButton))
|
||||||
// Click it and navigate to coder.com
|
|
||||||
|
// Click it and navigate to /healthz
|
||||||
// NOTE: ran into issues of it failing intermittently
|
// NOTE: ran into issues of it failing intermittently
|
||||||
// without having button: "middle"
|
// without having button: "middle"
|
||||||
await page.click(goHomeButton, { button: "middle" })
|
await page.click(goHomeButton, { button: "middle" })
|
||||||
|
|
||||||
// If there are unsaved changes it will show a dialog
|
|
||||||
// asking if you're sure you want to leave
|
|
||||||
await page.on("dialog", (dialog) => dialog.accept())
|
|
||||||
|
|
||||||
// If it takes longer than 3 seconds to navigate, something is wrong
|
|
||||||
await page.waitForRequest(GO_HOME_URL, { timeout: 10000 })
|
|
||||||
expect(requestedGoHomeUrl).toBeTruthy()
|
|
||||||
|
|
||||||
// // Make sure the response for GO_HOME_URL was successful
|
|
||||||
// const response = await page.waitForResponse(
|
|
||||||
// (response) => response.url() === GO_HOME_URL && response.status() === 200,
|
|
||||||
// )
|
|
||||||
// We make sure a request was made to the GO_HOME_URL
|
|
||||||
// expect(response.ok()).toBeTruthy()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -24,7 +24,7 @@ describe("login", () => {
|
|||||||
await context.clearCookies()
|
await context.clearCookies()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should be able to login with the password from config.yml", async () => {
|
it("should be able to login", async () => {
|
||||||
await page.goto(process.env.CODE_SERVER_ADDRESS || "http://localhost:8080")
|
await page.goto(process.env.CODE_SERVER_ADDRESS || "http://localhost:8080")
|
||||||
// Type in password
|
// Type in password
|
||||||
await page.fill(".password", process.env.PASSWORD || "password")
|
await page.fill(".password", process.env.PASSWORD || "password")
|
||||||
|
Loading…
Reference in New Issue
Block a user