Skip to content

Default error hint on LPA overview page#714

Merged
rosado merged 6 commits into
mainfrom
rosado/659-default-error-status-hint
Dec 12, 2024
Merged

Default error hint on LPA overview page#714
rosado merged 6 commits into
mainfrom
rosado/659-default-error-status-hint

Conversation

@rosado
Copy link
Copy Markdown
Contributor

@rosado rosado commented Dec 3, 2024

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

  • Bug Fix

Description

The error hint message on LPA overview page is missing sometimes. This is because error message is not in the database itself. This PR adds a default error message for such scenarios.

Related Tickets & Documents

Closes #659

QA Instructions, Screenshots, Recordings

Currently, on prod, you can see the hint missing here: https://submit.planning.data.gov.uk/organisations/local-authority:BUC

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

    • Enhanced error reporting for datasets, providing clearer messages when issues arise.
  • Bug Fixes

    • Improved error handling logic to display more informative error messages for dataset access issues.
  • Tests

    • Expanded test coverage for error scenarios in the overview page, ensuring accurate rendering of error messages with the addition of new datasets.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 3, 2024

Walkthrough

The changes involve updates to the overview.html file, specifically enhancing the datasetItem macro by adding a data-dataset-status attribute and improving error handling logic. The error handling now displays a generic message if no specific error message is present. Additionally, the test suite for the overview.middleware has been modified to include a new dataset with an error message, enhancing the coverage of error scenarios in the tests.

Changes

File Change Summary
src/views/organisations/overview.html Added data-dataset-status attribute to <li> element; improved error handling logic for datasets.
test/unit/middleware/overview.middleware.test.js Added import for setupNunjucks and jsdom; introduced getRenderedErrorCards function; updated tests to include a new dataset with an error message.

Assessment against linked issues

Objective Addressed Explanation
Display "There was an error accessing the data URL" for broken datasets (659)

Possibly related PRs

Suggested reviewers

  • DilwoarH
  • GeorgeGoodall-GovUk

Poem

In the meadow where datasets play,
Errors once hidden, now bright as day.
With new cards to show, and messages clear,
We hop with joy, for the changes are here! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c1cfb6e and 96b8d4b.

📒 Files selected for processing (2)
  • src/views/organisations/overview.html (2 hunks)
  • test/unit/middleware/overview.middleware.test.js (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/views/organisations/overview.html
  • test/unit/middleware/overview.middleware.test.js

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 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.

@rosado rosado added the bug Something isn't working label Dec 3, 2024
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 3, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 70.52% 5185 / 7352
🔵 Statements 70.52% 5185 / 7352
🔵 Functions 69.18% 211 / 305
🔵 Branches 83.11% 684 / 823
File CoverageNo changed files found.
Generated in workflow #469 for commit 5ab2be1 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

🧹 Outside diff range and nitpick comments (2)
src/views/organisations/overview.html (1)

34-38: Fix indentation and use loose equality for string comparison.

The error handling logic is good, but there are two minor improvements needed:

  1. The indentation is inconsistent with the rest of the file
  2. String comparison in templates typically uses loose equality

Apply this diff to fix the issues:

-        {% if not dataset.error or dataset.error === '' %}
-          <p>There was an error accessing the data URL</p>
-        {% else %}
-          <p>{{ dataset.error }}</p>
-        {% endif %}
+        {% if not dataset.error or dataset.error == '' %}
+            <p>There was an error accessing the data URL</p>
+        {% else %}
+            <p>{{ dataset.error }}</p>
+        {% endif %}
test/unit/middleware/overview.middleware.test.js (1)

24-29: Enhance the helper function with documentation and error handling.

The helper function is well-designed but could benefit from some improvements.

Apply these enhancements:

+/**
+ * Extracts error card nodes from the rendered HTML template
+ * @param {Object} templateParams - The template parameters
+ * @returns {Array<Element>} Array of error card DOM nodes
+ * @throws {Error} If template rendering fails
+ */
 const getRenderedErrorCards = (templateParams) => {
+  if (!templateParams) {
+    throw new Error('Template parameters are required')
+  }
   const html = nunjucks.render('organisations/overview.html', templateParams)
   const doc = new jsdom.JSDOM(html).window.document
   const errorNodes = doc.querySelectorAll('[data-dataset-status="Error"]')
   return Array.from(errorNodes)
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ef68c34 and b1fc569.

📒 Files selected for processing (2)
  • src/views/organisations/overview.html (2 hunks)
  • test/unit/middleware/overview.middleware.test.js (4 hunks)
🔇 Additional comments (3)
src/views/organisations/overview.html (1)

13-13: LGTM! Good addition of the data-dataset-status attribute.

The new attribute enhances testability and provides a hook for styling based on dataset status.

test/unit/middleware/overview.middleware.test.js (2)

58-63: LGTM! Good test coverage for error message scenarios.

The addition of dataset4 with a specific error message ensures proper testing of both default and custom error messages.


98-100: LGTM! Comprehensive error message verification.

The assertions effectively verify both the default error message and custom error message scenarios.

@rosado rosado force-pushed the rosado/659-default-error-status-hint branch from b1fc569 to c1cfb6e Compare December 3, 2024 15:29
@CharliePatterson
Copy link
Copy Markdown
Contributor

All LGTM 🙌

The dataset.error value can be null
@eveleighoj eveleighoj temporarily deployed to submit-pr-714 December 12, 2024 14:38 Inactive
@rosado rosado merged commit aa6942c into main Dec 12, 2024
@rosado rosado deleted the rosado/659-default-error-status-hint branch December 12, 2024 14:57
@coderabbitai coderabbitai Bot mentioned this pull request Jan 29, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text missing from dataset card on dashboard for broken/erroring endpoints

4 participants