Skip to content

Fix the Jest addNewDatagridRow helper so schema UI specs actually add a row. #10602 - #10624

Closed
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-10602-add-datagrid-row
Closed

dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-10602-add-datagrid-row

Conversation

@dpage

@dpage dpage commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

addNewDatagridRow queried [data-test="add-row"] button, but PgIconButton puts data-test on the <button> itself, so it matched nothing and user.click(null) clicked document.body. The helper now clicks [data-test="add-row"], asserts the button exists, and asserts that the grid's own row count went up by one.

Exercising the new-row path exposed two spec bugs, both fixed in the specs:

  • The primary key, unique constraint and foreign key specs reused one schema object across tests. The properties view sets field.helpMessage = '' on the schema's fields, and that then reached a DOM element in the later grid cells, tripping the console.error guard. Each test now gets a fresh schema, as each dialog does in the product.
  • The partitions 'create collection' spec forced the partition schema to be its own top, which never has session data, so top.sessData.partition_type threw. It now lets the collection become the top schema, as the table dialog does in the product.

Test plan

  • npx jest regression/javascript/schema_ui_files regression/javascript/SchemaView: 80 suites, 475 tests pass
  • eslint on the changed files is clean

Closes #10602

Summary by CodeRabbit

  • Tests
    • Improved regression checks to confirm that adding a data-grid row increases the direct row count by exactly one.
    • Isolated schema fixtures across tests to prevent changes in one test from affecting later grid-cell results.

… a row. pgadmin-org#10602

The helper looked for a button inside [data-test="add-row"], but that
attribute is on the button itself, so it clicked nothing. It now clicks the
right element and asserts that the grid gained a row.

That exposed two spec bugs: the primary key, unique constraint and foreign
key specs shared one schema across tests, so fields mutated by the
properties view leaked a helpMessage prop into later grid cells, and the
partitions spec made the partition schema its own top schema, which has
no session data.
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pgadmin-org/pgadmin4/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 14a368e6-e383-4b40-9c89-23656d0e8dfa
📥 Commits

Reviewing files that changed from the base of the PR and between b98470f and 998a935.

📒 Files selected for processing: 5
  • web/regression/javascript/genericFunctions.jsx
  • web/regression/javascript/schema_ui_files/foreign_key.ui.spec.js
  • web/regression/javascript/schema_ui_files/partition.utils.ui.spec.js
  • web/regression/javascript/schema_ui_files/primary_key.ui.spec.js
  • web/regression/javascript/schema_ui_files/unique_constraint.ui.spec.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.

Walkthrough

The add-row helper now verifies that it adds one direct grid row. Schema UI test changes document existing per-test setup and create fresh schema objects in partition, primary-key, and unique-constraint cases.

Changes

Schema UI Regression Tests

Layer / File(s) Summary
Verify direct grid row addition
web/regression/javascript/genericFunctions.jsx
The helper locates the add-row button, checks that the button and its containing grid exist, and verifies that the direct row count increases by one.
Update schema test setup
web/regression/javascript/schema_ui_files/foreign_key.ui.spec.js, web/regression/javascript/schema_ui_files/partition.utils.ui.spec.js, web/regression/javascript/schema_ui_files/primary_key.ui.spec.js, web/regression/javascript/schema_ui_files/unique_constraint.ui.spec.js
The foreign-key spec documents its existing per-test schema setup. The partition spec creates a new partition schema, and the primary-key and unique-constraint specs create fresh schemas for each test.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 998a9

The changes strengthen schema UI test setup and the add-row assertion. No concrete current-head behavior or required test contract warrants holding the PR.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: fixing the Jest addNewDatagridRow helper so schema UI tests verify row creation. It is concise and directly related to the pull request.
Linked Issues check Passed Issue #10602 requires addNewDatagridRow to select the button, click it, and verify that one row was added. genericFunctions.jsx now selects [data-test="add-row"], asserts the button and containi…
Out of Scope Changes check Passed The changes stay within issue #10602. The row-count helper strengthens the required test behavior. The schema fixture and partition setup changes correct failures exposed by exercising that behavior. …
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 5…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dpage

dpage commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Squashed and merged as 1402f7d.

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.

Jest helper addNewDatagridRow never adds a row, so schema UI specs don't test new rows

1 participant