Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to next 13 #906

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cypress/e2e/work-order/authorisation/authorisation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import 'cypress-audit/commands'
// Mock date
const now = new Date('Fri Jan 22 2021 18:27:20 GMT+0000 (Greenwich Mean Time)')

jest.mock('next/router', () => ({
useRouter: jest.fn(),
}))

describe('Authorisation workflow for a work order', () => {
beforeEach(() => {
cy.loginWithAuthorisationManagerRole()
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
"loglevel": "^1.8.0",
"lru-cache": "^6.0.0",
"mockdate": "^3.0.2",
"next": "^12",
"next": "13",
"path": "^0.12.7",
"qs": "^6.10.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "18",
"react-dom": "18",
"react-hook-form": "^6.14.0",
"react-hotjar": "^5.0.0",
"react-photo-view": "^1.2.6",
Expand All @@ -62,9 +62,9 @@
"@babel/eslint-parser": "^7.17.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-transform-private-methods": "^7.22.5",
"@testing-library/dom": "^7.31.0",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^13.1.9",
"@types/node": "^22.1.0",
"@types/qs": "^6.9.15",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const HeaderComponent = ({ serviceName, toggleMobileMenu, mobileMenuOpen }) => {
<div className="lbh-header__main">
<div className="lbh-container lbh-header__wrapper lbh-header__wrapper--stacked">
<div className="lbh-header__title">
<Link href="/">
<Link href="/" legacyBehavior>
<a className="lbh-header__title-link">
<div className="lbh-header__logo-container">
<svg
Expand Down
13 changes: 5 additions & 8 deletions src/components/Layout/MultiButton/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MultiButton from '.'
import { act, fireEvent, render, screen } from '@testing-library/react'
import { fireEvent, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { act } from 'react'

beforeAll(() => {
global.Storage.prototype.setItem = jest.fn()
Expand Down Expand Up @@ -43,9 +44,7 @@ describe('MultiButton', () => {
it('allows a user to choose between options', () => {
render(<MockComponent />)

act(() => {
fireEvent.click(screen.getByText('Bar'))
})
fireEvent.click(screen.getByText('Bar'))

expect(screen.getAllByText('Bar').length).toBe(2)
})
Expand Down Expand Up @@ -77,10 +76,8 @@ describe('MultiButton', () => {
it('closes the details panel after the enter key is pressed', () => {
render(<MockComponent />)

act(() => {
userEvent.click(screen.getByText('Select action'))
fireEvent.keyUp(screen.getByText('Bar'), { key: 'Enter', code: 'Enter' })
})
userEvent.click(screen.getByText('Select action'))
fireEvent.keyUp(screen.getByText('Bar'), { key: 'Enter', code: 'Enter' })

expect(screen.getByTestId('details').getAttribute('open')).toBe(null)
})
Expand Down
5 changes: 4 additions & 1 deletion src/components/Operatives/OperativeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ const OperativeList = ({
}
const OperativeListLinkItem = ({ workOrderReference, operativeDisplay }) => (
<li>
<Link href={`/work-orders/${workOrderReference}/operatives/edit`}>
<Link
href={`/work-orders/${workOrderReference}/operatives/edit`}
legacyBehavior
>
<a className="govuk-link">{operativeDisplay}</a>
</Link>
</li>
Expand Down
10 changes: 6 additions & 4 deletions src/components/Property/Contacts/Contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ const Contacts = (props) => {
return <WarningText text={text} />
}

const tenants = contacts.filter((x) => x.tenureType === 'Tenant')
const householdMembers = contacts.filter(
(x) => x.tenureType === 'HouseholdMember'
)
const tenants = Array.isArray(contacts)
? contacts?.filter((x) => x.tenureType === 'Tenant')
: []
const householdMembers = Array.isArray(contacts)
? contacts?.filter((x) => x.tenureType === 'HouseholdMember')
: []

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Property/PropertyDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const PropertyDetails = ({

{isCurrentTimeOutOfHours() && (
<div>
<Link href={process.env.NEXT_PUBLIC_OUT_OF_HOURS_LINK}>
<Link href={process.env.NEXT_PUBLIC_OUT_OF_HOURS_LINK} legacyBehavior>
<a
target="_blank"
rel="noopener"
Expand Down
22 changes: 9 additions & 13 deletions src/components/Property/PropertyDetails.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
render,
act,
screen,
waitForElementToBeRemoved,
} from '@testing-library/react'
Expand Down Expand Up @@ -59,12 +58,10 @@ describe('PropertyDetails component', () => {
/>
)

await act(async () => {
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
screen.getByTestId('spinner-personAlerts'),
])
})
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
screen.getByTestId('spinner-personAlerts'),
])

expect(asFragment()).toMatchSnapshot()
})
Expand All @@ -90,12 +87,11 @@ describe('PropertyDetails component', () => {
/>
)

await act(async () => {
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
screen.getByTestId('spinner-personAlerts'),
])
})
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
screen.getByTestId('spinner-personAlerts'),
])

expect(asFragment()).toMatchSnapshot()
})
})
Expand Down
2 changes: 1 addition & 1 deletion src/components/Property/PropertyDetailsAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const PropertyDetailsAddress = ({
<span className="govuk-!-font-size-14">{subTypeDescription}</span>
<br></br>
{hasLinkToProperty ? (
<Link href={`/properties/${propertyReference}`}>
<Link href={`/properties/${propertyReference}`} legacyBehavior>
<a className="lbh-link">
<Address address={address} />
</a>
Expand Down
21 changes: 8 additions & 13 deletions src/components/Property/PropertyFlags/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
render,
act,
screen,
waitForElementToBeRemoved,
} from '@testing-library/react'
Expand Down Expand Up @@ -59,12 +58,10 @@ describe('PropertyFlags', () => {

expect(asFragment()).toMatchSnapshot()

await act(async () => {
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
screen.getByTestId('spinner-personAlerts'),
])
})
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
screen.getByTestId('spinner-personAlerts'),
])

expect(axios).toHaveBeenCalledTimes(2)

Expand Down Expand Up @@ -131,12 +128,10 @@ describe('PropertyFlags', () => {
/>
)

await act(async () => {
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
screen.getByTestId('spinner-personAlerts'),
])
})
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
screen.getByTestId('spinner-personAlerts'),
])

expect(mockSetParentLocationAlerts).toHaveBeenCalledWith([
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/Property/PropertyRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PropertyRow = ({
}) => (
<TR className="govuk-table__row--clickable lbh-body-s">
<TD>
<Link href={`/properties/${propertyReference}`}>
<Link href={`/properties/${propertyReference}`} legacyBehavior>
<a className="lbh-link">{address}</a>
</Link>
</TD>
Expand Down
29 changes: 13 additions & 16 deletions src/components/Property/RaiseWorkOrder/RaiseWorkOrderForm.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
act,
render,
screen,
waitForElementToBeRemoved,
Expand All @@ -22,6 +21,10 @@ const axios = require('axios')

jest.mock('axios', () => jest.fn())

jest.mock('next/router', () => ({
useRouter: jest.fn(),
}))

describe('RaiseWorkOrderForm component', () => {
axios.mockResolvedValue({
data: {
Expand Down Expand Up @@ -116,11 +119,9 @@ describe('RaiseWorkOrderForm component', () => {
</UserContext.Provider>
)

await act(async () => {
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
])
})
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
])

expect(asFragment()).toMatchSnapshot()
})
Expand Down Expand Up @@ -154,11 +155,9 @@ describe('RaiseWorkOrderForm component', () => {
</UserContext.Provider>
)

await act(async () => {
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
])
})
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
])

expect(asFragment()).toMatchSnapshot()
})
Expand Down Expand Up @@ -223,11 +222,9 @@ describe('RaiseWorkOrderForm component', () => {
</UserContext.Provider>
)

await act(async () => {
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
])
})
await waitForElementToBeRemoved([
screen.getByTestId('spinner-locationAlerts'),
])

expect(asFragment()).toMatchSnapshot()
})
Expand Down
Loading