Skip to content

check tool: render column names unchanged#1012

Merged
rosado merged 16 commits into
mainfrom
rosado/949-column-names
May 2, 2025
Merged

check tool: render column names unchanged#1012
rosado merged 16 commits into
mainfrom
rosado/949-column-names

Conversation

@rosado
Copy link
Copy Markdown
Contributor

@rosado rosado commented Apr 4, 2025

Preview Link

https://submit-pr-[PR_NUMBER].herokuapp.com/

What type of PR is this? (check all applicable)

  • Bug Fix
  • Refactoring

Description

Ensures the column names in check tool result table are rendered unchanged. User will see the same column names as in their CSV etc.

Additionally

  • some cleanups in check tool related code: removed no longer used functions, simplified some of the existing ones.
  • updated the table.html template to take optional options (if not passed, no change in current behaviour).

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Before

image

After

image

Added/updated tests?

  • Yes

QA sign off

  • Code has been checked and approved
  • Design has been checked and approved
  • Product and business logic has been checked and proved

Summary by CodeRabbit

  • New Features

    • Introduced customisable table display options featuring a direct column name processing mode and flexible field-to-column mapping, allowing data to be presented more clearly.
  • Refactor

    • Streamlined the data arrangement process for table results, ensuring greater consistency and reliability in the displayed information.
    • Improved pagination handling and enhanced mapping between field names and column names in table parameters.
    • Simplified field retrieval with caching in response details and removed legacy error summary functionality for cleaner data handling.
  • Tests

    • Added new tests for field-to-column mapping functionality.
    • Updated existing tests to reflect changes in data mapping and removed obsolete error summary tests.

User will see the same column names as in their CSV etc.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 4, 2025

