Skip to content

add issue guidance to entity and entry page#950

Merged
DilwoarH merged 3 commits into
mainfrom
add-guidance-sections
Mar 7, 2025
Merged

add issue guidance to entity and entry page#950
DilwoarH merged 3 commits into
mainfrom
add-guidance-sections

Conversation

@DilwoarH
Copy link
Copy Markdown
Contributor

@DilwoarH DilwoarH commented Mar 6, 2025

Preview Link

https://submit-pr-950.herokuapp.com/organisations/local-authority:LBH/listed-building-outline/missing%20value/reference/entry

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

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

add issue guidance to entity and entry page

Related Tickets & Documents

  • Ticket Link
  • Related Issue #
  • Closes #

QA Instructions, Screenshots, Recordings

Before

Screenshot 2025-03-06 at 9 20 08 am

After

Screenshot 2025-03-06 at 9 20 23 am

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above.

  • Yes
  • No, and this is why: Please replace this line with details on why tests have not been included
  • I need help with writing tests

QA sign off

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

[optional] Are there any post-deployment tasks we need to perform?

[optional] Are there any dependencies on other PRs or Work?

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced issue details with comprehensive guidance for missing dataset columns, including clear instructions and links for further assistance.
    • Introduced a modular approach to issue specification, ensuring consistent and maintainable data presentation across multiple views.
    • Added a new HTML template to provide guidance on addressing dataset-related issues.
    • Integrated new middleware functionalities to improve data processing capabilities.
  • Refactor

    • Streamlined the incorporation of issue specification data into the rendering process, improving the overall clarity and consistency for end-user interactions.
    • Simplified template structure by offloading issue guidance rendering to a separate file.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 6, 2025

Walkthrough

This pull request introduces the getIssueSpecification function into the middleware, enhancing the processing pipeline. It modifies the entryIssueDetails.middleware.js to include new middleware functions and updates import statements. A new IssueSpecification schema is defined and integrated into relevant routes, replacing inline definitions. Additionally, HTML templates are updated to display issue guidance through an external include, streamlining the rendering process while maintaining existing logic and functionality.

Changes

File(s) Change Summary
src/middleware/entityIssueDetails.middleware.js
src/middleware/entryIssueDetails.middleware.js
Added getIssueSpecification to the middleware processing pipeline and updated the default export array to include new middleware functions.
src/middleware/common.middleware.js Introduced getIssueSpecification and processSpecificationMiddlewares functions, and updated the prepareIssueDetailsTemplateParams function to include issueSpecification in the request object.
src/routes/schemas.js Added a new IssueSpecification schema and updated OrgIssueTable and OrgIssueDetails schemas to reference this new schema instead of using inline definitions.
src/views/includes/_issue-guidance.html Created a new HTML template that displays issue guidance based on the issueSpecification object.
src/views/organisations/issueDetails.html
src/views/organisations/issueTable.html
Included the new _issue-guidance.html template in issueDetails.html and replaced an inline conditional block in issueTable.html with an include statement for the external guidance file.

Possibly related PRs

  • Add issue specification guidance to issueTable page #818: Related to the addition of the getIssueSpecification function in the same middleware file, indicating a direct code-level connection.
  • fix: invalid data range #839: Pertains to modifications in the src/middleware/common.middleware.js file, specifically the addition of the issueSpecification property to the req object, aligning with middleware enhancements.
  • Add issue table view #691: Involves modifications to middleware functions handling issue specifications, similar to the changes introduced in this PR.

Suggested labels

enhancement

Suggested reviewers

  • GeorgeGoodall-GovUk
  • rosado

Poem

In the fields of code I hop with glee,
Adding specs and functions for all to see,
Middleware marches with a brand new beat,
Schemas and templates harmonise neat,
A jolly rabbit sings as issues take flight,
Celebrating these changes with pure delight! 🐰


📜 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 f8ec991 and c135bab.

