Skip to content

Commit

Permalink
Upgrade testing library react to v14 #2182 (#2568)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrofbass authored Nov 10, 2024
1 parent 4ac9b8e commit f8b53ef
Show file tree
Hide file tree
Showing 6 changed files with 1,955 additions and 3,418 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"@sinonjs/fake-timers": "^13.0.4",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.2",
"@testing-library/react": "^12.1.5",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.5.2",
"@total-typescript/ts-reset": "^0.6.1",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
Expand Down
2 changes: 2 additions & 0 deletions src/components/__tests__/Bullet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ describe('expansion', () => {
const user = userEvent.setup({ delay: null })
await user.click(bulletOfThoughtA)

await vi.runOnlyPendingTimersAsync()

const thoughtCursor = await findCursor()
expect(thoughtCursor).toHaveTextContent('x')
})
Expand Down
8 changes: 5 additions & 3 deletions src/components/__tests__/ContextView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,13 @@ describe.skip('editing', () => {
const subthoughts = await findSubthoughts('m')

const thoughtA = await findByLabelText(subthoughts[0], 'thought')
userEvent.click(thoughtA)

userEvent.type(thoughtA, 'z')
const user = userEvent.setup({ delay: null })
await user.click(thoughtA)

userEvent.type(thoughtA, '{esc}')
await user.type(thoughtA, 'z')

await user.type(thoughtA, '{esc}')
store.dispatch(toggleContextView())

const thoughtA2 = await findAllThoughtsByText('a')
Expand Down
2 changes: 2 additions & 0 deletions src/shortcuts/__tests__/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ describe('delete', () => {

executeShortcut(deleteShortcut, { store })

await vi.runOnlyPendingTimersAsync()

const popupValue = document.querySelector('[data-testid="popup-value"]')!
expect(popupValue.textContent).toBe('Permanently deleted test')
})
Expand Down
32 changes: 32 additions & 0 deletions src/shortcuts/__tests__/toggleSort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ describe('DOM', () => {

executeShortcut(toggleSortShortcut, { store })

await vi.runOnlyPendingTimersAsync()

const thoughtC = getThoughtByContext(['c'])
expect(thoughtC).toBeTruthy()

Expand All @@ -375,6 +377,8 @@ describe('DOM', () => {

executeShortcut(toggleSortShortcut, { store })

await vi.runOnlyPendingTimersAsync()

const thought = getThoughtByContext(['a'])
expect(thought).toBeTruthy()

Expand All @@ -399,6 +403,8 @@ describe('DOM', () => {

executeShortcut(toggleSortShortcut, { store })

await vi.runOnlyPendingTimersAsync()

const thought = getThoughtByContext(['c'])
expect(thought).toBeTruthy()

Expand All @@ -423,6 +429,8 @@ describe('DOM', () => {
executeShortcut(toggleSortShortcut, { store })
executeShortcut(toggleSortShortcut, { store })

await vi.runOnlyPendingTimersAsync()

const thoughtA = getThoughtByContext(['a'])
expect(thoughtA).toBeTruthy()

Expand Down Expand Up @@ -541,6 +549,8 @@ describe('DOM', () => {
newThought({ value: '' }),
])

await vi.runOnlyPendingTimersAsync()

const thoughts = screen.getAllByTestId(/thought/)
const childrenString = thoughts
.map((child: HTMLElement) => child.textContent)
Expand All @@ -567,6 +577,8 @@ describe('DOM', () => {
newThought({ value: '' }),
])

await vi.runOnlyPendingTimersAsync()

const thoughts = screen.getAllByTestId(/thought/)

const childrenString = thoughts
Expand Down Expand Up @@ -594,6 +606,8 @@ describe('DOM', () => {
newThought({ value: '' }),
])

await vi.runOnlyPendingTimersAsync()

const thoughts = screen.getAllByTestId(/thought/)

const childrenString = thoughts
Expand Down Expand Up @@ -621,6 +635,8 @@ describe('DOM', () => {
newThought({ value: '', insertBefore: true }),
])

await vi.runOnlyPendingTimersAsync()

const thoughts = screen.getAllByTestId(/thought/)

const childrenString = thoughts
Expand Down Expand Up @@ -648,6 +664,8 @@ describe('DOM', () => {
newThought({ value: '', insertBefore: true }),
])

await vi.runOnlyPendingTimersAsync()

const thoughts = screen.getAllByTestId(/thought/)

const childrenString = thoughts
Expand Down Expand Up @@ -675,6 +693,8 @@ describe('DOM', () => {
newThought({ value: '', insertBefore: true }),
])

await vi.runOnlyPendingTimersAsync()

const thoughts = screen.getAllByTestId(/thought/)

const childrenString = thoughts
Expand Down Expand Up @@ -708,6 +728,8 @@ describe('DOM', () => {
newThought({ value: '' }),
])

await vi.runOnlyPendingTimersAsync()

const thoughts = screen.getAllByTestId(/thought/)

const childrenString = thoughts
Expand Down Expand Up @@ -735,6 +757,8 @@ describe('DOM', () => {
newThought({ value: '', insertNewSubthought: true }),
])

await vi.runOnlyPendingTimersAsync()

const thoughts = screen.getAllByTestId(/thought/)

const childrenString = thoughts
Expand Down Expand Up @@ -763,6 +787,8 @@ describe('DOM', () => {
newThought({ value: '' }),
])

await vi.runOnlyPendingTimersAsync()

const thoughts = screen.getAllByTestId(/thought/)

const childrenString = thoughts
Expand Down Expand Up @@ -790,6 +816,8 @@ describe('DOM', () => {
newThought({ value: '', insertNewSubthought: true }),
])

await vi.runOnlyPendingTimersAsync()

const thoughts = screen.getAllByTestId(/thought/)

const childrenString = thoughts
Expand Down Expand Up @@ -817,6 +845,8 @@ describe('DOM', () => {
newThought({ value: '', insertNewSubthought: true, insertBefore: true }),
])

await vi.runOnlyPendingTimersAsync()

const thoughts = screen.getAllByTestId(/thought/)

const childrenString = thoughts
Expand Down Expand Up @@ -850,6 +880,8 @@ describe('DOM', () => {
),
])

await vi.runOnlyPendingTimersAsync()

const thoughts = screen.getAllByTestId(/thought/)

const childrenString = thoughts
Expand Down
Loading

0 comments on commit f8b53ef

Please sign in to comment.