2022-04-22 09:49:26 -04:00
|
|
|
const MOCK_DELAY = 1000
|
|
|
|
|
|
|
|
const fakeUsersData = [
|
|
|
|
{
|
|
|
|
affiliation: {
|
|
|
|
institution: {
|
|
|
|
confirmed: true,
|
2022-04-29 07:09:53 -04:00
|
|
|
id: 1,
|
2022-04-22 09:49:26 -04:00
|
|
|
name: 'Overleaf',
|
|
|
|
},
|
|
|
|
licence: 'pro_plus',
|
|
|
|
},
|
|
|
|
confirmedAt: '2022-03-09T10:59:44.139Z',
|
|
|
|
email: 'foo@overleaf.com',
|
|
|
|
default: true,
|
2022-05-18 09:45:31 -04:00
|
|
|
emailHasInstitutionLicence: true,
|
2022-04-22 09:49:26 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
confirmedAt: '2022-03-10T10:59:44.139Z',
|
|
|
|
email: 'bar@overleaf.com',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
affiliation: {
|
|
|
|
institution: {
|
|
|
|
confirmed: true,
|
2022-04-29 07:09:53 -04:00
|
|
|
id: 2,
|
2022-04-22 09:49:26 -04:00
|
|
|
name: 'Overleaf',
|
|
|
|
},
|
|
|
|
licence: 'pro_plus',
|
|
|
|
department: 'Art & Art History',
|
|
|
|
role: 'Postdoc',
|
|
|
|
},
|
|
|
|
email: 'baz@overleaf.com',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
email: 'qux@overleaf.com',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
]
|
2022-05-31 08:06:28 -04:00
|
|
|
const fakeReconfirmationUsersData = [
|
|
|
|
{
|
|
|
|
affiliation: {
|
|
|
|
institution: {
|
|
|
|
confirmed: true,
|
|
|
|
isUniversity: true,
|
|
|
|
id: 4,
|
|
|
|
name: 'Reconfirmable Email Highlighted',
|
|
|
|
},
|
|
|
|
licence: 'pro_plus',
|
|
|
|
inReconfirmNotificationPeriod: true,
|
|
|
|
},
|
|
|
|
email: 'reconfirmation-highlighted@overleaf.com',
|
|
|
|
confirmedAt: '2022-03-09T10:59:44.139Z',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
affiliation: {
|
|
|
|
institution: {
|
|
|
|
confirmed: true,
|
|
|
|
isUniversity: true,
|
|
|
|
id: 4,
|
|
|
|
name: 'Reconfirmable Emails Primary',
|
|
|
|
},
|
|
|
|
licence: 'pro_plus',
|
|
|
|
inReconfirmNotificationPeriod: true,
|
|
|
|
},
|
|
|
|
email: 'reconfirmation-nonsso@overleaf.com',
|
|
|
|
confirmedAt: '2022-03-09T10:59:44.139Z',
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
affiliation: {
|
|
|
|
institution: {
|
|
|
|
confirmed: true,
|
|
|
|
ssoEnabled: true,
|
|
|
|
isUniversity: true,
|
|
|
|
id: 3,
|
|
|
|
name: 'Reconfirmable SSO',
|
|
|
|
},
|
|
|
|
licence: 'pro_plus',
|
|
|
|
inReconfirmNotificationPeriod: true,
|
|
|
|
},
|
|
|
|
email: 'reconfirmation-sso@overleaf.com',
|
|
|
|
confirmedAt: '2022-03-09T10:59:44.139Z',
|
|
|
|
samlProviderId: 'reconfirmation-sso-provider-id',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
affiliation: {
|
|
|
|
institution: {
|
|
|
|
confirmed: true,
|
|
|
|
isUniversity: true,
|
|
|
|
ssoEnabled: true,
|
|
|
|
id: 5,
|
|
|
|
name: 'Reconfirmed SSO',
|
|
|
|
},
|
|
|
|
licence: 'pro_plus',
|
|
|
|
},
|
|
|
|
confirmedAt: '2022-03-09T10:59:44.139Z',
|
|
|
|
email: 'sso@overleaf.com',
|
|
|
|
samlProviderId: 'sso-reconfirmed-provider-id',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
]
|
2022-04-22 09:49:26 -04:00
|
|
|
|
2022-04-27 04:42:48 -04:00
|
|
|
const fakeInstitutions = [
|
2022-04-29 07:09:53 -04:00
|
|
|
{
|
|
|
|
id: 9326,
|
|
|
|
name: 'Unknown',
|
|
|
|
country_code: 'al',
|
|
|
|
departments: ['New department'],
|
|
|
|
},
|
2022-04-27 04:42:48 -04:00
|
|
|
]
|
2022-04-29 07:09:53 -04:00
|
|
|
const fakeInstitution = {
|
|
|
|
id: 123,
|
|
|
|
name: 'test',
|
|
|
|
country_code: 'de',
|
|
|
|
departments: [],
|
|
|
|
team_id: null,
|
|
|
|
}
|
|
|
|
const bazFakeInstitution = {
|
|
|
|
id: 2,
|
|
|
|
name: 'Baz',
|
|
|
|
country_code: 'de',
|
|
|
|
departments: ['Custom department 1', 'Custom department 2'],
|
|
|
|
team_id: null,
|
|
|
|
}
|
2022-04-27 04:42:48 -04:00
|
|
|
|
2022-05-16 04:03:04 -04:00
|
|
|
const fakeInstitutionDomain1 = [
|
2022-04-27 12:13:17 -04:00
|
|
|
{
|
|
|
|
university: {
|
|
|
|
id: 1234,
|
|
|
|
ssoEnabled: true,
|
|
|
|
name: 'Auto Complete University',
|
|
|
|
},
|
|
|
|
hostname: 'autocomplete.edu',
|
|
|
|
confirmed: true,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2022-05-16 04:03:04 -04:00
|
|
|
const fakeInstitutionDomain2 = [
|
|
|
|
{
|
|
|
|
university: {
|
|
|
|
id: 5678,
|
|
|
|
ssoEnabled: false,
|
|
|
|
name: 'Fake Auto Complete University',
|
|
|
|
},
|
|
|
|
hostname: 'fake-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-29 07:09:53 -04:00
|
|
|
.get(/\/institutions\/list\/2/, bazFakeInstitution, { delay: MOCK_DELAY })
|
|
|
|
.get(/\/institutions\/list\/\d+/, fakeInstitution, { delay: MOCK_DELAY })
|
|
|
|
.get(/\/institutions\/list\?country_code=.*/, fakeInstitutions, {
|
|
|
|
delay: MOCK_DELAY,
|
|
|
|
})
|
2022-05-16 04:03:04 -04:00
|
|
|
.get(/\/institutions\/domains\?hostname=a/, fakeInstitutionDomain1)
|
|
|
|
.get(/\/institutions\/domains\?hostname=f/, fakeInstitutionDomain2)
|
2022-05-24 03:47:08 -04:00
|
|
|
.get(/\/institutions\/domains/, [])
|
2022-04-22 09:49:26 -04:00
|
|
|
.post(/\/user\/emails\/*/, 200, {
|
|
|
|
delay: MOCK_DELAY,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-05-31 08:06:28 -04:00
|
|
|
export function reconfirmationSetupMocks(fetchMock) {
|
|
|
|
defaultSetupMocks(fetchMock)
|
|
|
|
fetchMock.get(/\/user\/emails/, fakeReconfirmationUsersData, {
|
|
|
|
delay: MOCK_DELAY,
|
|
|
|
overwriteRoutes: true,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-04-22 09:49:26 -04:00
|
|
|
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', {
|
2022-04-27 12:13:42 -04:00
|
|
|
...window.metaAttributesCache.get('ol-ExposedSettings'),
|
2022-04-22 09:49:26 -04:00
|
|
|
hasAffiliationsFeature: true,
|
2022-04-27 12:13:17 -04:00
|
|
|
hasSamlFeature: true,
|
|
|
|
samlInitPath: 'saml/init',
|
2022-04-22 09:49:26 -04:00
|
|
|
})
|
2022-05-18 09:45:31 -04:00
|
|
|
localStorage.setItem(
|
|
|
|
'showInstitutionalLeaversSurveyUntil',
|
|
|
|
(Date.now() - 1000 * 60 * 60).toString()
|
|
|
|
)
|
2022-04-22 09:49:26 -04:00
|
|
|
}
|
2022-05-31 08:06:28 -04:00
|
|
|
|
|
|
|
export function setReconfirmationMeta() {
|
|
|
|
setDefaultMeta()
|
|
|
|
window.metaAttributesCache.set(
|
|
|
|
'ol-reconfirmationRemoveEmail',
|
|
|
|
'reconfirmation-highlighted@overleaf.com'
|
|
|
|
)
|
|
|
|
window.metaAttributesCache.set(
|
|
|
|
'ol-reconfirmedViaSAML',
|
|
|
|
'sso-reconfirmed-provider-id'
|
|
|
|
)
|
|
|
|
}
|