📒 Files selected for processing (3)
  • src/middleware/common.middleware.js (2 hunks)
  • src/middleware/entityIssueDetails.middleware.js (2 hunks)
  • src/middleware/entryIssueDetails.middleware.js (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/middleware/entityIssueDetails.middleware.js
  • src/middleware/entryIssueDetails.middleware.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (3)
src/middleware/common.middleware.js (3)

709-719: Well-structured feature implementation with feature flag

This new middleware function correctly extracts issue field specifications when the feature flag is enabled. The code properly handles the case when specification might not exist and follows the established patterns in the codebase.


722-722: Clean parameter extraction

The addition of issueSpecification to the destructured parameters is consistent with the introduction of the new feature.


735-736: LGTM - Template parameters enhanced

Adding issueSpecification to the template parameters completes the implementation, making the field specifications available to the template rendering process.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 Mar 6, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 66.83% 5461 / 8171
🔵 Statements 66.83% 5461 / 8171
🔵 Functions 64.18% 233 / 363
🔵 Branches 80.42% 719 / 894
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/middleware/common.middleware.js 70.65% 92.07% 43.47% 70.65% 26-35, 39, 55-56, 58-59, 71-73, 77, 93-100, 193-194, 206-217, 223-245, 343, 352-354, 384-386, 424-438, 478-482, 487-490, 502-506, 534-548, 555-566, 572-580, 584-600, 669-671, 744-751, 765-820
src/middleware/entityIssueDetails.middleware.js 100% 76.19% 100% 100%
src/middleware/entryIssueDetails.middleware.js 81.56% 76% 57.14% 81.56% 22-24, 46-57, 83-86, 126-132
src/routes/schemas.js 100% 100% 100% 100%
Generated in workflow #943 for commit c135bab by the Vitest Coverage Report Action

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: 0

🧹 Nitpick comments (2)
src/views/includes/_issue-guidance.html (1)

1-27: Well-structured issue guidance component.

The component provides clear, actionable guidance for fixing dataset issues. The conditional rendering based on the presence of issueSpecification is appropriate, and the use of the GOV.UK Design System components maintains visual consistency.

Some suggestions to enhance accessibility and user experience:

  1. Consider adding an id attribute to the issue guidance section for better navigation and potential anchor linking.
  2. The guidance text could benefit from more structured content patterns from the GOV.UK Design System, such as warning text component for critical issues.
src/middleware/entryIssueDetails.middleware.js (1)

2-2: Consider organizing the imports for better readability.

This import line has become quite long with the addition of getIssueSpecification and processSpecificationMiddlewares. Consider organizing these imports for better readability, perhaps by grouping them by functionality or arranging them alphabetically.

-import { createPaginationTemplateParams, fetchDatasetInfo, fetchEntryIssues, fetchOrgInfo, fetchResources, getErrorSummaryItems, getIssueSpecification, getSetBaseSubPath, getSetDataRange, logPageError, prepareIssueDetailsTemplateParams, processSpecificationMiddlewares, show404IfPageNumberNotInRange, validateQueryParams } from './common.middleware.js'
+import { 
+  createPaginationTemplateParams,
+  fetchDatasetInfo,
+  fetchEntryIssues,
+  fetchOrgInfo,
+  fetchResources,
+  getErrorSummaryItems,
+  getIssueSpecification,
+  getSetBaseSubPath,
+  getSetDataRange,
+  logPageError,
+  prepareIssueDetailsTemplateParams,
+  processSpecificationMiddlewares,
+  show404IfPageNumberNotInRange,
+  validateQueryParams
+} from './common.middleware.js'
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 08a9d15 and 58eef0e.

📒 Files selected for processing (6)
  • src/middleware/entityIssueDetails.middleware.js (3 hunks)
  • src/middleware/entryIssueDetails.middleware.js (4 hunks)
  • src/routes/schemas.js (3 hunks)
  • src/views/includes/_issue-guidance.html (1 hunks)
  • src/views/organisations/issueDetails.html (1 hunks)
  • src/views/organisations/issueTable.html (1 hunks)
🔇 Additional comments (12)
src/views/organisations/issueDetails.html (1)

97-97: Good addition of the issue guidance component.

Including the issue guidance template before the "How to improve" section provides a logical flow of information. This approach enhances user experience by first explaining the specific issue and then providing general improvement steps.

src/views/organisations/issueTable.html (1)

99-99: Good reuse of the issue guidance component.

Including the shared issue guidance template promotes consistency across different views and reduces code duplication. This modular approach will make future maintenance easier.

src/routes/schemas.js (3)

108-114: Good schema definition for issue specification.

The IssueSpecification schema is well-structured with appropriate field definitions. Making it optional allows for flexibility in different contexts.


223-223: Correct implementation of issue specification schema in OrgIssueTable.

Using the centrally defined IssueSpecification schema maintains consistency and reduces duplication.


246-247: Appropriate addition of issue specification to OrgIssueDetails.

Adding the issueSpecification field to the OrgIssueDetails schema ensures consistent validation across the application.

src/middleware/entityIssueDetails.middleware.js (3)

17-18: Import updated to include the new middleware function.

The import statement has been updated to include getIssueSpecification from the common middleware file, which is consistent with its addition to the middleware pipeline later in this file.


112-115: Template parameters now include issue specification data.

The templateParams function has been updated to include the issueSpecification property from the request object. This is done cleanly using the spread operator to maintain existing template parameters while adding the new data.


128-128: Added issue specification middleware to the processing pipeline.

The getIssueSpecification middleware has been added to the default export array, positioned before filterOutEntitiesWithoutIssues. This ensures that the issue specification is available for subsequent middleware functions.

src/middleware/entryIssueDetails.middleware.js (4)

22-23: SQL query formatting improved.

The SQL query formatting has been adjusted to remove an unnecessary line break, improving consistency in the code.


135-138: Template parameters now include issue specification data.

The templateParams function has been updated to include the issueSpecification property from the request object, consistent with the changes in the entity issue details middleware. This provides the necessary data for displaying issue guidance in the template.


149-150: Added specification middleware to the processing pipeline.

Two middleware functions have been added to the default export array:

  1. processSpecificationMiddlewares - Likely processes specification data needed for issue guidance
  2. getIssueSpecification - Retrieves and prepares issue specification data

Their positioning after data fetching but before further processing is appropriate.


1-165:

Details

✅ Verification successful

Verify that the new middleware functions exist and are properly implemented.

The changes in this file and entityIssueDetails.middleware.js both reference getIssueSpecification and processSpecificationMiddlewares, but these functions aren't visible in the provided code. Ensure they're properly implemented in common.middleware.js.


🏁 Script executed:

#!/bin/bash
# Check for the implementation of the new middleware functions in common.middleware.js
grep -n "getIssueSpecification\|processSpecificationMiddlewares" src/middleware/common.middleware.js

Length of output: 216


Middleware Functions Verified
Both processSpecificationMiddlewares and getIssueSpecification have been located in src/middleware/common.middleware.js (lines 330 and 709, respectively) and appear to be correctly implemented. No further action is required regarding these functions.

@DilwoarH DilwoarH changed the title add issue guidance to check results, entity and entry page add issue guidance to entity and entry page Mar 6, 2025
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

🧹 Nitpick comments (1)
test/unit/views/includes/_issue-guidance.test.js (1)

1-61: Consider adding more boundary cases for robust testing.

While the current tests cover the main scenarios well, consider adding tests for additional edge cases:

  1. When issueSpecification is present but empty ({})
  2. When dataset is missing but issueSpecification is present
  3. When field names contain special characters that might need escaping in HTML

These additional tests would further strengthen the robustness of your component.

🧰 Tools
🪛 GitHub Actions: Unit test coverage report

[error] 1-1: Failed to load url @jest/globals (resolved id: @jest/globals) in /home/runner/work/submit/submit/test/unit/views/includes/_issue-guidance.test.js. Does the file exist?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 58eef0e and 6d18538.

📒 Files selected for processing (1)
  • test/unit/views/includes/_issue-guidance.test.js (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Unit test coverage report
test/unit/views/includes/_issue-guidance.test.js

[error] 1-1: Failed to load url @jest/globals (resolved id: @jest/globals) in /home/runner/work/submit/submit/test/unit/views/includes/_issue-guidance.test.js. Does the file exist?

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (3)
test/unit/views/includes/_issue-guidance.test.js (3)

4-8: LGTM! Good test for empty state handling.

This first test correctly verifies that the template doesn't render anything when no issue specification is provided, which is an important edge case to cover.


10-37: Good thorough testing of rendered guidance elements.

This test provides comprehensive coverage of the component's rendering capabilities when a complete issue specification is provided. The assertions check all key elements: headings, missing column message, guidance content, and field name display.


39-59: LGTM! Good test for partial data handling.

This test properly verifies the template's behavior when guidance text is missing, ensuring the UI degrades gracefully without showing empty sections.

Comment thread test/unit/views/includes/_issue-guidance.test.js Outdated
@DilwoarH DilwoarH force-pushed the add-guidance-sections branch from 6d18538 to a1d5868 Compare March 6, 2025 09:24
@DilwoarH DilwoarH self-assigned this Mar 6, 2025
@DilwoarH DilwoarH moved this from Refined to Code review & QA in Providers team (BACKLOG) Mar 6, 2025
@rosado rosado self-requested a review March 6, 2025 10:33
Comment thread src/middleware/entityIssueDetails.middleware.js Outdated
Comment thread src/middleware/entryIssueDetails.middleware.js Outdated
@DilwoarH DilwoarH temporarily deployed to submit-pr-950 March 6, 2025 22:31 Inactive
@DilwoarH DilwoarH merged commit 00be274 into main Mar 7, 2025
@github-project-automation github-project-automation Bot moved this from Code review & QA to Ready for release in Providers team (BACKLOG) Mar 7, 2025
@DilwoarH DilwoarH deleted the add-guidance-sections branch March 7, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done Archived

Development

Successfully merging this pull request may close these issues.

4 participants