Skip to content

Conversation

pan-kot
Copy link
Member

@pan-kot pan-kot commented Sep 3, 2025

Description

Some of our integration tests fail when run against React 18 (in strict-mode). This PR fixes some of those.

To run tests with React 18 use this setup: #3829

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

const [refreshCounter, setRefreshCounter] = useState(0);
window.refreshItems = () => setRefreshCounter(prev => prev + 1);

useEffectOnUpdate(() => {
Copy link
Member Author

@pan-kot pan-kot Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The auto-refresh feature was not used in integration tests, but it was causing issues: in React 18 with strict mode the useEffectOnUpdate callback is triggered even when the dependencies did not change. As result, the table's state changed, causing some tests to fail.

<>
<h1>Syncing horizontal scrolls</h1>
<div
onScroll={() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This onScroll is not reached in React 18 + strict-mode. The nested onScroll do get triggered, so I moved the related code to those handlers instead.

const page = new BasePageObject(browser);
await page.setWindowSize({ width: 900, height: 800 });
await browser.url('#/light/table/tall-rows');
await page.waitForVisible(tableWrapper.findRows().toSelector());
Copy link
Member Author

@pan-kot pan-kot Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what we normally do in tests. Without this line the scroll on line 30 (page.windowScrollTo({ top: 200 })) caused no effect when run in React 18, thus making the test assertion fail.

setupTest({ actionsMode: 'inline' }, async page => {
await page.click('button[aria-label="Update item"]');
await expect(page.isFocused('button[aria-label="Update item"]')).resolves.toBe(true);
await page.click('button[aria-label="Update item"]:not([disabled])');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the newly generated data for table with grid navigation the first active "Update item" action moved to the 2nd row, so I updated the selector to ignore the prev row's disabled action.

Copy link

codecov bot commented Sep 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.10%. Comparing base (e41e149) to head (c8685a6).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3832   +/-   ##
=======================================
  Coverage   97.10%   97.10%           
=======================================
  Files         839      839           
  Lines       24419    24419           
  Branches     8624     8625    +1     
=======================================
  Hits        23711    23711           
+ Misses        701      658   -43     
- Partials        7       50   +43     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

await page.keys(['ArrowRight', 'ArrowDown', 'ArrowRight', 'ArrowRight']);
await expect(page.isFocused('tr[aria-rowindex="2"] button[aria-label="Update item"]')).resolves.toBe(true);
await page.keys(['ArrowRight', 'ArrowDown', 'ArrowDown', 'ArrowRight', 'ArrowRight']);
await expect(page.isFocused('tr[aria-rowindex="3"] button[aria-label="Update item"]')).resolves.toBe(true);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: small changes were required to account for the newly generated data.

@pan-kot pan-kot marked this pull request as ready for review September 3, 2025 09:55
@pan-kot pan-kot requested a review from a team as a code owner September 3, 2025 09:55
@pan-kot pan-kot requested review from mariksav and removed request for a team September 3, 2025 09:55
@pan-kot pan-kot enabled auto-merge September 3, 2025 09:55
@pan-kot pan-kot marked this pull request as draft September 3, 2025 09:58
auto-merge was automatically disabled September 3, 2025 09:58

Pull request was converted to draft

@pan-kot pan-kot force-pushed the chore-integ-tests-react18 branch from 91402e0 to 92ea2dc Compare September 3, 2025 10:09
@pan-kot pan-kot force-pushed the chore-integ-tests-react18 branch from 92ea2dc to c8685a6 Compare September 3, 2025 12:26
@pan-kot pan-kot removed the request for review from connorlanigan September 3, 2025 12:26

import { id, Instance } from './generate-data';

export const allInstances50: Instance[] = [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generated with generateItems(50). Having pre-generated items in test pages is better because we have tests that depends on specific item placements. These tests require adjustments every time we make changes to the order in which items are generated on the page.

@pan-kot pan-kot added this pull request to the merge queue Sep 4, 2025
Merged via the queue into main with commit b6e632c Sep 4, 2025
65 of 67 checks passed
@pan-kot pan-kot deleted the chore-integ-tests-react18 branch September 4, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants