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:
@ -67,6 +67,8 @@ describe("parser", () => {
|
||||
|
||||
"1",
|
||||
"--verbose",
|
||||
["--app-name", "custom instance name"],
|
||||
["--welcome-text", "welcome to code"],
|
||||
"2",
|
||||
|
||||
["--locale", "ja"],
|
||||
@ -123,6 +125,8 @@ describe("parser", () => {
|
||||
socket: path.resolve("mumble"),
|
||||
"socket-mode": "777",
|
||||
verbose: true,
|
||||
"app-name": "custom instance name",
|
||||
"welcome-text": "welcome to code",
|
||||
version: true,
|
||||
"bind-addr": "192.169.0.1:8080",
|
||||
})
|
||||
|
@ -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