Skip to content

Fixes #39492 - Replace enzyme test in SettingsTable, SettingsCell, SettingsName with RTL - #11084

Closed
kfamilonidis wants to merge 1 commit into
theforeman:developfrom
kfamilonidis:pf5-setttings-table
Closed

Fixes #39492 - Replace enzyme test in SettingsTable, SettingsCell, SettingsName with RTL#11084
kfamilonidis wants to merge 1 commit into
theforeman:developfrom
kfamilonidis:pf5-setttings-table

Conversation

@kfamilonidis

Copy link
Copy Markdown
Contributor

Fixes #39492: Replace enzyme test in SettingsTable, SettingsCell, SettingsName with RTL

@Lukshio

Lukshio commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@kfamilonidis please add more testing cases

@Lukshio Lukshio self-assigned this Jul 8, 2026
@kfamilonidis
kfamilonidis force-pushed the pf5-setttings-table branch from 8f88452 to c75b1ae Compare July 8, 2026 11:15
@kfamilonidis

Copy link
Copy Markdown
Contributor Author

Added 4 more tests that check the settings table values (instead of row headers that was before)

@kfamilonidis
kfamilonidis force-pushed the pf5-setttings-table branch 3 times, most recently from 5ff80b6 to aabfb44 Compare July 8, 2026 13:42
@Lukshio

Lukshio commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Good migration across SettingsTable, SettingCell, and SettingName. The author already responded to the earlier "please add more testing cases" feedback by adding 4 behavior-driven tests (cell text, cancel-exits-edit, Escape-exits-edit, select-submit). Solid overall.

Critical (must fix before merge)

  • None

Suggestions (should fix)

  • SettingsTable.test.js still builds its store with configureMockStore/mockStore (redux-mock-store). The project's testing guidelines call this out as deprecated for new tests in favor of a real store with initial-state fixtures. Since this PR already reworks the surrounding tests, consider swapping it out here (or note it as a deliberate, scoped-out follow-up).
  • Several assertions use raw document.querySelector('button#administrator') / [data-ouia-component-id=...] instead of RTL's screen.getByRole/getByLabelText. This matches the pre-existing style in the file, so not a regression, but worth moving to accessible queries where a role/label exists, for resilience if ids ever change.
  • Commit message uses Fixes #39492: ... - the documented convention (see develop history, e.g. Fixes #38653 - Fix settings show endpoint) is Fixes #XXXXX - description with a hyphen, not a colon.

Nice to have (optional)

  • None beyond the above.

Checklist gaps

  • redux-mock-store usage not addressed (see above).
  • Commit message hyphen convention.

@kfamilonidis

Copy link
Copy Markdown
Contributor Author

@Lukshio Replaced mock store with a real redux store.
I changed in the three interaction tests with role based assertions.
Left on data-ouia-* deliberately, with a comment noting why.

@kfamilonidis
kfamilonidis force-pushed the pf5-setttings-table branch from a38df2e to a0b5b6f Compare July 14, 2026 14:09
@kfamilonidis kfamilonidis changed the title Fixes #39492: Replace enzyme test in SettingsTable, SettingsCell, SettingsName with RTL Fixes #39492 - Replace enzyme test in SettingsTable, SettingsCell, SettingsName with RTL Jul 15, 2026
)

async function extracted(text = '') {
const editButton = document.querySelector('button#http_proxy_except_list');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please use screen.getByRole instead of querySelector. Here and on line 110-120 and 190-191, as per the guideline https://github.com/theforeman/foreman/blob/develop/developer_docs/ui-testing-guidelines.asciidoc

describe('SettingCell', () =>
testComponentSnapshotsWithFixtures(SettingValue, fixtures));
// Render the tooltip content inline instead of through the Popper, so the
// computed tooltipText can be asserted without hover/async teardown issues.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@@ -177,4 +166,75 @@ describe('SettingsTable', () => {
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

On lines 100, 130, 141, 151, and 161 we have toHaveBeenCalledTimes which is incremented after every test. This approach is a bit fragile, imo. A better approach would be to use jest.clearAllMocks in between tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@kfamilonidis this wasn't handled. Please make this change as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added the after each hook

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, but the comment was about the use of toHaveBeenCalledTimes instead of toHaveBeenCalled and adding jest.clearAllMocks. Please use toHaveBeenCalled on those.

@@ -177,4 +166,75 @@ describe('SettingsTable', () => {
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@kfamilonidis this wasn't handled. Please make this change as well

@@ -177,4 +166,75 @@ describe('SettingsTable', () => {
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, but the comment was about the use of toHaveBeenCalledTimes instead of toHaveBeenCalled and adding jest.clearAllMocks. Please use toHaveBeenCalled on those.

@andreilakatos

Copy link
Copy Markdown
Contributor

@Lukshio Good to go

@andreilakatos

Copy link
Copy Markdown
Contributor

@Lukshio
@kfamilonidis
This PR should be closed as well, created 3 PR's for the same thing, 2 of them were merged:
#11211
#11209
#11212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants