mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Merge pull request #24313 from overleaf/td-ac-bs5-frontend-tests
Update front-end tests to use Bootstrap 5 GitOrigin-RevId: abaa09f8c0639d64d6ade97468ab16204e5de97b
This commit is contained in:
+8
-7
@@ -1,6 +1,6 @@
|
||||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import { screen, fireEvent, render } from '@testing-library/react'
|
||||
import { screen, fireEvent, render, within } from '@testing-library/react'
|
||||
import { IntegrationLinkingWidget } from '../../../../../../frontend/js/features/settings/components/linking/integration-widget'
|
||||
import * as eventTracking from '@/infrastructure/event-tracking'
|
||||
|
||||
@@ -32,7 +32,7 @@ describe('<IntegrationLinkingWidgetTest/>', function () {
|
||||
})
|
||||
|
||||
it('should render an upgrade link and track clicks', function () {
|
||||
const upgradeLink = screen.getByRole('link', { name: 'Upgrade' })
|
||||
const upgradeLink = screen.getByRole('button', { name: 'Upgrade' })
|
||||
expect(upgradeLink.getAttribute('href')).to.equal(
|
||||
'/user/subscription/plans'
|
||||
)
|
||||
@@ -51,7 +51,7 @@ describe('<IntegrationLinkingWidgetTest/>', function () {
|
||||
|
||||
it('should render a link to initiate integration linking', function () {
|
||||
expect(
|
||||
screen.getByRole('link', { name: 'Link' }).getAttribute('href')
|
||||
screen.getByRole('button', { name: 'Link' }).getAttribute('href')
|
||||
).to.equal('/link')
|
||||
})
|
||||
|
||||
@@ -90,10 +90,11 @@ describe('<IntegrationLinkingWidgetTest/>', function () {
|
||||
|
||||
it('should open a modal with a link to confirm integration unlinking', function () {
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Unlink' }))
|
||||
screen.getByText('confirm unlink')
|
||||
screen.getByText('you will be unlinked')
|
||||
screen.getByRole('button', { name: 'Cancel' })
|
||||
screen.getByRole('button', { name: 'Unlink' })
|
||||
const withinModal = within(screen.getByRole('dialog'))
|
||||
withinModal.getByText('confirm unlink')
|
||||
withinModal.getByText('you will be unlinked')
|
||||
withinModal.getByRole('button', { name: 'Cancel' })
|
||||
withinModal.getByRole('button', { name: 'Unlink' })
|
||||
})
|
||||
|
||||
it('should cancel unlinking when clicking "cancel" in the confirmation modal', async function () {
|
||||
|
||||
+16
-7
@@ -1,6 +1,12 @@
|
||||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import { screen, fireEvent, render, waitFor } from '@testing-library/react'
|
||||
import {
|
||||
screen,
|
||||
fireEvent,
|
||||
render,
|
||||
waitFor,
|
||||
within,
|
||||
} from '@testing-library/react'
|
||||
import { FetchError } from '../../../../../../frontend/js/infrastructure/fetch-json'
|
||||
import { SSOLinkingWidget } from '../../../../../../frontend/js/features/settings/components/linking/sso-widget'
|
||||
|
||||
@@ -27,7 +33,7 @@ describe('<SSOLinkingWidget />', function () {
|
||||
it('should render a link to `linkPath`', function () {
|
||||
render(<SSOLinkingWidget {...defaultProps} linked={false} />)
|
||||
expect(
|
||||
screen.getByRole('link', { name: 'Link' }).getAttribute('href')
|
||||
screen.getByRole('button', { name: 'Link' }).getAttribute('href')
|
||||
).to.equal('/integration/link?intent=link')
|
||||
})
|
||||
})
|
||||
@@ -75,7 +81,7 @@ describe('<SSOLinkingWidget />', function () {
|
||||
<SSOLinkingWidget {...defaultProps} linked onUnlink={unlinkFunction} />
|
||||
)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Unlink' }))
|
||||
confirmBtn = screen.getByRole('button', {
|
||||
confirmBtn = within(screen.getByRole('dialog')).getByRole('button', {
|
||||
name: 'Unlink',
|
||||
hidden: false,
|
||||
})
|
||||
@@ -109,10 +115,13 @@ describe('<SSOLinkingWidget />', function () {
|
||||
<SSOLinkingWidget {...defaultProps} linked onUnlink={unlinkFunction} />
|
||||
)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Unlink' }))
|
||||
const confirmBtn = screen.getByRole('button', {
|
||||
name: 'Unlink',
|
||||
hidden: false,
|
||||
})
|
||||
const confirmBtn = within(screen.getByRole('dialog')).getByRole(
|
||||
'button',
|
||||
{
|
||||
name: 'Unlink',
|
||||
hidden: false,
|
||||
}
|
||||
)
|
||||
fireEvent.click(confirmBtn)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user