Skip to content

Commit 475b2bf

Browse files
committed
Fixed and added LoginPage test
1 parent 9480f8e commit 475b2bf

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

site/src/pages/LoginPage/LoginPage.test.tsx

+29-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe("LoginPage", () => {
9898
render(<LoginPage />)
9999

100100
// Then
101-
await screen.findByText(Language.passwordSignIn)
101+
expect(await screen.queryByText(Language.passwordSignIn)).not.toBeInTheDocument()
102102
await screen.findByText(Language.githubSignIn)
103103
})
104104

@@ -121,4 +121,32 @@ describe("LoginPage", () => {
121121
// Then
122122
await screen.findByText("Setup")
123123
})
124+
125+
it("hides password authentication if OIDC/GitHub is enabled and displays on click", async () => {
126+
const authMethods: TypesGen.AuthMethods = {
127+
password: { enabled: true },
128+
github: { enabled: true },
129+
oidc: { enabled: true, signInText: "", iconUrl: "" },
130+
}
131+
132+
// Given
133+
server.use(
134+
rest.get("/api/v2/users/authmethods", async (req, res, ctx) => {
135+
return res(ctx.status(200), ctx.json(authMethods))
136+
}),
137+
)
138+
139+
// When
140+
render(<LoginPage />)
141+
142+
// Then
143+
expect(await screen.queryByText(Language.passwordSignIn)).not.toBeInTheDocument()
144+
await screen.findByText(Language.githubSignIn)
145+
146+
const showPasswordAuthLink = screen.getByText("Show password login")
147+
await userEvent.click(showPasswordAuthLink);
148+
149+
await screen.findByText(Language.passwordSignIn)
150+
await screen.findByText(Language.githubSignIn)
151+
})
124152
})

0 commit comments

Comments
 (0)