Skip to content

772 link to endpoint submission form from live service#930

Merged
rosado merged 30 commits into
mainfrom
772-link-to-endpoint-submission-form-from-live-service
Mar 6, 2025
Merged

772 link to endpoint submission form from live service#930
rosado merged 30 commits into
mainfrom
772-link-to-endpoint-submission-form-from-live-service

Conversation

@GeorgeGoodall-GovUk
Copy link
Copy Markdown
Contributor

@GeorgeGoodall-GovUk GeorgeGoodall-GovUk commented Feb 25, 2025

Preview Link

https://submit-pr-930.herokuapp.com/

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

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

Description

This PR includes several improvements to deep linking and error handling:

the primary goal of this PR is to link the submit form.

additional changes

  1. Added null checks for organisation and dataset parameters in deep link functions
  2. Updated terminology from "data URL" to "endpoint URL" for consistency
  3. Fixed parameter passing in endpointSubmissionFormToolDeepLink
  4. Added PageController to the confirmation step
  5. Updated the confirmation page to include conditional rendering for the submission form feature
  6. Fixed deep link generation in the get-started page

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

test out the links on the get-started page, check confirmation page and endpoint error page

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

    • Added a submission option on the confirmation page, allowing users to submit data via a dedicated endpoint when enabled.
    • Extended issue forms with extra guidance information where applicable.
  • Bug Fixes

    • Enhanced navigation by validating required information and redirecting to default pages if details are missing.
    • Standardised error messages to consistently reference the “endpoint URL.”
    • Improved URL generation by encoding special characters, ensuring reliable navigation and display.

@GeorgeGoodall-GovUk GeorgeGoodall-GovUk linked an issue Feb 25, 2025 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 25, 2025

Walkthrough

The changes introduce early parameter validation in deep link functions, ensuring that invalid or missing data for organisation or dataset results in a default URL response. Several HTML templates and error pages have been updated to standardise terminology—switching from “data URL” to “endpoint URL”—and URL generation now applies proper encoding. Additionally, a new controller is assigned for the confirmation route, the issue specification schema now includes an optional guidance field, and the endpoint submission controller has been enhanced to incorporate dataset information into session data.

Changes

Files Change Summary
src/filters/checkToolDeepLink.js
src/filters/endpointSubmissionFormDeepLink.js
Added parameter validation in deep link functions. Returns a default URL ('/check' or '/submit') if organisation or dataset is falsy, otherwise continues with URL construction.
src/controllers/endpointSubmissionFormDeepLinkController.js Imported datasets and updated the GET method to retrieve dataset information. The session data is now enriched with a new property datasetName from the dataset information.
src/routes/form-wizard/check/steps.js Introduced a new property controller set to PageController in the /confirmation route configuration.
src/views/check/confirmation.html Added a conditional HTML section wrapped in a feature flag to provide submission instructions via an endpoint, while retaining email instructions as fallback.
src/views/organisations/http-error.html
test/unit/http-errorPage.test.js
Updated all instances of “data URL” to “endpoint URL”, including header text, error details and resubmit link text, with test assertions adjusted for the new URL structure.
src/views/organisations/dataset-overview.html
src/views/check/results/results.html
Modified the construction of the boundaryGeoJsonUrl property to apply an urlencode filter (on organisation in dataset overview and on orgId in results) ensuring proper URL encoding of special characters.
src/routes/schemas.js Added a new optional field guidance (using v.optional(NonEmptyString)) to the issueSpecification object within the OrgIssueTable schema.

Possibly related PRs

Suggested labels

bug, enhancement

Suggested reviewers

  • DilwoarH

Poem

I’m a rabbit in code, hopping through each line,
Fixing deep links and URLs, making them align.
With parameters checked and encoded just right,
My whiskered cheers ring out in delight.
In a garden of changes, I nibble on every byte,
Celebrating small victories in code day and night!


📜 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 86f4ae3 and 637a9e0.

📒 Files selected for processing (1)
  • test/unit/http-errorPage.test.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/unit/http-errorPage.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 Feb 25, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 66.71% 5433 / 8143
🔵 Statements 66.71% 5433 / 8143
🔵 Functions 64.18% 233 / 363
🔵 Branches 80.42% 719 / 894
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/controllers/endpointSubmissionFormDeepLinkController.js 80% 66.66% 100% 80% 15-26
src/filters/checkToolDeepLink.js 85.71% 50% 100% 85.71% 11-12
src/filters/endpointSubmissionFormDeepLink.js 85.71% 50% 100% 85.71% 11-12
src/routes/schemas.js 100% 100% 100% 100%
src/routes/form-wizard/check/steps.js 0% 0% 0% 0% 1-130
Generated in workflow #936 for commit 637a9e0 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: 1

🧹 Nitpick comments (1)
src/filters/endpointSubmissionFormDeepLink.js (1)

