Просмотр исходного кода

Merge pull request #7930 from overleaf/fix-tsc-typings

Fix typescript errors

GitOrigin-RevId: b49235a3d9d6277e7c2de5bc7a79b7cafae75e2e
Timothée Alby 4 лет назад
Родитель
Сommit
afe9e486ae

+ 1 - 1
services/web/cypress/support/ct/window.ts

@@ -1,2 +1,2 @@
 window.i18n = { currentLangCode: 'en' }
-window.ExposedSettings = { appName: 'Overleaf' }
+window.ExposedSettings = { ...window?.ExposedSettings, appName: 'Overleaf' }

+ 23 - 11
services/web/test/frontend/features/settings/components/account-info-section.test.tsx

@@ -52,7 +52,7 @@ describe('<AccountInfoSection />', function () {
       })
     )
     expect(updateMock.called()).to.be.true
-    expect(JSON.parse(updateMock.lastCall()[1].body)).to.deep.equal({
+    expect(JSON.parse(updateMock.lastCall()[1].body as string)).to.deep.equal({
       email: 'john@watson.co.uk',
       first_name: 'John',
       last_name: 'Watson',
@@ -68,7 +68,7 @@ describe('<AccountInfoSection />', function () {
     })
     const button = screen.getByRole('button', {
       name: 'Update',
-    })
+    }) as HTMLButtonElement
 
     expect(button.disabled).to.be.true
     fireEvent.click(button)
@@ -155,7 +155,7 @@ describe('<AccountInfoSection />', function () {
         name: 'Update',
       })
     )
-    expect(JSON.parse(updateMock.lastCall()[1].body)).to.deep.equal({
+    expect(JSON.parse(updateMock.lastCall()[1].body as string)).to.deep.equal({
       first_name: 'Sherlock',
       last_name: 'Holmes',
     })
@@ -169,16 +169,22 @@ describe('<AccountInfoSection />', function () {
     const updateMock = fetchMock.post('/user/settings', 200)
 
     renderSectionWithUserProvider()
-    expect(screen.getByLabelText('Email').readOnly).to.be.true
-    expect(screen.getByLabelText('First Name').readOnly).to.be.false
-    expect(screen.getByLabelText('Last Name').readOnly).to.be.false
+    expect(screen.getByLabelText('Email')).to.have.property('readOnly', true)
+    expect(screen.getByLabelText('First Name')).to.have.property(
+      'readOnly',
+      false
+    )
+    expect(screen.getByLabelText('Last Name')).to.have.property(
+      'readOnly',
+      false
+    )
 
     fireEvent.click(
       screen.getByRole('button', {
         name: 'Update',
       })
     )
-    expect(JSON.parse(updateMock.lastCall()[1].body)).to.deep.equal({
+    expect(JSON.parse(updateMock.lastCall()[1].body as string)).to.deep.equal({
       first_name: 'Sherlock',
       last_name: 'Holmes',
     })
@@ -189,16 +195,22 @@ describe('<AccountInfoSection />', function () {
     const updateMock = fetchMock.post('/user/settings', 200)
 
     renderSectionWithUserProvider()
-    expect(screen.getByLabelText('Email').readOnly).to.be.false
-    expect(screen.getByLabelText('First Name').readOnly).to.be.true
-    expect(screen.getByLabelText('Last Name').readOnly).to.be.true
+    expect(screen.getByLabelText('Email')).to.have.property('readOnly', false)
+    expect(screen.getByLabelText('First Name')).to.have.property(
+      'readOnly',
+      true
+    )
+    expect(screen.getByLabelText('Last Name')).to.have.property(
+      'readOnly',
+      true
+    )
 
     fireEvent.click(
       screen.getByRole('button', {
         name: 'Update',
       })
     )
-    expect(JSON.parse(updateMock.lastCall()[1].body)).to.deep.equal({
+    expect(JSON.parse(updateMock.lastCall()[1].body as string)).to.deep.equal({
       email: 'sherlock@holmes.co.uk',
     })
   })

+ 3 - 3
services/web/test/frontend/features/settings/components/beta-program-section.test.tsx

@@ -21,7 +21,7 @@ describe('<BetaProgramSection />', function () {
   })
 
   it('shows link to sessions', async function () {
-    renderSectionWithUserProvider(<BetaProgramSection />)
+    renderSectionWithUserProvider()
 
     const link = screen.getByRole('link', {
       name: 'Manage Beta Program Membership',
@@ -31,7 +31,7 @@ describe('<BetaProgramSection />', function () {
   })
 
   it('shows enrolled status', async function () {
-    renderSectionWithUserProvider(<BetaProgramSection />)
+    renderSectionWithUserProvider()
     screen.getByText('You are enrolled in the Beta Program')
   })
 
@@ -39,7 +39,7 @@ describe('<BetaProgramSection />', function () {
     window.metaAttributesCache.set('ol-user', {
       betaProgram: false,
     })
-    renderSectionWithUserProvider(<BetaProgramSection />)
+    renderSectionWithUserProvider()
     screen.getByText(/By joining our Beta program you can have early access/)
   })
 })

+ 3 - 0
services/web/test/frontend/features/settings/components/emails/emails-section-add-new-email.test.tsx

@@ -13,6 +13,8 @@ import { UserEmailData } from '../../../../../../types/user-email'
 const userEmailData: UserEmailData = {
   affiliation: {
     cachedConfirmedAt: null,
+    cachedEntitlement: null,
+    cachedLastDayToReconfirm: null,
     cachedPastReconfirmDate: false,
     cachedReconfirmedAt: null,
     department: 'Art History',
@@ -21,6 +23,7 @@ const userEmailData: UserEmailData = {
       confirmed: true,
       id: 1,
       isUniversity: true,
+      maxConfirmationMonths: null,
       name: 'Overleaf',
       ssoEnabled: false,
       ssoBeta: false,

+ 6 - 0
services/web/test/frontend/features/settings/components/emails/emails-section-institution-and-role.test.tsx

@@ -14,6 +14,8 @@ import EmailsSection from '../../../../../../frontend/js/features/settings/compo
 const userData1: UserEmailData = {
   affiliation: {
     cachedConfirmedAt: null,
+    cachedEntitlement: null,
+    cachedLastDayToReconfirm: null,
     cachedPastReconfirmDate: false,
     cachedReconfirmedAt: null,
     department: null,
@@ -22,6 +24,7 @@ const userData1: UserEmailData = {
       confirmed: true,
       id: 1,
       isUniversity: false,
+      maxConfirmationMonths: null,
       name: 'Overleaf',
       ssoEnabled: false,
       ssoBeta: false,
@@ -41,6 +44,8 @@ const userData1: UserEmailData = {
 const userData2: UserEmailData = {
   affiliation: {
     cachedConfirmedAt: null,
+    cachedEntitlement: null,
+    cachedLastDayToReconfirm: null,
     cachedPastReconfirmDate: false,
     cachedReconfirmedAt: null,
     department: 'Art History',
@@ -49,6 +54,7 @@ const userData2: UserEmailData = {
       confirmed: true,
       id: 1,
       isUniversity: false,
+      maxConfirmationMonths: null,
       name: 'Overleaf',
       ssoEnabled: false,
       ssoBeta: false,

+ 3 - 0
services/web/test/frontend/features/settings/components/emails/emails-section.test.tsx

@@ -25,6 +25,8 @@ const unconfirmedUserData: UserEmailData = {
 const professionalUserData: UserEmailData = {
   affiliation: {
     cachedConfirmedAt: null,
+    cachedEntitlement: null,
+    cachedLastDayToReconfirm: null,
     cachedPastReconfirmDate: false,
     cachedReconfirmedAt: null,
     department: 'Art History',
@@ -33,6 +35,7 @@ const professionalUserData: UserEmailData = {
       confirmed: true,
       id: 1,
       isUniversity: false,
+      maxConfirmationMonths: null,
       name: 'Overleaf',
       ssoEnabled: false,
       ssoBeta: false,

+ 3 - 2
services/web/test/frontend/features/settings/components/linking/integration-widget.test.tsx

@@ -4,9 +4,10 @@ import { IntegrationLinkingWidget } from '../../../../../../frontend/js/features
 
 describe('<IntegrationLinkingWidgetTest/>', function () {
   const defaultProps = {
-    logoSrc: '/logo',
+    logo: <div />,
     title: 'Integration',
-    description: ['paragraph1', 'paragraph2'],
+    description: 'paragraph1',
+    helpPath: '/learn',
     linkPath: '/link',
     unlinkPath: '/unlink',
     unlinkConfirmationTitle: 'confirm unlink',

+ 11 - 5
services/web/test/frontend/features/settings/components/password-section.test.tsx

@@ -47,7 +47,7 @@ describe('<PasswordSection />', function () {
     submitValidForm()
 
     expect(updateMock.called()).to.be.true
-    expect(JSON.parse(updateMock.lastCall()[1].body)).to.deep.equal({
+    expect(JSON.parse(updateMock.lastCall()[1].body as string)).to.deep.equal({
       currentPassword: 'foobar',
       newPassword1: 'barbaz',
       newPassword2: 'barbaz',
@@ -71,7 +71,7 @@ describe('<PasswordSection />', function () {
 
     const button = screen.getByRole('button', {
       name: 'Change',
-    })
+    }) as HTMLButtonElement
     expect(button.disabled).to.be.true
 
     fireEvent.change(screen.getByLabelText('Current Password'), {
@@ -104,9 +104,15 @@ describe('<PasswordSection />', function () {
     })
     render(<PasswordSection />)
 
-    const currentPasswordInput = screen.getByLabelText('Current Password')
-    const newPassword1Input = screen.getByLabelText('New Password')
-    const newPassword2Input = screen.getByLabelText('Confirm New Password')
+    const currentPasswordInput = screen.getByLabelText(
+      'Current Password'
+    ) as HTMLInputElement
+    const newPassword1Input = screen.getByLabelText(
+      'New Password'
+    ) as HTMLInputElement
+    const newPassword2Input = screen.getByLabelText(
+      'Confirm New Password'
+    ) as HTMLInputElement
 
     expect(newPassword1Input.minLength).to.equal(3)