Skip to content

Commit

Permalink
test, components: add test to disable userpass login
Browse files Browse the repository at this point in the history
  • Loading branch information
maany committed Nov 25, 2024
1 parent b67504a commit 7f363ee
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/component/Login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('Login Page Test', () => {
Promise.resolve(
JSON.stringify({
x509Enabled: true,
userpassEnabled: true,
oidcEnabled: true,
oidcProviders: oidcProviders,
multiVOEnabled: true,
Expand Down Expand Up @@ -102,6 +103,7 @@ describe('Login Page Test', () => {
Promise.resolve(
JSON.stringify({
x509Enabled: true,
userpassEnabled: true,
oidcEnabled: false,
oidcProviders: getSampleOIDCProviders(),
multiVOEnabled: true,
Expand All @@ -124,6 +126,7 @@ describe('Login Page Test', () => {
Promise.resolve(
JSON.stringify({
x509Enabled: true,
userpassEnabled: true,
oidcEnabled: false,
oidcProviders: getSampleOIDCProviders(),
multiVOEnabled: true,
Expand All @@ -143,6 +146,7 @@ describe('Login Page Test', () => {
it('should show error message if login fails', async () => {
const loginViewModel: LoginViewModel = {
x509Enabled: true,
userpassEnabled: true,
oidcEnabled: false,
oidcProviders: getSampleOIDCProviders(),
multiVOEnabled: true,
Expand Down Expand Up @@ -193,6 +197,7 @@ describe('Login Page Test', () => {
it('test if modal will show if user has multiple accounts', async () => {
const loginViewModel: LoginViewModel = {
x509Enabled: true,
userpassEnabled: true,
oidcEnabled: false,
oidcProviders: getSampleOIDCProviders(),
multiVOEnabled: true,
Expand Down Expand Up @@ -236,6 +241,7 @@ describe('Login Page Test', () => {
it('should show error alert if login fails, user closes alert, and login fails again', async () => {
const loginViewModel: LoginViewModel = {
x509Enabled: true,
userpassEnabled: true,
oidcEnabled: false,
oidcProviders: getSampleOIDCProviders(),
multiVOEnabled: true,
Expand Down Expand Up @@ -304,4 +310,26 @@ describe('Login Page Test', () => {
// check if Alert is not displayed
expect(alertCollapsible.className).toContain('hidden');
});
it('should not show userpass button if userpass is disabled', async () => {
fetchMock.doMock();
fetchMock.mockIf(/login/, req =>
Promise.resolve(
JSON.stringify({
x509Enabled: true,
userpassEnabled: false,
oidcEnabled: false,
oidcProviders: getSampleOIDCProviders(),
multiVOEnabled: true,
voList: getSampleVOs(),
isLoggedIn: false,
status: 'error',
} as LoginViewModel),
),
);
await act(async () => render(<Login />));

// Check userpass button: 1 piece and collapsed
const userpassButton = screen.queryByRole('button', { name: /Userpass/ });
expect(userpassButton).toBeNull();
});
});

0 comments on commit 7f363ee

Please sign in to comment.