Skip to content

Add issue specification guidance to issueTable page#818

Merged
DilwoarH merged 6 commits into
mainfrom
782-technical-spike-how-will-we-surface-guidance-content-snippets
Jan 31, 2025
Merged

Add issue specification guidance to issueTable page#818
DilwoarH merged 6 commits into
mainfrom
782-technical-spike-how-will-we-surface-guidance-content-snippets

Conversation

@DilwoarH
Copy link
Copy Markdown
Contributor

@DilwoarH DilwoarH commented Jan 22, 2025

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

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

Description

Add issue specification guidance to issue table page

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Before

screenshot-submit_planning_data_gov_uk-2025_01_28-10_24_57

After

screenshot-localhost_5000-2025_01_28-10_24_18

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

Release Notes

  • New Features

    • Added issue specification guidance to the issue table view.
    • Enhanced issue table middleware to support additional specification details.
  • Improvements

    • Introduced a new optional property for more detailed issue specifications in the schema.
    • Added context-aware guidance for missing dataset columns.
  • Chores

    • Added a "Preview Link" section to the pull request template for enhanced visibility.

The update provides a more informative user experience by displaying contextual information about potential dataset issues and their recommended resolutions.

@DilwoarH DilwoarH linked an issue Jan 22, 2025 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 22, 2025

Walkthrough

This pull request introduces a new function getIssueSpecification to handle issue specifications across multiple files. The function retrieves issue field specifications from request parameters and updates the middleware to pass this information to the template rendering logic. Additionally, an optional issueSpecification property is added to the OrgIssueTable schema, and the HTML view is updated to display guidance related to issue specifications when available.

Changes

File Change Summary
src/middleware/common.middleware.js Added getIssueSpecification function to retrieve issue field specifications.
src/middleware/issueTable.middleware.js Imported getIssueSpecification and added issueSpecification to template parameters.
src/routes/schemas.js Added optional issueSpecification property to OrgIssueTable schema.
src/views/organisations/issueTable.html Added new section to display issue specification guidance using govukInsetText.
.github/PULL_REQUEST_TEMPLATE.md Added new section for "Preview Link" in the pull request template.
config/default.yaml Added features.issueSpecificationGuidance with enabled: false.
config/development.yaml Added features.issueSpecificationGuidance with enabled: true.
config/local.yaml Added features.issueSpecificationGuidance with enabled: true.
config/production.yaml Added features.issueSpecificationGuidance with enabled: false.
config/staging.yaml Added features.issueSpecificationGuidance with enabled: true.
config/test.yaml Added features.issueSpecificationGuidance with enabled: true.
test/unit/middleware/common.middleware.test.js Added tests for getIssueSpecification function to validate its behaviour.

Possibly related PRs

  • fix: a few type errors #589: This PR modifies the src/middleware/common.middleware.js file, which is directly related to the main PR as it also involves changes to the same file, specifically the addition of new functions and modifications to existing middleware functionality.
  • Add issue table view #691: This PR introduces new middleware functions and modifies existing ones in src/middleware/issueTable.middleware.js, which may interact with the getIssueSpecification function added in the main PR.
  • 684 issue details fetch data from all active resources #707: This PR updates the src/middleware/entryIssueDetails.middleware.js and introduces a new middleware function that checks for the presence of issues, which could relate to the handling of issue specifications in the main PR.

Suggested Labels

enhancement

Suggested Reviewers

  • GeorgeGoodall-GovUk

Poem

🐰 A rabbit's tale of specs so bright,
Middleware dancing with pure delight,
Issue guidance now takes flight,
With columns clear and context tight,
Code evolves with rabbit might! 🔍


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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. (Beta)
  • @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 Jan 22, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 69.29% 5548 / 8006
🔵 Statements 69.29% 5548 / 8006
🔵 Functions 67.27% 220 / 327
🔵 Branches 82.25% 709 / 862
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/middleware/common.middleware.js 73.26% 92.07% 43.47% 73.26% 24-33, 37, 53-54, 56-57, 69-71, 75, 91-98, 175-176, 188-199, 205-227, 325, 334-336, 366-368, 406-420, 460-464, 469-472, 484-488, 516-530, 537-548, 554-562, 566-582, 651-653, 725-732, 746-801
src/middleware/issueTable.middleware.js 98.48% 95.83% 85.71% 98.48% 44-45
src/routes/schemas.js 100% 100% 100% 100%
Generated in workflow #697 for commit a0f3893 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: 3

