mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-29 23:00:08 +02:00

* Create decapitalize.sh script * Remove `text-capitalize` classes, rely on translations instead * `Account Linking` -> `Account linking` * `Account Settings` -> `Account settings` * `Add Affiliation` -> `Add affiliation` * `Add Email` -> `Add email` * `Add Files` -> `Add files` * `Add to Dictionary` -> `Add to dictionary` * `All Projects` -> `All projects` * `All Templates` -> `All templates` * `Archive Projects` -> `Archive projects` * `Archived Projects` -> `Archived projects` * `Auto Compile` -> `Auto compile` * `Back to Subscription` -> `Back to subscription` * `Blank Project` -> `Blank project` * `Change Password` -> `Change password` * `Change Project Owner` -> `Change project owner` * `Clear Sessions` -> `Clear sessions` * `Company Name` -> `Company name` * `Compile Error Handling` -> `Compile error handling` * `Compile Mode` -> `Compile mode` * `Compromised Password` -> `Compromised password` * `Confirm Affiliation` -> `Confirm affiliation` * `Confirm Email` -> `Confirm email` * `Connected Users` -> `Connected users` * `Contact Sales` -> `Contact sales` * `Contact Support` -> `Contact support` * `Contact Us` -> `Contact us` * `Copy Project` -> `Copy project` * `Delete Account` -> `Delete account` * `Emails and Affiliations` -> `Emails and affiliations` * `Git Integration` -> `Git integration` * `Group Settings` -> `Group settings` * `Link Accounts` -> `Link accounts` * `Make Primary` -> `Make primary` * `Mendeley Integration` -> `Mendeley integration` * `Papers Integration` -> `Papers integration` * `Project Synchronisation` -> `Project synchronisation` * `Sessions Cleared` -> `Sessions cleared` * `Stop Compilation` -> `Stop compilation` * `Update Account Info` -> `Update account info` * `the Sales team` -> `the sales team` * `your Group settings` -> `your group settings` * `Zotero Integration` -> `Zotero integration` * Update decapitalize.sh * Decapitalize some translations * `Example Project` -> `Example project` * `New Project` -> `New project` * `New Tag` -> `New tag` * `Trashed Projects` -> `Trashed projects` * `Upload Project` -> `Upload project` * `Your Projects` -> `Your projects` * Revert "Create decapitalize.sh script" This reverts commit 8c79f367096c206c704c7c01e3572a18f3961d5e. * Revert changes to stories * Fix tests * `Contact us of` -> `Contact us if` * Make `Contact us` bold in tex files * `sales team` -> `Sales team` * `Link accounts and Add email` -> `Link accounts and add email` * `Make Private` -> `Make private` * `contact support` -> `contact Support` * Make `Make primary` tests case sensitive * Use `add_email` translation string * Revert changes to non-english locales * Remove redundant `Account settings` translation * `New project Name` -> `New project name` GitOrigin-RevId: 675c46f96ddbf3d259a8d723fed62aa4a7ed40b7
121 lines
4 KiB
TypeScript
121 lines
4 KiB
TypeScript
import { render, screen } from '@testing-library/react'
|
|
import { expect } from 'chai'
|
|
import fetchMock from 'fetch-mock'
|
|
import { cloneDeep } from 'lodash'
|
|
import EmailsRow from '../../../../../../frontend/js/features/settings/components/emails/row'
|
|
import {
|
|
professionalUserData,
|
|
unconfirmedUserData,
|
|
} from '../../fixtures/test-user-email-data'
|
|
import { UserEmailData } from '../../../../../../types/user-email'
|
|
import { UserEmailsProvider } from '../../../../../../frontend/js/features/settings/context/user-email-context'
|
|
import { Affiliation } from '../../../../../../types/affiliation'
|
|
import getMeta from '@/utils/meta'
|
|
|
|
function renderEmailsRow(data: UserEmailData) {
|
|
return render(
|
|
<UserEmailsProvider>
|
|
<EmailsRow userEmailData={data} />
|
|
</UserEmailsProvider>
|
|
)
|
|
}
|
|
|
|
function getByTextContent(text: string) {
|
|
return screen.getAllByText(
|
|
(content, node) =>
|
|
content === text || node?.children[0]?.textContent === text
|
|
)
|
|
}
|
|
|
|
describe('<EmailsRow/>', function () {
|
|
beforeEach(function () {
|
|
Object.assign(getMeta('ol-ExposedSettings'), {
|
|
samlInitPath: '/saml',
|
|
hasSamlBeta: true,
|
|
})
|
|
fetchMock.get('/user/emails?ensureAffiliation=true', [])
|
|
})
|
|
|
|
afterEach(function () {
|
|
fetchMock.removeRoutes().clearHistory()
|
|
})
|
|
|
|
describe('with unaffiliated email data', function () {
|
|
it('renders email info', function () {
|
|
renderEmailsRow(unconfirmedUserData)
|
|
screen.getByText('baz@overleaf.com')
|
|
})
|
|
|
|
it('renders actions', function () {
|
|
renderEmailsRow(unconfirmedUserData)
|
|
screen.getByRole('button', { name: 'Make primary' })
|
|
})
|
|
})
|
|
|
|
describe('with affiliated email data', function () {
|
|
it('renders email info', function () {
|
|
renderEmailsRow(professionalUserData)
|
|
screen.getByText('foo@overleaf.com')
|
|
screen.getByText('Primary')
|
|
})
|
|
|
|
it('renders actions', function () {
|
|
renderEmailsRow(professionalUserData)
|
|
screen.getByRole('button', { name: 'Remove' })
|
|
})
|
|
|
|
it('renders institution info', function () {
|
|
renderEmailsRow(professionalUserData)
|
|
screen.getByText('Overleaf')
|
|
screen.getByText('Reader, Art History')
|
|
})
|
|
})
|
|
|
|
describe('with email data affiliated to an institution with SSO available', function () {
|
|
let affiliatedEmail: UserEmailData & { affiliation: Affiliation }
|
|
|
|
beforeEach(function () {
|
|
window.metaAttributesCache.get('ol-ExposedSettings').hasSamlFeature = true
|
|
|
|
// make sure the institution has SSO available
|
|
affiliatedEmail = cloneDeep(professionalUserData)
|
|
affiliatedEmail.affiliation.institution.confirmed = true
|
|
affiliatedEmail.affiliation.institution.isUniversity = true
|
|
affiliatedEmail.affiliation.institution.ssoEnabled = true
|
|
})
|
|
|
|
describe('when the email is not yet linked to the institution', function () {
|
|
beforeEach(async function () {
|
|
fetchMock.removeRoutes().clearHistory()
|
|
fetchMock.get(/\/user\/emails/, [affiliatedEmail, unconfirmedUserData])
|
|
await fetchMock.callHistory.flush(true)
|
|
})
|
|
|
|
it('prompts the user to link to their institutional account', function () {
|
|
renderEmailsRow(affiliatedEmail)
|
|
getByTextContent(
|
|
'You can now link your Overleaf account to your Overleaf institutional account.'
|
|
)
|
|
screen.getByRole('button', { name: 'Link accounts' })
|
|
})
|
|
})
|
|
|
|
describe('when the email is already linked to the institution', function () {
|
|
beforeEach(async function () {
|
|
affiliatedEmail.samlProviderId = '1'
|
|
fetchMock.removeRoutes().clearHistory()
|
|
fetchMock.get(/\/user\/emails/, [affiliatedEmail, unconfirmedUserData])
|
|
await fetchMock.callHistory.flush(true)
|
|
})
|
|
|
|
it('prompts the user to login using their institutional account', function () {
|
|
renderEmailsRow(affiliatedEmail)
|
|
getByTextContent(
|
|
'You can log in to Overleaf through your Overleaf institutional login.'
|
|
)
|
|
expect(screen.queryByRole('button', { name: 'Link accounts' })).to.be
|
|
.null
|
|
})
|
|
})
|
|
})
|
|
})
|