13-13: JSDoc and implementation mismatch

The JSDoc describes dataset as an object with a 'dataset' property, but the implementation uses 'dataset' directly. Additionally, the use of 'organisation.organisation' for the orgId parameter seems unusual.

Consider updating either:

  1. The JSDoc to match implementation:
/**
 * Returns the deep link to the endpoint submission form for a given dataset and organisation
 *
- * @param {{name:string}} organisation
- * @param {{dataset:string, name:string}} dataset
+ * @param {{name:string, organisation:string}} organisation
+ * @param {string} dataset
 *
 * @return {string}
 */
  1. Or the implementation to match JSDoc:
- return `/submit/link?dataset=${encodeURIComponent(dataset)}&orgName=${encodeURIComponent(organisation)}&orgId=${encodeURIComponent(organisation.organisation)}`
+ return `/submit/link?dataset=${encodeURIComponent(dataset.dataset)}&orgName=${encodeURIComponent(organisation.name)}&orgId=${encodeURIComponent(organisation.organisation)}`
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f9b628a and af64861.

📒 Files selected for processing (7)
  • src/filters/checkToolDeepLink.js (1 hunks)
  • src/filters/endpointSubmissionFormDeepLink.js (1 hunks)
  • src/routes/form-wizard/check/steps.js (1 hunks)
  • src/views/check/confirmation.html (2 hunks)
  • src/views/organisations/get-started.html (1 hunks)
  • src/views/organisations/http-error.html (3 hunks)
  • test/unit/http-errorPage.test.js (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/views/organisations/http-error.html
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (8)
src/routes/form-wizard/check/steps.js (1)

99-99: Good addition of the PageController.

Adding the controller to this route aligns it with the baseSettings pattern used throughout the file and ensures consistent behavior with other routes. This change supports the PR objective of introducing a PageController to manage the confirmation step effectively.

src/views/check/confirmation.html (1)

29-53: Excellent implementation of feature-flagged submission form option.

The conditional rendering based on the submitEndpointForm feature flag provides a clean way to gradually roll out the new submission form functionality while maintaining the existing email method as a fallback. This change effectively addresses the PR objective of linking to the endpoint submission form.

The instructions are clear and the terminology update from "data URL" to "endpoint URL" is consistently applied.

src/views/organisations/get-started.html (1)

188-188: Correct parameter passing to the deep link function.

The function now correctly receives specific properties (organisation.name and dataset.dataset) rather than passing entire objects. This addresses the PR objective of fixing parameter passing in the endpointSubmissionFormToolDeepLink function.

src/filters/checkToolDeepLink.js (1)

10-12: Good defensive programming with null parameter checks.

Adding validation for the organisation and dataset parameters prevents potential errors when these values are null or undefined. This improves the robustness of the deep linking functionality and addresses the PR objective of implementing null checks.

This pattern should be applied consistently across all deep link functions to ensure comprehensive error handling.

test/unit/http-errorPage.test.js (3)

26-26: Terminology update looks good

The update from "data URL" to "endpoint URL" aligns with the PR's terminology standardisation objective.


35-35: Terminology consistency maintained

The consistent update of terminology in the summary list maintains coherent user experience.


56-56:

Details

❓ Verification inconclusive

Verify whether 'orgId=undefined' is intentional

The test now correctly uses the updated deep link format with query parameters, but it's expecting 'orgId=undefined' in the URL. Is this the intended behaviour or should the test mock include a valid organisation ID?


🏁 Script executed:

#!/bin/bash
# Check if other tests or implementation files expect undefined orgId
echo "Searching for references to orgId=undefined in tests or views:"
rg "orgId=undefined" --type js --type html

Length of output: 403


Clarification on Organisation ID in Deep Link

After verifying across the codebase, the only reference to orgId=undefined is in this test. Please confirm whether the test intentionally omits a valid organisation ID, meaning the URL should indeed include orgId=undefined, or if a valid organisation ID is expected and the test mock should be updated accordingly.

src/filters/endpointSubmissionFormDeepLink.js (1)

10-12: Good defensive programming with null checks

Adding null checks for organisation and dataset parameters improves error handling and prevents potential runtime errors, aligning with the PR objectives.

Comment thread src/views/check/confirmation.html
Comment thread src/filters/endpointSubmissionFormDeepLink.js Outdated
…-to-endpoint-submission-form-from-live-service
Comment thread src/filters/endpointSubmissionFormDeepLink.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: 5

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9d792da and 860a302.

📒 Files selected for processing (10)
  • src/filters/checkToolDeepLink.js (1 hunks)
  • src/filters/endpointSubmissionFormDeepLink.js (1 hunks)
  • src/routes/schemas.js (1 hunks)
  • src/views/check/results/issueDetails.html (1 hunks)
  • src/views/organisations/dataset-overview.html (1 hunks)
  • src/views/organisations/datasetTaskList.html (1 hunks)
  • src/views/organisations/get-started.html (3 hunks)
  • src/views/organisations/issueDetails.html (1 hunks)
  • src/views/organisations/issueTable.html (1 hunks)
  • test/unit/views/organisations/dataset-overview.test.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/views/organisations/get-started.html
  • src/filters/checkToolDeepLink.js
🧰 Additional context used
🧠 Learnings (1)
test/unit/views/organisations/dataset-overview.test.js (1)
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#510
File: test/unit/views/organisations/dataset-overview.test.js:3-3
Timestamp: 2024-11-12T10:13:49.419Z
Learning: Ensure to verify import paths in all relevant test files before flagging inconsistencies.
🪛 GitHub Check: test
test/unit/views/organisations/dataset-overview.test.js

[failure] 184-184: test/unit/views/organisations/dataset-overview.test.js > Dataset Overview Page > Renders dataset actions sections
AssertionError: expected '/check/link?dataset=article-4-directi…' to deeply equal '/check/link?dataset=article-4-directi…'

Expected: "/check/link?dataset=article-4-direction-area&orgName=mock-org&orgId=mock-org"
Received: "/check/link?dataset=article-4-direction-area&orgName=Mock%20org&orgId=Mock%20org"

❯ test/unit/views/organisations/dataset-overview.test.js:184:56

🪛 GitHub Actions: Unit test coverage report
test/unit/views/organisations/dataset-overview.test.js

[error] 184-184: AssertionError: expected '/check/link?dataset=article-4-direction-area&orgName=mock-org&orgId=mock-org' to deeply equal '/check/link?dataset=article-4-direction-area&orgName=mock-org&orgId=mock-org'

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (8)
src/views/organisations/datasetTaskList.html (1)

77-77: Changed from passing entire organisation object to just organisation.name.

This change supports the PR's goal to improve deep linking by passing the specific name property to the checkToolDeepLink filter instead of the entire object. This is a good practice that makes the parameter usage more explicit.

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

105-105: Updated to use organisation.name instead of the whole object.

This change correctly updates the parameters passed to the checkToolDeepLink filter, using specific properties instead of whole objects, which aligns with the PR objectives to fix parameter passing in deep link functions.

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

138-138: Updated to use organisation.name and dataset.dataset explicitly.

This change correctly updates the parameters passed to the checkToolDeepLink filter, using specific properties instead of whole objects. This is consistent with the changes in other templates and aligns with the PR objectives.

src/views/check/results/issueDetails.html (1)

82-82: Parameter passing update looks good.

The parameter passing to checkToolDeepLink has been updated to pass options.lpa and options.dataset directly, which aligns with the updated function signature that now expects strings instead of objects.

src/routes/schemas.js (1)

219-220: Good enhancement by adding the guidance field.

Adding an optional guidance field to the issueSpecification object will allow for including helpful guidance information related to the issue, which can improve the user experience.

src/views/organisations/dataset-overview.html (1)

212-212: Parameter passing update looks good.

The updated parameter passing to checkToolDeepLink now uses organisation.name instead of the entire organisation object, and dataset.dataset instead of the entire dataset object, which aligns with the updated function signature that now expects strings instead of objects.

src/filters/endpointSubmissionFormDeepLink.js (2)

4-6: JSDoc updated to match the new parameter types.

The JSDoc has been correctly updated to indicate that both parameters are now strings instead of objects.


10-12: Good null check implementation.

Adding validation for falsy parameters is a good defensive programming practice to prevent errors when required inputs are missing.

Comment thread test/unit/views/organisations/dataset-overview.test.js Outdated
Comment thread src/views/organisations/datasetTaskList.html Outdated
Comment thread src/views/organisations/issueDetails.html Outdated
Comment thread src/views/organisations/issueTable.html Outdated
Comment thread src/filters/endpointSubmissionFormDeepLink.js Outdated
@eveleighoj eveleighoj temporarily deployed to submit-pr-930 March 6, 2025 10:21 Inactive
@rosado rosado self-requested a review March 6, 2025 10:39
@rosado rosado moved this from Refined to Code review & QA in Providers team (BACKLOG) Mar 6, 2025
@rosado rosado merged commit f16ac51 into main Mar 6, 2025
@github-project-automation github-project-automation Bot moved this from Code review & QA to Ready for release in Providers team (BACKLOG) Mar 6, 2025
@rosado rosado deleted the 772-link-to-endpoint-submission-form-from-live-service branch March 6, 2025 10:57
@DilwoarH DilwoarH moved this from Ready for release to Done in Providers team (BACKLOG) Mar 6, 2025
@neilfwar neilfwar moved this from Done to Done Archived in Providers team (BACKLOG) Apr 8, 2025
This was referenced Jul 21, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Sep 29, 2025
11 tasks
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.

Link to endpoint submission form from live service

6 participants