Skip to content

Commit 99c2cbb

Browse files
Add JSDoc for report table test helpers and fixtures
1 parent 7983d61 commit 99c2cbb

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎tests/e2e/report-pagination.spec.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ test.describe('sorting', () => {
155155
test('clicking Priority flips the default to descending, then back to ascending', async ({ page }) => {
156156
const table = page.locator('table[data-rf-table="class-relationships"]');
157157
const priorityHeader = table.locator('thead th', { has: page.getByRole('button', { name: /Priority/ }) });
158+
/**
159+
* Reads the visible class relationship priorities in their current row order.
160+
* @returns {Promise<number[]>} Priorities on the currently rendered page.
161+
*/
158162
const priorities = () => table.locator('tbody tr td:nth-child(2)').allInnerTexts()
159163
.then(texts => texts.map(Number));
160164

‎tests/integration/report-view.test.jsx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,12 @@ function headerCell(utils, tableId, sortKey) {
413413
.find(th => th.querySelector(`[data-sort-key="${sortKey}"]`));
414414
}
415415

416+
/**
417+
* Finds all header cells in a rendered report table, in column order.
418+
* @param {object} utils - React Testing Library render result.
419+
* @param {string} tableId - Report table identifier.
420+
* @returns {Array<HTMLTableCellElement>} Matching table header cells.
421+
*/
416422
function headerCells(utils, tableId) {
417423
return [...utils.container.querySelectorAll(
418424
`table[data-rf-table="${tableId}"] thead th`)];
@@ -513,6 +519,10 @@ describe('enhanced report tables: sorting', () => {
513519
const utils = await renderReport();
514520
const { fireEvent } = await import('@testing-library/react');
515521

522+
/**
523+
* Reads the visible class relationship priorities in their current row order.
524+
* @returns {number[]} Priorities on the currently rendered page.
525+
*/
516526
const prioritiesOf = () => tableRows(utils, 'class-relationships')
517527
.map(row => Number(row.children[1].textContent.trim()));
518528

‎tests/unit/renderer.test.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ describe('templating safety (repository-provided templates are untrusted)', () =
189189
// template with paginated rows and tableUi metadata (plan Phase 3).
190190
// ---------------------------------------------------------------------------
191191

192+
/**
193+
* Builds relationship fixtures with out-of-order priorities to exercise sorting.
194+
* @param {number} count - Number of relationship rows to generate.
195+
* @returns {Array<object>} Synthetic relationship rows.
196+
*/
192197
function synthRelationships(count) {
193198
return Array.from({ length: count }, (_, i) => ({
194199
renderedLabel: `Class${String(count - i)} > Class${i}`,
@@ -201,6 +206,16 @@ function synthRelationships(count) {
201206
}));
202207
}
203208

209+
/**
210+
* Builds a report fixture with configurable table sizes and unsorted priorities.
211+
* @param {object} [options] - Row counts for each report table.
212+
* @param {number} [options.classRows=25] - Class relationship count.
213+
* @param {number} [options.pkgRows=5] - Package relationship count.
214+
* @param {number} [options.disharmonyRows=30] - Disharmony finding count.
215+
* @param {number} [options.cycleRows=21] - Cycle summary row count.
216+
* @param {number} [options.breakdownRows=3] - Largest-cycle breakdown row count.
217+
* @returns {object} Report data for renderer tests.
218+
*/
204219
function synthReport({ classRows = 25, pkgRows = 5, disharmonyRows = 30, cycleRows = 21, breakdownRows = 3 } = {}) {
205220
return {
206221
project: { name: 'Demo', version: '1.0' },

0 commit comments

Comments
 (0)