2022-04-22 09:49:26 -04:00
|
|
|
const MOCK_DELAY = 1000
|
|
|
|
|
|
|
|
const fakeUsersData = [
|
|
|
|
{
|
|
|
|
affiliation: {
|
|
|
|
institution: {
|
|
|
|
confirmed: true,
|
|
|
|
name: 'Overleaf',
|
|
|
|
},
|
|
|
|
licence: 'pro_plus',
|
|
|
|
},
|
|
|
|
confirmedAt: '2022-03-09T10:59:44.139Z',
|
|
|
|
email: 'foo@overleaf.com',
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
confirmedAt: '2022-03-10T10:59:44.139Z',
|
|
|
|
email: 'bar@overleaf.com',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
affiliation: {
|
|
|
|
institution: {
|
|
|
|
confirmed: true,
|
|
|
|
name: 'Overleaf',
|
|
|
|
},
|
|
|
|
licence: 'pro_plus',
|
|
|
|
department: 'Art & Art History',
|
|
|
|
role: 'Postdoc',
|
|
|
|
},
|
|
|
|
email: 'baz@overleaf.com',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
email: 'qux@overleaf.com',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2022-04-27 04:42:48 -04:00
|
|
|
const fakeInstitutions = [
|
|
|
|
{ id: 9326, name: 'Unknown', country_code: 'al', departments: [] },
|
|
|
|
]
|
|
|
|
|
2022-04-27 12:13:17 -04:00
|
|
|
const fakeInstitutionDomain = [
|
|
|
|
{
|
|
|
|
university: {
|
|
|
|
id: 1234,
|
|
|
|
ssoEnabled: true,
|
|
|
|
name: 'Auto Complete University',
|
|
|
|
},
|
|
|
|
hostname: 'autocomplete.edu',
|
|
|
|
confirmed: true,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2022-04-22 09:49:26 -04:00
|
|
|
export function defaultSetupMocks(fetchMock) {
|
|
|
|
fetchMock
|
|
|
|
.get(/\/user\/emails/, fakeUsersData, { delay: MOCK_DELAY })
|
2022-04-27 04:42:48 -04:00
|
|
|
.get(/\/institutions\/list/, fakeInstitutions, { delay: MOCK_DELAY })
|
2022-04-27 12:13:17 -04:00
|
|
|
.get(/\/institutions\/domains/, fakeInstitutionDomain)
|
2022-04-22 09:49:26 -04:00
|
|
|
.post(/\/user\/emails\/*/, 200, {
|
|
|
|
delay: MOCK_DELAY,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function errorsMocks(fetchMock) {
|
|
|
|
fetchMock
|
|
|
|
.get(/\/user\/emails/, fakeUsersData, { delay: MOCK_DELAY })
|
|
|
|
.post(/\/user\/emails\/*/, 500)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setDefaultMeta() {
|
|
|
|
window.metaAttributesCache = window.metaAttributesCache || new Map()
|
|
|
|
window.metaAttributesCache.set('ol-ExposedSettings', {
|
|
|
|
hasAffiliationsFeature: true,
|
2022-04-27 12:13:17 -04:00
|
|
|
hasSamlFeature: true,
|
|
|
|
samlInitPath: 'saml/init',
|
2022-04-22 09:49:26 -04:00
|
|
|
})
|
|
|
|
}
|