Skip to content

Commit

Permalink
Added test to Login.test.tsx
Browse files Browse the repository at this point in the history
will now check whether the modal shows if multiple accounts are set.
  • Loading branch information
Anton Schwarz committed Jul 12, 2023
1 parent 67b625e commit 411d2d9
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/component/Login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ describe("Login Page Test", () => {
}
x509SessionHandler = {(authViewModel) => {}}
/>))
expect(screen.queryByRole("dialog", {name: /Multiaccount Modal/})).not.toBeInTheDocument()
const userPassButton = screen.getByRole('button', {name: /Userpass/})
fireEvent.click(userPassButton)
const loginButton = screen.getByRole('button', {name: /Login/})
Expand All @@ -176,6 +177,48 @@ describe("Login Page Test", () => {
expect(alert.textContent).toContain("Invalid Credentials")
})

it('test if modal will show if user has multiple accounts', async () => {
const loginViewModel: LoginViewModel = {
x509Enabled: true,
oidcEnabled: false,
oidcProviders: getSampleOIDCProviders(),
multiVOEnabled: true,
voList: getSampleVOs(),
isLoggedIn: false,
status: "success",
rucioAuthHost: "https://rucio-auth.cern.ch",
}
const authViewModel: AuthViewModel = {
status: "success",
message: "",
rucioAccount: "",
rucioMultiAccount: "account1,account2",
rucioAuthType: "",
rucioAuthToken: "",
rucioIdentity: "",
rucioAuthTokenExpires: "",
role: undefined,
}
await act( async () => render(<LoginStory
loginViewModel={loginViewModel}
authViewModel={authViewModel}
userPassSubmitHandler = {() => {}}
oidcSubmitHandler = {() => {}}
x509SubmitHandler = {() => {
return Promise.resolve(authViewModel)}
}
x509SessionHandler = {(authViewModel) => {}}
/>))


const userPassButton = screen.getByRole('button', {name: /Userpass/})
fireEvent.click(userPassButton)
const loginButton = screen.getByRole('button', {name: /Login/})
fireEvent.click(loginButton)
const modal = screen.getByRole("dialog", {name: /Multiaccount Modal/})
expect(modal).toBeInTheDocument()
})

it('should show error alert if login fails, user closes alert, and login fails again', async () => {
const loginViewModel: LoginViewModel = {
x509Enabled: true,
Expand Down

0 comments on commit 411d2d9

Please sign in to comment.