🧹 Nitpick comments (1)
src/views/organisations/issueTable.html (1)

100-128: Improve accessibility of the guidance link.

The implementation follows GOV.UK Design System patterns well. However, the guidance link could be more accessible.

Apply this diff to improve the link's accessibility:

-      <p class="govuk-body">The <a href="{{ dataset.dataset | getDatasetGuidanceUrl }}" target="_blank">{{ dataset.name }}</a> guidance explains how to fix the issue:</p>
+      <p class="govuk-body">The <a href="{{ dataset.dataset | getDatasetGuidanceUrl }}" target="_blank" rel="noopener noreferrer">{{ dataset.name }} guidance (opens in new tab)</a> explains how to fix the issue:</p>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2fcf34a and 65c3291.

📒 Files selected for processing (4)
  • src/middleware/common.middleware.js (1 hunks)
  • src/middleware/issueTable.middleware.js (4 hunks)
  • src/routes/schemas.js (1 hunks)
  • src/views/organisations/issueTable.html (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (3)
src/middleware/issueTable.middleware.js (1)

Line range hint 77-89: LGTM! Template parameters are correctly updated.

The issueSpecification parameter is properly destructured from the request object and added to the template parameters.

src/routes/schemas.js (1)

214-219: LGTM! Schema definition is well-structured.

The issueSpecification property is properly defined with:

  • Appropriate optional wrapper
  • Strict object validation
  • Required and optional fields with proper types
src/views/organisations/issueTable.html (1)

7-7: LGTM! Macro import is correctly placed.

The govukInsetText macro is properly imported from the GOV.UK Design System.

Comment thread src/middleware/issueTable.middleware.js Outdated
Comment thread src/middleware/issueTable.middleware.js Outdated
Comment thread src/middleware/common.middleware.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 65c3291 and 192c9e8.

📒 Files selected for processing (1)
  • .github/PULL_REQUEST_TEMPLATE.md (1 hunks)
🧰 Additional context used
🪛 Markdownlint (0.37.0)
.github/PULL_REQUEST_TEMPLATE.md

17-17: null
Bare URL used

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (1)
.github/PULL_REQUEST_TEMPLATE.md (1)

Line range hint 1-14: The PR template structure looks good!

The template follows GitHub's best practices and includes comprehensive sections for documenting PRs effectively.

Also applies to: 19-89

🧰 Tools
🪛 Markdownlint (0.37.0)

17-17: null
Bare URL used

(MD034, no-bare-urls)

Comment thread .github/PULL_REQUEST_TEMPLATE.md
@DilwoarH DilwoarH force-pushed the 782-technical-spike-how-will-we-surface-guidance-content-snippets branch from 3cc9a34 to fbb4c93 Compare January 28, 2025 10:15
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

♻️ Duplicate comments (1)
.github/PULL_REQUEST_TEMPLATE.md (1)

15-24: ⚠️ Potential issue

Format the preview link section properly.

The preview link section needs proper formatting as previously suggested.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

23-23: Bare URL used
null

(MD034, no-bare-urls)

🧹 Nitpick comments (2)
test/unit/middleware/common.middleware.test.js (1)

1388-1455: Consider adding more test cases for better coverage.

The test suite is well-structured, but could benefit from additional test cases:

  1. Test when issue_field parameter is missing in req.params
  2. Test when field specification has empty description or guidance properties
 describe('getIssueSpecification', () => {
+    it('handles missing issue_field parameter', () => {
+      const req = {
+        params: {},
+        specification: {
+          fields: [
+            { field: 'field1', description: 'string' }
+          ]
+        }
+      }
+      const res = {}
+      const next = vi.fn()
+
+      getIssueSpecification(req, res, next)
+
+      expect(req.issueSpecification).toBeUndefined()
+      expect(next).toHaveBeenCalledTimes(1)
+    })
+
+    it('handles field with empty description and guidance', () => {
+      const req = {
+        params: { issue_field: 'field1' },
+        specification: {
+          fields: [
+            { field: 'field1', description: '', guidance: '' }
+          ]
+        }
+      }
+      const res = {}
+      const next = vi.fn()
+
+      getIssueSpecification(req, res, next)
+
+      expect(req.issueSpecification).toEqual({ field: 'field1', description: '', guidance: '' })
+      expect(next).toHaveBeenCalledTimes(1)
+    })
src/views/organisations/issueTable.html (1)

117-119: Consider using a more specific heading.

The current heading "How to fix this issue" is generic. Consider making it more specific to the context, such as "How to fix the missing column issue".

-      <h2 class="govuk-heading-l">
-        How to fix this issue
-      </h2>
+      <h2 class="govuk-heading-l">
+        How to fix the missing column issue
+      </h2>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3cc9a34 and afcac26.

📒 Files selected for processing (6)
  • .github/PULL_REQUEST_TEMPLATE.md (1 hunks)
  • src/middleware/common.middleware.js (1 hunks)
  • src/middleware/issueTable.middleware.js (4 hunks)
  • src/routes/schemas.js (1 hunks)
  • src/views/organisations/issueTable.html (2 hunks)
  • test/unit/middleware/common.middleware.test.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/middleware/issueTable.middleware.js
  • src/middleware/common.middleware.js
  • src/routes/schemas.js
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
.github/PULL_REQUEST_TEMPLATE.md

23-23: Bare URL used
null

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test

Comment thread src/views/organisations/issueTable.html Outdated
Comment thread src/middleware/common.middleware.js Outdated
rosado
rosado previously approved these changes Jan 29, 2025
@DilwoarH DilwoarH force-pushed the 782-technical-spike-how-will-we-surface-guidance-content-snippets branch from afcac26 to de70d9e Compare January 30, 2025 16:24
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 (1)
test/unit/middleware/common.middleware.test.js (1)

1393-1460: Add test cases for edge cases in getIssueSpecification.

The test suite would benefit from additional test cases to ensure robust error handling:

  1. Test with undefined issue_field parameter
  2. Test with null fields array
  3. Test with malformed field specification

Add these test cases:

     it('handles missing specification in req', () => {
       const req = {
         params: { issue_field: 'field1' }
       }
       const res = {}
       const next = vi.fn()

       getIssueSpecification(req, res, next)

       expect(req.issueSpecification).toBeUndefined()
       expect(next).toHaveBeenCalledTimes(1)
     })
+
+    it('handles undefined issue_field parameter', () => {
+      const req = {
+        params: {},
+        specification: {
+          fields: [
+            { field: 'field1', description: 'string' }
+          ]
+        }
+      }
+      const res = {}
+      const next = vi.fn()
+
+      getIssueSpecification(req, res, next)
+
+      expect(req.issueSpecification).toBeUndefined()
+      expect(next).toHaveBeenCalledTimes(1)
+    })
+
+    it('handles null fields array in specification', () => {
+      const req = {
+        params: { issue_field: 'field1' },
+        specification: {
+          fields: null
+        }
+      }
+      const res = {}
+      const next = vi.fn()
+
+      getIssueSpecification(req, res, next)
+
+      expect(req.issueSpecification).toBeUndefined()
+      expect(next).toHaveBeenCalledTimes(1)
+    })
+
+    it('handles malformed field specification', () => {
+      const req = {
+        params: { issue_field: 'field1' },
+        specification: {
+          fields: [
+            { invalidKey: 'field1' }
+          ]
+        }
+      }
+      const res = {}
+      const next = vi.fn()
+
+      getIssueSpecification(req, res, next)
+
+      expect(req.issueSpecification).toBeUndefined()
+      expect(next).toHaveBeenCalledTimes(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 afcac26 and de70d9e.

📒 Files selected for processing (6)
  • .github/PULL_REQUEST_TEMPLATE.md (1 hunks)
  • src/middleware/common.middleware.js (1 hunks)
  • src/middleware/issueTable.middleware.js (4 hunks)
  • src/routes/schemas.js (1 hunks)
  • src/views/organisations/issueTable.html (2 hunks)
  • test/unit/middleware/common.middleware.test.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/routes/schemas.js
  • src/middleware/issueTable.middleware.js
  • src/middleware/common.middleware.js
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
.github/PULL_REQUEST_TEMPLATE.md

23-23: Bare URL used
null

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (2)
.github/PULL_REQUEST_TEMPLATE.md (1)

23-23: Format the preview URL as a Markdown link.

The bare URL should be formatted as a Markdown link for better readability and to follow Markdown best practices.

Apply this diff to format the URL:

-https://submit-pr-[PR_NUMBER].herokuapp.com/
+[Preview deployment](https://submit-pr-[PR_NUMBER].herokuapp.com/)
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

23-23: Bare URL used
null

(MD034, no-bare-urls)

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

122-122: Add security attributes to the external link.

When using target="_blank", it's recommended to add rel="noopener noreferrer" to prevent potential security vulnerabilities.

Apply this diff:

-      <p class="govuk-body">The <a href="{{ dataset.dataset | getDatasetGuidanceUrl }}" target="_blank">{{ dataset.name }}</a> guidance explains how to fix the issue:</p>
+      <p class="govuk-body">The <a href="{{ dataset.dataset | getDatasetGuidanceUrl }}" target="_blank" rel="noopener noreferrer">{{ dataset.name }}</a> guidance explains how to fix the issue:</p>

@DilwoarH DilwoarH force-pushed the 782-technical-spike-how-will-we-surface-guidance-content-snippets branch from cf755f3 to a0f3893 Compare January 30, 2025 17:28
@DilwoarH DilwoarH temporarily deployed to submit-pr-818 January 30, 2025 17:29 Inactive
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 (3)
config/staging.yaml (1)

14-16: Consider adding feature description.

While the implementation is correct, consider adding a comment describing the purpose and impact of this feature flag for better maintainability.

 features:
+  # Controls the display of issue specification guidance in the UI
   issueSpecificationGuidance:
     enabled: true
config/production.yaml (1)

21-23: Good practice for controlled rollout.

Excellent approach to disable the feature in production initially. This allows for controlled rollout and easy rollback if needed.

Consider documenting the rollout strategy and criteria for enabling this feature in production.

config/default.yaml (1)

97-99: LGTM! Consider adding documentation for the feature flag.

The feature flag implementation follows good practices by being disabled by default. However, it would be helpful to add a comment explaining its purpose and impact.

Add documentation above the feature flag:

 features:
+  # Controls the display of specification guidance on the issueTable page
+  # When enabled, shows additional context about issue specifications
   issueSpecificationGuidance:
     enabled: false
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between de70d9e and a0f3893.

📒 Files selected for processing (8)
  • config/default.yaml (1 hunks)
  • config/development.yaml (1 hunks)
  • config/local.yaml (1 hunks)
  • config/production.yaml (1 hunks)
  • config/staging.yaml (1 hunks)
  • config/test.yaml (1 hunks)
  • src/middleware/common.middleware.js (2 hunks)
  • src/views/organisations/issueTable.html (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/views/organisations/issueTable.html
  • src/middleware/common.middleware.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (4)
config/test.yaml (1)

14-17: Well-structured feature flag implementation.

The feature flag follows best practices with a clear hierarchical structure. Good choice to enable it in the test environment for proper testing.

config/local.yaml (1)

17-19: Consistent with other environments.

The implementation maintains consistency with other configuration files, which is crucial for maintainability.

config/development.yaml (1)

14-16: Consistent implementation.

The feature flag implementation aligns with other environments, maintaining a uniform configuration structure.

config/default.yaml (1)

Line range hint 13-14: Update or remove the TODO comment.

There's an unrelated TODO comment about URL and name updates that should be addressed or removed if no longer relevant.

Let's check if this TODO is still relevant:

✅ Verification successful

Remove outdated TODO comment

The TODO comment about updating the URL and name appears to be outdated. Both the URL (submit.planning.data.gov.uk) and the service names are actively used throughout the system and appear to be current.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the URL mentioned in the TODO is still in use

# Search for references to the URL
rg -i 'submit.planning.data.gov.uk' --type yaml --type js --type html

Length of output: 369


Script:

#!/bin/bash
# Find the TODO comment in the configuration file
cat config/default.yaml

Length of output: 3828

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.

Technical spike: How will we surface guidance content snippets?

4 participants