"""

Walkthrough

The pull request implements multiple changes across production and test files. In production code, it enhances request handling and data mapping by augmenting the RequestWithDetails typedef, adding a new field mapping function, and adjusting table parameter construction. Additionally, obsolete error summary and column functionality are removed from model classes and the table component is made more configurable. Test files are updated accordingly with simplified imports, adjusted expectations, and removal of deprecated tests.

Changes

File(s) Change Summary
src/controllers/resultsController.js, src/models/requestData.js, src/models/responseDetails.js, src/views/components/table.html Enhanced RequestWithDetails typedef (added parsedParams, locals.requestData, locals.responseDetails, locals.template); introduced new function fieldToColumnMapping for bi-directional mapping; updated setupTableParams to use new mappings and extract pagination from req.parsedParams; removed getErrorSummary from ResultData; simplified field retrieval in ResponseDetails by caching and removed getColumns; made table component more flexible with new columnNameProcessing and mapping parameters.
test/integration/test_recieving_results.playwright.test.js, test/unit/requestData.test.js, test/unit/responseDetails.test.js, test/unit/resultsController.test.js Updated import paths (added .js extension); removed tests for deprecated methods like getErrorSummary and getColumns; added new tests for fieldToColumnMapping and updated expectations for setupTableParams (now synchronous with added properties such as columnNameProcessing and mapping); simplified header mapping tests in integration.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Controller as ResultsController
    participant Response as ResponseDetails
    Client->>Controller: Send HTTP request with parsedParams
    Controller->>Response: Retrieve response details (cached if available)
    Controller->>Controller: Execute fieldToColumnMapping(details)
    Controller->>Controller: Construct tableParams (columns, fields, mapping)
    Controller->>Client: Return response with tableParams
Loading

Assessment against linked issues

Objective (Issue) Addressed Explanation
Ensure field names in the data table match the specification (e.g. #949)

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • GeorgeGoodall-GovUk

Poem

I'm a little rabbit, hopping through the code,
Mapping fields and columns on a winding road.
New functions bloom like carrots bright,
In clever tests our changes take flight.
With every hop and every tweak,
Our code garden sings—smooth and sleek!
🥕🐇 Happy coding!
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ed2120 and 3f306f8.

📒 Files selected for processing (1)
  • test/integration/test_recieving_results.playwright.test.js (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/integration/test_recieving_results.playwright.test.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 4, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 66.07% 5840 / 8838
🔵 Statements 66.07% 5840 / 8838
🔵 Functions 64.82% 247 / 381
🔵 Branches 79% 745 / 943
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/controllers/resultsController.js 61.8% 63.15% 51.85% 61.8% 19-37, 64-68, 72-76, 84-85, 87-88, 92-93, 132-134, 163-171, 183-184, 219-220, 229-237, 240-243, 246-258, 271-295, 305-306, 333-335, 351-356, 364-376, 383-404, 416-426, 429-431, 440-453
src/models/requestData.js 94.84% 95.23% 100% 94.84% 44-48
src/models/responseDetails.js 95.29% 90% 100% 95.29% 77-78, 145-146, 173-178, 263
Generated in workflow #1059 for commit 4d46b82 by the Vitest Coverage Report Action

Also: simplify and remove code
@rosado rosado marked this pull request as ready for review April 11, 2025 09:13
@rosado rosado requested a review from DilwoarH April 11, 2025 09:13
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 531b6ab and 32ae2e9.

📒 Files selected for processing (8)
  • src/controllers/resultsController.js (3 hunks)
  • src/models/requestData.js (0 hunks)
  • src/models/responseDetails.js (3 hunks)
  • src/views/components/table.html (2 hunks)
  • test/integration/test_recieving_results.playwright.test.js (2 hunks)
  • test/unit/requestData.test.js (1 hunks)
  • test/unit/responseDetails.test.js (1 hunks)
  • test/unit/resultsController.test.js (3 hunks)
💤 Files with no reviewable changes (1)
  • src/models/requestData.js
🧰 Additional context used
🧬 Code Graph Analysis (3)
test/unit/resultsController.test.js (1)
src/controllers/resultsController.js (14)
  • setupTableParams (154-210)
  • req (121-121)
  • req (203-203)
  • req (229-229)
  • req (240-240)
  • req (246-246)
  • req (271-271)
  • req (351-351)
  • req (364-364)
  • req (383-383)
  • req (434-434)
  • req (478-478)
  • fieldToColumnMapping (142-146)
  • fieldToColumnMapping (142-146)
test/integration/test_recieving_results.playwright.test.js (3)
test/acceptance/request_check.test.js (1)
  • response (119-119)
src/middleware/entryIssueDetails.middleware.js (1)
  • details (71-75)
src/utils/table.js (2)
  • leading (19-19)
  • trailing (20-20)
src/controllers/resultsController.js (2)
src/utils/table.js (2)
  • splitByLeading (18-31)
  • splitByLeading (18-31)
src/services/performanceDbApi.js (1)
  • req (387-387)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (22)
test/unit/responseDetails.test.js (1)

121-121: Update to test expectations reflects column naming change.

The test now expects raw field names from the getFields method rather than the previously transformed versions, which aligns with the PR objective to display column names exactly as they appear in the user's CSV files.

test/unit/requestData.test.js (2)

2-2: Consistent file extension usage for imports.

This change standardises the import by adding the .js extension to the path, which improves consistency across the codebase.


5-5: Consistent file extension usage for imports.

Same standardisation for the logger import.

src/views/components/table.html (5)

31-38: Added optional parameters for enhanced column name handling.

These new parameters provide flexibility for column name rendering:

  • columnNameProcessing allows the raw field names to be displayed without transformation
  • mapping enables field-to-column mapping for correct data display

This implementation directly supports the PR objective to display column names exactly as they appear in source files.


54-62: Added conditional rendering for column names.

This change allows column names to be displayed either as they are (with basic escaping) or with the prettifyColumnName filter applied, based on the new columnNameProcessing parameter. Good use of the template's conditional logic to maintain backward compatibility.


66-66: Simplified mapping access in templates.

Setting mapping as a local variable improves readability in the template.


70-70: Enhanced column data lookup using mappings.

Now supports field-to-column mapping with a fallback to direct access, allowing for dynamic column name handling.


72-77: Consistent error message handling with column name processing.

Appropriately applies the same column name processing logic to error messages, ensuring consistent display throughout the table.

test/unit/resultsController.test.js (4)

2-14: Updated imports to include new fieldToColumnMapping function.

The import statement now includes the new utility function that handles field-to-column mapping, ensuring all necessary components are available for testing.


135-135: Removed async/await for synchronous function call.

The setupTableParams function is now called without await since it operates synchronously, improving code correctness.


137-143: Updated test expectations for table parameters.

The test now expects the new parameters required by the enhanced table component:

  • columnNameProcessing set to 'none' to preserve original field names
  • mapping initialized as an empty Map for column mapping

This correctly validates the updated behavior of the setupTableParams function.


307-329: Added comprehensive tests for the new fieldToColumnMapping function.

Good test coverage for the new utility function:

  1. Verifies correct mapping creation with various field types
  2. Handles the edge case of empty column data

These tests ensure the mapping function works correctly, which is essential for the proper display of column names in the check tool result table.

src/models/responseDetails.js (3)

34-35: Good addition of a private cache field.

Adding a private cache field for storing the result of potentially expensive operations is a good performance improvement.


53-55: Improved documentation with JSDoc return type.

Adding the return type to the JSDoc comment improves code clarity and helps with type checking.


66-74: Improved documentation clarifying field usage.

The updated JSDoc comments provide better clarity about what the fields represent and how they're used.

test/integration/test_recieving_results.playwright.test.js (2)

12-17: Good practice adding .js extensions to imports.

Adding the .js extension to import statements is good practice and helps with module resolution in modern JavaScript environments.


104-120: Simplified table value generation aligns with PR objectives.

The function has been simplified to directly use column names from the converted row data without transformation, which aligns with the PR objective to "render column names unchanged".

src/controllers/resultsController.js (5)

106-111: Enhanced type definitions improve code clarity.

The expanded TypeScript definitions for RequestWithDetails improve code clarity and documentation.


138-146: Well-structured mapping function.

The new fieldToColumnMapping function is well-structured, appropriately documented with JSDoc comments, and follows functional programming principles by using tuple destructuring and mapping.


180-185: Good bidirectional mapping implementation.

Creating bidirectional mappings between fields and columns is a good approach for maintaining data relationships.


187-189: Clear explanation of the intention in comments.

The comment clearly explains the intention to preserve original CSV column names for users, which aligns well with the PR objectives.


190-198: Simplified table parameters with explicit column name handling.

The updated table parameters explicitly specify 'none' for column name processing and include the mapping, which supports the goal of preserving original column names.

Comment thread src/models/responseDetails.js
Comment thread src/controllers/resultsController.js Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c6a388 and ef86ea8.

📒 Files selected for processing (1)
  • test/integration/test_recieving_results.playwright.test.js (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
test/integration/test_recieving_results.playwright.test.js (1)
src/utils/table.js (2)
  • leading (19-19)
  • trailing (20-20)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (3)
test/integration/test_recieving_results.playwright.test.js (3)

12-12: Good update adding .js extensions to import paths.

The addition of explicit .js extensions to import statements improves module compatibility across different environments.

Also applies to: 14-14, 17-17


50-54: Good addition of 'reference' column handling.

This code correctly adds a 'reference' column header and empty values to match the updated table structure, ensuring test data aligns with the new column display requirements.


110-127: Good refactoring to preserve original column names.

The function has been correctly simplified to derive column headers directly from the data structure without transformation, aligning with the PR objective to display column names unchanged from the CSV files.

Comment thread test/integration/test_recieving_results.playwright.test.js Outdated
Comment thread src/models/responseDetails.js
Comment thread src/views/components/table.html
Comment thread test/integration/test_recieving_results.playwright.test.js Outdated
@rosado rosado temporarily deployed to development May 2, 2025 14:25 — with GitHub Actions Inactive
@rosado rosado merged commit fbb4541 into main May 2, 2025
5 checks passed
@rosado rosado deleted the rosado/949-column-names branch May 2, 2025 14:36
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.

Fields in data table are not reflecting what is in the guidance/specification

2 participants