notifications.test.tsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. import { expect } from 'chai'
  2. import sinon from 'sinon'
  3. import {
  4. fireEvent,
  5. render,
  6. screen,
  7. waitForElementToBeRemoved,
  8. } from '@testing-library/react'
  9. import fetchMock from 'fetch-mock'
  10. import { merge, cloneDeep } from 'lodash'
  11. import {
  12. professionalUserData,
  13. unconfirmedUserData,
  14. } from '../../settings/fixtures/test-user-email-data'
  15. import {
  16. notification,
  17. notificationsInstitution,
  18. } from '../fixtures/notifications-data'
  19. import Common from '../../../../../frontend/js/features/project-list/components/notifications/groups/common'
  20. import Institution from '../../../../../frontend/js/features/project-list/components/notifications/groups/institution'
  21. import ConfirmEmail from '../../../../../frontend/js/features/project-list/components/notifications/groups/confirm-email'
  22. import ReconfirmationInfo from '../../../../../frontend/js/features/project-list/components/notifications/groups/affiliation/reconfirmation-info'
  23. import { ProjectListProvider } from '../../../../../frontend/js/features/project-list/context/project-list-context'
  24. import {
  25. Notification,
  26. Institution as InstitutionType,
  27. } from '../../../../../types/project/dashboard/notification'
  28. import { DeepPartial } from '../../../../../types/utils'
  29. import { Project } from '../../../../../types/project/dashboard/api'
  30. const renderWithinProjectListProvider = (Component: React.ComponentType) => {
  31. render(<Component />, {
  32. wrapper: ({ children }) => (
  33. <ProjectListProvider>
  34. <ul className="list-unstyled">{children}</ul>
  35. </ProjectListProvider>
  36. ),
  37. })
  38. }
  39. describe('<UserNotifications />', function () {
  40. const exposedSettings = {
  41. samlInitPath: '/fakeSaml/',
  42. appName: 'Overleaf',
  43. }
  44. beforeEach(function () {
  45. window.metaAttributesCache = window.metaAttributesCache || new Map()
  46. fetchMock.reset()
  47. // at least one project is required to show some notifications
  48. const projects = [{}] as Project[]
  49. fetchMock.post(/\/api\/project/, {
  50. status: 200,
  51. body: {
  52. projects,
  53. totalSize: projects.length,
  54. },
  55. })
  56. })
  57. afterEach(function () {
  58. window.metaAttributesCache = new Map()
  59. fetchMock.reset()
  60. })
  61. describe('<Common>', function () {
  62. beforeEach(function () {
  63. window.metaAttributesCache = window.metaAttributesCache || new Map()
  64. window.metaAttributesCache.set('ol-ExposedSettings', exposedSettings)
  65. })
  66. afterEach(function () {
  67. window.metaAttributesCache = new Map()
  68. fetchMock.reset()
  69. })
  70. it('accepts project invite', async function () {
  71. const reconfiguredNotification: DeepPartial<Notification> = {
  72. _id: 1,
  73. templateKey: 'notification_project_invite',
  74. }
  75. window.metaAttributesCache.set('ol-notifications', [
  76. merge(cloneDeep(notification), reconfiguredNotification),
  77. ])
  78. renderWithinProjectListProvider(Common)
  79. await fetchMock.flush(true)
  80. const deleteMock = fetchMock.delete(
  81. `/notifications/${reconfiguredNotification._id}`,
  82. 200
  83. )
  84. const acceptMock = fetchMock.post(
  85. `project/${notification.messageOpts.projectId}/invite/token/${notification.messageOpts.token}/accept`,
  86. 200
  87. )
  88. screen.getByRole('alert')
  89. screen.getByText(/would like you to join/i)
  90. const joinBtn = screen.getByRole('button', {
  91. name: /join project/i,
  92. }) as HTMLButtonElement
  93. expect(joinBtn.disabled).to.be.false
  94. fireEvent.click(joinBtn)
  95. expect(joinBtn.disabled).to.be.true
  96. await waitForElementToBeRemoved(() =>
  97. screen.getByRole('button', { name: /joining/i })
  98. )
  99. expect(acceptMock.called()).to.be.true
  100. screen.getByText(/joined/i)
  101. expect(screen.queryByRole('button', { name: /join project/i })).to.be.null
  102. const openProject = screen.getByRole('link', { name: /open project/i })
  103. expect(openProject.getAttribute('href')).to.equal(
  104. `/project/${notification.messageOpts.projectId}`
  105. )
  106. const closeBtn = screen.getByRole('button', { name: /close/i })
  107. fireEvent.click(closeBtn)
  108. expect(deleteMock.called()).to.be.true
  109. expect(screen.queryByRole('alert')).to.be.null
  110. })
  111. it('fails to accept project invite', async function () {
  112. const reconfiguredNotification: DeepPartial<Notification> = {
  113. _id: 1,
  114. templateKey: 'notification_project_invite',
  115. }
  116. window.metaAttributesCache.set('ol-notifications', [
  117. merge(cloneDeep(notification), reconfiguredNotification),
  118. ])
  119. renderWithinProjectListProvider(Common)
  120. await fetchMock.flush(true)
  121. fetchMock.post(
  122. `project/${notification.messageOpts.projectId}/invite/token/${notification.messageOpts.token}/accept`,
  123. 500
  124. )
  125. screen.getByRole('alert')
  126. screen.getByText(/would like you to join/i)
  127. const joinBtn = screen.getByRole('button', {
  128. name: /join project/i,
  129. }) as HTMLButtonElement
  130. fireEvent.click(joinBtn)
  131. await waitForElementToBeRemoved(() =>
  132. screen.getByRole('button', { name: /joining/i })
  133. )
  134. expect(fetchMock.called()).to.be.true
  135. screen.getByRole('button', { name: /join project/i })
  136. expect(screen.queryByRole('link', { name: /open project/i })).to.be.null
  137. })
  138. it('shows WFH2020', async function () {
  139. const reconfiguredNotification: DeepPartial<Notification> = {
  140. _id: 1,
  141. templateKey: 'wfh_2020_upgrade_offer',
  142. }
  143. window.metaAttributesCache.set('ol-notifications', [
  144. merge(cloneDeep(notification), reconfiguredNotification),
  145. ])
  146. renderWithinProjectListProvider(Common)
  147. await fetchMock.flush(true)
  148. fetchMock.delete(`/notifications/${reconfiguredNotification._id}`, 200)
  149. screen.getByRole('alert')
  150. screen.getByText(/your free WFH2020 upgrade came to an end on/i)
  151. const viewLink = screen.getByRole('link', { name: /view/i })
  152. expect(viewLink.getAttribute('href')).to.equal(
  153. 'https://www.overleaf.com/events/wfh2020'
  154. )
  155. const closeBtn = screen.getByRole('button', { name: /close/i })
  156. fireEvent.click(closeBtn)
  157. expect(fetchMock.called()).to.be.true
  158. expect(screen.queryByRole('alert')).to.be.null
  159. })
  160. it('shows IP matched affiliation with SSO enabled', async function () {
  161. const reconfiguredNotification: DeepPartial<Notification> = {
  162. _id: 1,
  163. templateKey: 'notification_ip_matched_affiliation',
  164. messageOpts: { ssoEnabled: true },
  165. }
  166. window.metaAttributesCache.set('ol-notifications', [
  167. merge(cloneDeep(notification), reconfiguredNotification),
  168. ])
  169. renderWithinProjectListProvider(Common)
  170. await fetchMock.flush(true)
  171. fetchMock.delete(`/notifications/${reconfiguredNotification._id}`, 200)
  172. screen.getByRole('alert')
  173. screen.getByText(/it looks like you’re at/i)
  174. screen.getByText(/you can now log in through your institution/i)
  175. screen.getByText(
  176. /link an institutional email address to your account to get started/i
  177. )
  178. const findOutMore = screen.getByRole('link', { name: /find out more/i })
  179. expect(findOutMore.getAttribute('href')).to.equal(
  180. 'https://www.overleaf.com/learn/how-to/Institutional_Login'
  181. )
  182. const linkAccount = screen.getByRole('link', { name: /link account/i })
  183. expect(linkAccount.getAttribute('href')).to.equal(
  184. `${exposedSettings.samlInitPath}?university_id=${notification.messageOpts.institutionId}&auto=/project`
  185. )
  186. const closeBtn = screen.getByRole('button', { name: /close/i })
  187. fireEvent.click(closeBtn)
  188. expect(fetchMock.called()).to.be.true
  189. expect(screen.queryByRole('alert')).to.be.null
  190. })
  191. it('shows IP matched affiliation with SSO disabled', async function () {
  192. const reconfiguredNotification: DeepPartial<Notification> = {
  193. _id: 1,
  194. templateKey: 'notification_ip_matched_affiliation',
  195. messageOpts: { ssoEnabled: false },
  196. }
  197. window.metaAttributesCache.set('ol-notifications', [
  198. merge(cloneDeep(notification), reconfiguredNotification),
  199. ])
  200. renderWithinProjectListProvider(Common)
  201. await fetchMock.flush(true)
  202. fetchMock.delete(`/notifications/${reconfiguredNotification._id}`, 200)
  203. screen.getByRole('alert')
  204. screen.getByText(/it looks like you’re at/i)
  205. screen.getByText(/did you know that/i)
  206. screen.getByText(
  207. /add an institutional email address to claim your features/i
  208. )
  209. const addAffiliation = screen.getByRole('link', {
  210. name: /add affiliation/i,
  211. })
  212. expect(addAffiliation.getAttribute('href')).to.equal(`/user/settings`)
  213. const closeBtn = screen.getByRole('button', { name: /close/i })
  214. fireEvent.click(closeBtn)
  215. expect(fetchMock.called()).to.be.true
  216. expect(screen.queryByRole('alert')).to.be.null
  217. })
  218. it('shows tpds file limit', async function () {
  219. const reconfiguredNotification: DeepPartial<Notification> = {
  220. templateKey: 'notification_tpds_file_limit',
  221. }
  222. window.metaAttributesCache.set('ol-notifications', [
  223. merge(cloneDeep(notification), reconfiguredNotification),
  224. ])
  225. renderWithinProjectListProvider(Common)
  226. await fetchMock.flush(true)
  227. screen.getByRole('alert')
  228. screen.getByText(/file limit/i)
  229. screen.getByText(
  230. /please decrease the size of your project to prevent further errors/i
  231. )
  232. const accountSettings = screen.getByRole('link', {
  233. name: /account settings/i,
  234. })
  235. expect(accountSettings.getAttribute('href')).to.equal('/user/settings')
  236. const closeBtn = screen.getByRole('button', { name: /close/i })
  237. fireEvent.click(closeBtn)
  238. expect(screen.queryByRole('alert')).to.be.null
  239. })
  240. it('shows dropbox duplicate project names warning', async function () {
  241. const reconfiguredNotification: DeepPartial<Notification> = {
  242. _id: 1,
  243. templateKey: 'notification_dropbox_duplicate_project_names',
  244. }
  245. window.metaAttributesCache.set('ol-notifications', [
  246. merge(cloneDeep(notification), reconfiguredNotification),
  247. ])
  248. renderWithinProjectListProvider(Common)
  249. await fetchMock.flush(true)
  250. fetchMock.delete(`/notifications/${reconfiguredNotification._id}`, 200)
  251. screen.getByRole('alert')
  252. screen.getByText(/you have more than one project called/i)
  253. screen.getByText(/make your project names unique/i)
  254. const learnMore = screen.getByRole('link', { name: /learn more/i })
  255. expect(learnMore.getAttribute('href')).to.equal(
  256. '/learn/how-to/Dropbox_Synchronization#Troubleshooting'
  257. )
  258. const closeBtn = screen.getByRole('button', { name: /close/i })
  259. fireEvent.click(closeBtn)
  260. expect(fetchMock.called()).to.be.true
  261. expect(screen.queryByRole('alert')).to.be.null
  262. })
  263. it('shows dropbox unlinked tue to lapsed reconfirmation', async function () {
  264. const reconfiguredNotification: DeepPartial<Notification> = {
  265. _id: 1,
  266. templateKey:
  267. 'notification_dropbox_unlinked_due_to_lapsed_reconfirmation',
  268. }
  269. window.metaAttributesCache.set('ol-notifications', [
  270. merge(cloneDeep(notification), reconfiguredNotification),
  271. ])
  272. renderWithinProjectListProvider(Common)
  273. await fetchMock.flush(true)
  274. fetchMock.delete(`/notifications/${reconfiguredNotification._id}`, 200)
  275. screen.getByRole('alert')
  276. screen.getByText(/your Dropbox account has been unlinked/i)
  277. screen.getByText(
  278. /confirm you are still at the institution and on their license, or upgrade your account in order to relink your dropbox account/i
  279. )
  280. const learnMore = screen.getByRole('link', { name: /learn more/i })
  281. expect(learnMore.getAttribute('href')).to.equal(
  282. '/learn/how-to/Institutional_Email_Reconfirmation'
  283. )
  284. const closeBtn = screen.getByRole('button', { name: /close/i })
  285. fireEvent.click(closeBtn)
  286. expect(fetchMock.called()).to.be.true
  287. expect(screen.queryByRole('alert')).to.be.null
  288. })
  289. it('shows non specific notification', async function () {
  290. const reconfiguredNotification: DeepPartial<Notification> = {
  291. _id: 1,
  292. html: 'unspecific message',
  293. }
  294. window.metaAttributesCache.set('ol-notifications', [
  295. merge(cloneDeep(notification), reconfiguredNotification),
  296. ])
  297. renderWithinProjectListProvider(Common)
  298. await fetchMock.flush(true)
  299. fetchMock.delete(`/notifications/${reconfiguredNotification._id}`, 200)
  300. screen.getByRole('alert')
  301. screen.getByText(reconfiguredNotification.html!)
  302. const closeBtn = screen.getByRole('button', { name: /close/i })
  303. fireEvent.click(closeBtn)
  304. expect(fetchMock.called()).to.be.true
  305. expect(screen.queryByRole('alert')).to.be.null
  306. })
  307. })
  308. describe('<Institution>', function () {
  309. beforeEach(function () {
  310. window.metaAttributesCache = window.metaAttributesCache || new Map()
  311. window.metaAttributesCache.set('ol-ExposedSettings', exposedSettings)
  312. fetchMock.reset()
  313. })
  314. afterEach(function () {
  315. fetchMock.reset()
  316. })
  317. it('shows sso available', function () {
  318. const institution: DeepPartial<InstitutionType> = {
  319. templateKey: 'notification_institution_sso_available',
  320. }
  321. window.metaAttributesCache.set('ol-notificationsInstitution', [
  322. { ...notificationsInstitution, ...institution },
  323. ])
  324. render(<Institution />)
  325. screen.getByRole('alert')
  326. screen.getByText(/you can now link/i)
  327. screen.getByText(/doing this will allow you to log in/i)
  328. const learnMore = screen.getByRole('link', { name: /learn more/i })
  329. expect(learnMore.getAttribute('href')).to.equal(
  330. '/learn/how-to/Institutional_Login'
  331. )
  332. const action = screen.getByRole('link', { name: /link account/i })
  333. expect(action.getAttribute('href')).to.equal(
  334. `${exposedSettings.samlInitPath}?university_id=${notificationsInstitution.institutionId}&auto=/project&email=${notificationsInstitution.email}`
  335. )
  336. })
  337. it('shows sso linked', function () {
  338. const institution: DeepPartial<InstitutionType> = {
  339. _id: 1,
  340. templateKey: 'notification_institution_sso_linked',
  341. }
  342. window.metaAttributesCache.set('ol-notificationsInstitution', [
  343. { ...notificationsInstitution, ...institution },
  344. ])
  345. render(<Institution />)
  346. fetchMock.delete(`/notifications/${institution._id}`, 200)
  347. screen.getByRole('alert')
  348. screen.getByText(/has been linked to your/i)
  349. const closeBtn = screen.getByRole('button', { name: /close/i })
  350. fireEvent.click(closeBtn)
  351. expect(fetchMock.called()).to.be.true
  352. expect(screen.queryByRole('alert')).to.be.null
  353. })
  354. it('shows sso non canonical', function () {
  355. const institution: DeepPartial<InstitutionType> = {
  356. _id: 1,
  357. templateKey: 'notification_institution_sso_non_canonical',
  358. }
  359. window.metaAttributesCache.set('ol-notificationsInstitution', [
  360. { ...notificationsInstitution, ...institution },
  361. ])
  362. render(<Institution />)
  363. fetchMock.delete(`/notifications/${institution._id}`, 200)
  364. screen.getByRole('alert')
  365. screen.getByText(/you’ve tried to login with/i)
  366. screen.getByText(
  367. /in order to match your institutional metadata, your account is associated with/i
  368. )
  369. const closeBtn = screen.getByRole('button', { name: /close/i })
  370. fireEvent.click(closeBtn)
  371. expect(fetchMock.called()).to.be.true
  372. expect(screen.queryByRole('alert')).to.be.null
  373. })
  374. it('shows sso already registered', function () {
  375. const institution: DeepPartial<InstitutionType> = {
  376. _id: 1,
  377. templateKey: 'notification_institution_sso_already_registered',
  378. }
  379. window.metaAttributesCache.set('ol-notificationsInstitution', [
  380. { ...notificationsInstitution, ...institution },
  381. ])
  382. render(<Institution />)
  383. fetchMock.delete(`/notifications/${institution._id}`, 200)
  384. screen.getByRole('alert')
  385. screen.getByText(/which is already registered with/i)
  386. const action = screen.getByRole('link', { name: /find out more/i })
  387. expect(action.getAttribute('href')).to.equal(
  388. '/learn/how-to/Institutional_Login'
  389. )
  390. const closeBtn = screen.getByRole('button', { name: /close/i })
  391. fireEvent.click(closeBtn)
  392. expect(fetchMock.called()).to.be.true
  393. expect(screen.queryByRole('alert')).to.be.null
  394. })
  395. it('shows sso error', function () {
  396. const institution: DeepPartial<InstitutionType> = {
  397. templateKey: 'notification_institution_sso_error',
  398. error: {
  399. message: 'fake message',
  400. tryAgain: true,
  401. },
  402. }
  403. window.metaAttributesCache.set('ol-notificationsInstitution', [
  404. { ...notificationsInstitution, ...institution },
  405. ])
  406. render(<Institution />)
  407. screen.getByRole('alert')
  408. screen.getByText(/something went wrong/i)
  409. screen.getByText(institution.error!.message!)
  410. screen.getByText(/please try again/i)
  411. const closeBtn = screen.getByRole('button', { name: /close/i })
  412. fireEvent.click(closeBtn)
  413. expect(screen.queryByRole('alert')).to.be.null
  414. })
  415. })
  416. describe('<ConfirmEmail/>', function () {
  417. beforeEach(async function () {
  418. window.metaAttributesCache.set('ol-ExposedSettings', {
  419. emailConfirmationDisabled: false,
  420. })
  421. window.metaAttributesCache.set('ol-userEmails', [unconfirmedUserData])
  422. renderWithinProjectListProvider(ConfirmEmail)
  423. await fetchMock.flush(true)
  424. })
  425. afterEach(function () {
  426. fetchMock.reset()
  427. })
  428. it('sends successfully', async function () {
  429. fetchMock.post('/user/emails/resend_confirmation', 200)
  430. const resendButton = screen.getByRole('button', { name: /resend/i })
  431. fireEvent.click(resendButton)
  432. expect(screen.queryByRole('button', { name: /resend/i })).to.be.null
  433. await waitForElementToBeRemoved(() =>
  434. screen.getByText(/resending confirmation email/i)
  435. )
  436. expect(fetchMock.called()).to.be.true
  437. expect(screen.queryByRole('alert')).to.be.null
  438. })
  439. it('fails to send', async function () {
  440. fetchMock.post('/user/emails/resend_confirmation', 500)
  441. const resendButton = screen.getByRole('button', { name: /resend/i })
  442. fireEvent.click(resendButton)
  443. await waitForElementToBeRemoved(() =>
  444. screen.getByText(/resending confirmation email/i)
  445. )
  446. expect(fetchMock.called()).to.be.true
  447. screen.getByText(/something went wrong/i)
  448. })
  449. })
  450. describe('<Affiliation/>', function () {
  451. const locationStub = sinon.stub()
  452. const originalLocation = window.location
  453. beforeEach(function () {
  454. window.metaAttributesCache = window.metaAttributesCache || new Map()
  455. window.metaAttributesCache.set('ol-ExposedSettings', exposedSettings)
  456. Object.defineProperty(window, 'location', {
  457. value: { assign: locationStub },
  458. })
  459. fetchMock.reset()
  460. })
  461. afterEach(function () {
  462. window.metaAttributesCache = new Map()
  463. Object.defineProperty(window, 'location', {
  464. value: originalLocation,
  465. })
  466. fetchMock.reset()
  467. })
  468. it('shows reconfirm message with SSO disabled', async function () {
  469. window.metaAttributesCache.set('ol-allInReconfirmNotificationPeriods', [
  470. { ...professionalUserData, samlProviderId: 'Saml Provider' },
  471. ])
  472. render(<ReconfirmationInfo />)
  473. screen.getByRole('alert')
  474. screen.getByText(
  475. /take a moment to confirm your institutional email address/i
  476. )
  477. const removeLink = screen.getByRole('link', { name: /remove it/i })
  478. expect(removeLink.getAttribute('href')).to.equal(
  479. `/user/settings?remove=${professionalUserData.email}`
  480. )
  481. const learnMore = screen.getByRole('link', { name: /learn more/i })
  482. expect(learnMore.getAttribute('href')).to.equal(
  483. '/learn/how-to/Institutional_Email_Reconfirmation'
  484. )
  485. const sendReconfirmationMock = fetchMock.post(
  486. '/user/emails/send-reconfirmation',
  487. 200
  488. )
  489. fireEvent.click(
  490. screen.getByRole('button', { name: /confirm affiliation/i })
  491. )
  492. await waitForElementToBeRemoved(() => screen.getByText(/sending/i))
  493. screen.getByText(/check your email inbox to confirm/i)
  494. expect(screen.queryByRole('button', { name: /confirm affiliation/i })).to
  495. .be.null
  496. expect(screen.queryByRole('link', { name: /remove it/i })).to.be.null
  497. expect(screen.queryByRole('link', { name: /learn more/i })).to.be.null
  498. expect(sendReconfirmationMock.called()).to.be.true
  499. fireEvent.click(
  500. screen.getByRole('button', { name: /resend confirmation email/i })
  501. )
  502. await waitForElementToBeRemoved(() => screen.getByText(/sending/i))
  503. expect(sendReconfirmationMock.calls()).to.have.lengthOf(2)
  504. })
  505. it('shows reconfirm message with SSO enabled', async function () {
  506. window.metaAttributesCache.set('ol-allInReconfirmNotificationPeriods', [
  507. merge(cloneDeep(professionalUserData), {
  508. affiliation: { institution: { ssoEnabled: true } },
  509. }),
  510. ])
  511. render(<ReconfirmationInfo />)
  512. fireEvent.click(
  513. screen.getByRole('button', { name: /confirm affiliation/i })
  514. )
  515. sinon.assert.calledOnce(locationStub)
  516. sinon.assert.calledWithMatch(
  517. locationStub,
  518. `${exposedSettings.samlInitPath}?university_id=${professionalUserData.affiliation.institution.id}&reconfirm=/project`
  519. )
  520. })
  521. it('shows success reconfirmation message', function () {
  522. window.metaAttributesCache.set('ol-userEmails', [
  523. { ...professionalUserData, samlProviderId: 'Saml Provider' },
  524. ])
  525. window.metaAttributesCache.set('ol-reconfirmedViaSAML', 'Saml Provider')
  526. const { rerender } = render(<ReconfirmationInfo />)
  527. screen.getByRole('alert')
  528. screen.getByText(professionalUserData.affiliation!.institution!.name!)
  529. screen.getByText(/affiliation is confirmed/i)
  530. window.metaAttributesCache.set('ol-reconfirmedViaSAML', '')
  531. rerender(<ReconfirmationInfo />)
  532. expect(screen.queryByRole('alert')).to.be.null
  533. })
  534. })
  535. })