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
99 lines
2.9 KiB
TypeScript
99 lines
2.9 KiB
TypeScript
import { expect } from 'chai'
|
|
import { screen, render } from '@testing-library/react'
|
|
import fetchMock from 'fetch-mock'
|
|
import LinkingSection from '@/features/settings/components/linking-section'
|
|
import { UserProvider } from '@/shared/context/user-context'
|
|
import { SSOProvider } from '@/features/settings/context/sso-context'
|
|
import { SplitTestProvider } from '@/shared/context/split-test-context'
|
|
|
|
function renderSectionWithProviders() {
|
|
render(<LinkingSection />, {
|
|
wrapper: ({ children }) => (
|
|
<SplitTestProvider>
|
|
<UserProvider>
|
|
<SSOProvider>{children}</SSOProvider>
|
|
</UserProvider>
|
|
</SplitTestProvider>
|
|
),
|
|
})
|
|
}
|
|
|
|
const mockOauthProviders = {
|
|
google: {
|
|
descriptionKey: 'login_with_service',
|
|
descriptionOptions: { service: 'Google' },
|
|
name: 'Google',
|
|
linkPath: '/auth/google',
|
|
},
|
|
orcid: {
|
|
descriptionKey: 'oauth_orcid_description',
|
|
descriptionOptions: {
|
|
link: '/blog/434',
|
|
appName: 'Overleaf',
|
|
},
|
|
name: 'ORCID',
|
|
linkPath: '/auth/orcid',
|
|
},
|
|
}
|
|
|
|
describe('<LinkingSection />', function () {
|
|
beforeEach(function () {
|
|
window.metaAttributesCache.set('ol-user', {})
|
|
|
|
// suppress integrations and references widgets as they cannot be tested in
|
|
// all environments
|
|
window.metaAttributesCache.set('ol-hideLinkingWidgets', true)
|
|
|
|
window.metaAttributesCache.set('ol-thirdPartyIds', {
|
|
google: 'google-id',
|
|
})
|
|
|
|
window.metaAttributesCache.set('ol-oauthProviders', mockOauthProviders)
|
|
})
|
|
|
|
afterEach(function () {
|
|
fetchMock.removeRoutes().clearHistory()
|
|
})
|
|
|
|
it('shows header', async function () {
|
|
renderSectionWithProviders()
|
|
|
|
screen.getByText('Integrations')
|
|
screen.getByText(
|
|
'You can link your Overleaf account with other services to enable the features described below.'
|
|
)
|
|
})
|
|
|
|
it('lists SSO providers', async function () {
|
|
renderSectionWithProviders()
|
|
screen.getByText('Linked accounts')
|
|
|
|
screen.getByText('Google')
|
|
screen.getByText('Log in with Google.')
|
|
screen.getByRole('button', { name: /unlink/i })
|
|
|
|
screen.getByText('ORCID')
|
|
screen.getByText(
|
|
/Securely establish your identity by linking your ORCID iD/
|
|
)
|
|
const helpLink = screen.getByRole('link', {
|
|
name: /learn more about orcid/i,
|
|
})
|
|
expect(helpLink.getAttribute('href')).to.equal('/blog/434')
|
|
const linkButton = screen.getByRole('link', { name: /link orcid/i })
|
|
expect(linkButton.getAttribute('href')).to.equal('/auth/orcid?intent=link')
|
|
})
|
|
|
|
it('shows SSO error message', async function () {
|
|
window.metaAttributesCache.set('ol-ssoErrorMessage', 'You no SSO')
|
|
renderSectionWithProviders()
|
|
screen.getByText('Error linking account: You no SSO')
|
|
})
|
|
|
|
it('does not show providers section when empty', async function () {
|
|
window.metaAttributesCache.delete('ol-oauthProviders')
|
|
renderSectionWithProviders()
|
|
|
|
expect(screen.queryByText('Linked accounts')).to.not.exist
|
|
})
|
|
})
|