feat: add customization options for the login page (#5633)
* add customization options for the login page * add unit tests * add test for correct welcome text when none is set but app-name is Signed-off-by: niwla23 <46248939+niwla23@users.noreply.github.com> * add test for no app-name set and check in title too Signed-off-by: niwla23 <46248939+niwla23@users.noreply.github.com> Signed-off-by: niwla23 <46248939+niwla23@users.noreply.github.com> Co-authored-by: Joe Previte <jjprevite@gmail.com>
This commit is contained in:
@ -92,5 +92,51 @@ describe("login", () => {
|
||||
|
||||
expect(htmlContent).toContain("Incorrect password")
|
||||
})
|
||||
|
||||
it("should return correct app-name", async () => {
|
||||
process.env.PASSWORD = previousEnvPassword
|
||||
const appName = "testnäme"
|
||||
const codeServer = await integration.setup([`--app-name=${appName}`], "")
|
||||
const resp = await codeServer.fetch("/login", { method: "GET" })
|
||||
|
||||
const htmlContent = await resp.text()
|
||||
expect(resp.status).toBe(200)
|
||||
expect(htmlContent).toContain(`${appName}</h1>`)
|
||||
expect(htmlContent).toContain(`<title>${appName} login</title>`)
|
||||
})
|
||||
|
||||
it("should return correct app-name when unset", async () => {
|
||||
process.env.PASSWORD = previousEnvPassword
|
||||
const appName = "code-server"
|
||||
const codeServer = await integration.setup([], "")
|
||||
const resp = await codeServer.fetch("/login", { method: "GET" })
|
||||
|
||||
const htmlContent = await resp.text()
|
||||
expect(resp.status).toBe(200)
|
||||
expect(htmlContent).toContain(`${appName}</h1>`)
|
||||
expect(htmlContent).toContain(`<title>${appName} login</title>`)
|
||||
})
|
||||
|
||||
it("should return correct welcome text", async () => {
|
||||
process.env.PASSWORD = previousEnvPassword
|
||||
const welcomeText = "Welcome to your code workspace! öäü🔐"
|
||||
const codeServer = await integration.setup([`--welcome-text=${welcomeText}`], "")
|
||||
const resp = await codeServer.fetch("/login", { method: "GET" })
|
||||
|
||||
const htmlContent = await resp.text()
|
||||
expect(resp.status).toBe(200)
|
||||
expect(htmlContent).toContain(welcomeText)
|
||||
})
|
||||
|
||||
it("should return correct welcome text when none is set but app-name is", async () => {
|
||||
process.env.PASSWORD = previousEnvPassword
|
||||
const appName = "testnäme"
|
||||
const codeServer = await integration.setup([`--app-name=${appName}`], "")
|
||||
const resp = await codeServer.fetch("/login", { method: "GET" })
|
||||
|
||||
const htmlContent = await resp.text()
|
||||
expect(resp.status).toBe(200)
|
||||
expect(htmlContent).toContain(`Welcome to ${appName}`)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user