Skip to content

Commit

Permalink
MOBILE-4201 login: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Sep 8, 2023
1 parent 9c2133b commit 05a5472
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 49 additions & 1 deletion src/core/features/login/tests/credentials.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { CoreSites } from '@services/sites';
import { Http } from '@singletons';
import { of } from 'rxjs';
import { CoreLoginHelper } from '../services/login-helper';
import { CoreConstants } from '@/core/constants';

describe('Credentials page', () => {

Expand Down Expand Up @@ -54,6 +55,28 @@ describe('Credentials page', () => {
maintenancemessage: '',
typeoflogin: 1,
}),
checkSite: async () => ({
code: 0,
siteUrl,
service: CoreConstants.CONFIG.wsservice,
config: ({
wwwroot: siteUrl,
httpswwwroot: siteUrl,
sitename: 'Example Campus',
guestlogin: 0,
rememberusername: 0,
authloginviaemail: 0,
registerauth: '',
forgottenpasswordurl: '',
authinstructions: '',
authnoneenabled: 0,
enablewebservices: 1,
enablemobilewebservice: 1,
maintenanceenabled: 0,
maintenancemessage: '',
typeoflogin: 1,
}),
}),
});

mockSingleton(CoreLoginHelper, { getAvailableSites: async () => [{ url: siteUrl, name: 'Example Campus' }] });
Expand All @@ -72,6 +95,30 @@ describe('Credentials page', () => {
});

it('suggests contacting support after multiple failed attempts', async () => {

const siteCheck = {
code: 0,
siteUrl,
service: CoreConstants.CONFIG.wsservice,
config: ({
wwwroot: siteUrl,
httpswwwroot: siteUrl,
sitename: 'Example Campus',
guestlogin: 0,
rememberusername: 0,
authloginviaemail: 0,
registerauth: '',
forgottenpasswordurl: '',
authinstructions: '',
authnoneenabled: 0,
enablewebservices: 1,
enablemobilewebservice: 1,
maintenanceenabled: 0,
maintenancemessage: '',
typeoflogin: 1,
supportpage: '',
}),
};
// Arrange.
mockSingleton(CoreSites, {
getUserToken: () => {
Expand All @@ -80,12 +127,13 @@ describe('Credentials page', () => {
errorcode: 'invalidlogin',
});
},
checkSite: async () => (siteCheck),
});

mockSingleton(CoreLoginHelper, { getAvailableSites: async () => [] });

const fixture = await renderPageComponent(CoreLoginCredentialsPage, {
routeParams: { siteUrl, siteConfig: { supportpage: '' } },
routeParams: { siteUrl, siteCheck },
imports: [CoreSharedModule, CoreLoginComponentsModule],
});

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 05a5472

Please sign in to comment.