Skip to content

Redirects /check and /submit to landing page#987

Merged
DilwoarH merged 7 commits into
mainfrom
985-bug-check-tool-confirmation-page-send-invalid-values-to-endpoint-submission-form
Mar 24, 2025
Merged

Redirects /check and /submit to landing page#987
DilwoarH merged 7 commits into
mainfrom
985-bug-check-tool-confirmation-page-send-invalid-values-to-endpoint-submission-form

Conversation

@DilwoarH
Copy link
Copy Markdown
Contributor

@DilwoarH DilwoarH commented Mar 20, 2025

Preview Link

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

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

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

Description

Redirects /check and /submit to landing page. This ensures users always go through our main user journey with proper deep linking set up.

Related Tickets & Documents

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

  • New Features

    • Users with invalid input parameters are now automatically redirected to the landing page for a more streamlined experience.
    • The form wizard’s entry point has been enhanced for clearer, more direct navigation.
  • Bug Fixes

    • Improved error handling by replacing error responses with user-friendly redirects for invalid input.
  • Refactor

    • Redirection flows and on-screen messaging have been updated for consistent, intuitive user journeys.
    • Test cases have been restructured for improved navigation flow and page verification.

This is to ensure users always go through our main user journey with proper deep linking set up.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 20, 2025

Caution

Review failed

The head commit changed during the review from fc54953 to cbafbe9.

Walkthrough

This pull request modifies the redirection behaviour in multiple controllers handling deep link requests. In the CheckDeepLinkController, the log message is updated, and the redirection path changes from /check to /. The EndpointSubmissionFormDeepLinkController replaces error responses with a redirect to /. Additionally, a new controller, checkStartController, is introduced and associated with the root route. A test page object has its URL updated accordingly, and related tests have been adjusted.

Changes

File(s) Change Summary
src/controllers/checkDeepLinkController.js
test/unit/checkDeepLinkController.test.js
Updated invalid parameter handling: log message now indicates redirection to landing page and res.redirect now points to / instead of /check; corresponding test updated.
src/controllers/endpointSubmissionFormDeepLinkController.js
test/unit/endpointSubmissionFormLinkController.test.js
Modified error handling in the get method to log invalid parameters and redirect to / rather than returning a 400 error; test updated accordingly.
src/controllers/checkStartController.js
src/routes/form-wizard/check/steps.js
Added new checkStartController that redirects to /; route mapping updated to use this controller for the root route.
test/PageObjectModels/startPage.js Updated constructor URL from /check/ to a more specific URL with query parameters.
test/integration/back_buttons.playwright.test.js
test/integration/pages_load_ok.playwright.test.js
test/integration/validation_errors.playwright.test.js
Refactored tests to replace clickStartNow() with verifyAndReturnPage() for improved navigation flow and updated assertions to reflect new routing logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CDC as CheckDeepLinkController
    participant Logger as Logger
    User->>CDC: GET /?invalid_params
    CDC->>Logger: Log "redirecting to landing page"
    CDC->>User: res.redirect("/")
Loading
sequenceDiagram
    participant User
    participant EDFC as EndpointSubmissionFormDeepLinkController
    participant Logger as Logger
    User->>EDFC: GET with invalid query parameters
    EDFC->>Logger: Log invalid parameters
    EDFC->>User: res.redirect("/")
Loading
sequenceDiagram
    participant User
    participant Router as Router
    participant CSC as checkStartController
    User->>Router: GET /
    Router->>CSC: Invoke get() method
    CSC->>User: res.redirect("/")
Loading

Possibly related PRs

  • 772 link to endpoint submission form from live service #930: The changes in the main PR, specifically the redirection logic in the CheckDeepLinkController, are related to the modifications in the EndpointSubmissionFormDeepLinkController where error handling was replaced with a redirect to the root URL, indicating a similar approach to handling invalid parameters.
  • Redirect guidance pages to main website #693: The changes in the main PR, which involve modifying the redirection behaviour in the CheckDeepLinkController, are related to the changes in the retrieved PR that also focus on redirecting requests, although they affect different controllers and routes.
  • 771 design and content changes for endpoint submission form #797: The changes in the main PR are related to the modifications in the CheckDeepLinkController class, specifically in the get method, which also appears in the retrieved PR where the DeepLinkController was refactored to CheckDeepLinkController and involved changes to the same method.

Suggested labels

bug, enhancement

Suggested reviewers

  • GeorgeGoodall-GovUk
  • rosado

Poem

I'm a little bunny with a coding flair,
Hopping through changes with utmost care.
Controllers now guide with a rhythmic beat,
Redirecting users to a landing page so neat.
With every commit, I munch a carrot or two 🥕,
Celebrating fresh code and progress anew!


🪧 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 20, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 67.34% 5602 / 8318
🔵 Statements 67.34% 5602 / 8318
🔵 Functions 63.85% 235 / 368
🔵 Branches 79.73% 736 / 923
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/controllers/checkDeepLinkController.js 85.54% 71.42% 100% 85.54% 23-34
src/controllers/checkStartController.js 0% 0% 0% 0% 1-11
src/controllers/endpointSubmissionFormDeepLinkController.js 80% 71.42% 100% 80% 15-26
src/routes/form-wizard/check/steps.js 0% 0% 0% 0% 1-132
Generated in workflow #999 for commit cbafbe9 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 (3)
src/controllers/checkStartController.js (2)

1-1: Remove redundant 'use strict' directive

ES modules run in strict mode by default, so this directive is unnecessary.

-'use strict'

 import PageController from './pageController.js'
🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)


5-5: Follow PascalCase naming convention for controller classes

Other controllers in this codebase follow PascalCase naming convention (as seen in references like PageController). Maintaining consistent naming conventions improves code readability and maintainability.

-class checkStartController extends PageController {
+class CheckStartController extends PageController {

Don't forget to update the export statement as well:

-export default checkStartController
+export default CheckStartController
test/unit/endpointSubmissionFormLinkController.test.js (1)

28-33: Update test name to match the new expected behaviour

The test name "should throw a 400 error when params invalid" no longer accurately reflects the actual behaviour being tested. The implementation has changed from throwing an error to redirecting to the landing page. Consider updating the test name to something like "should redirect to landing page when params invalid" to better align with the actual assertion.

-    it('should throw a 400 error when params invalid', async () => {
+    it('should redirect to landing page when params invalid', async () => {
      const { req, res, next } = mockMiddlewareArgs({ query: {} })
      endpointSubmissionFormDeepLinkController.get(req, res, next)

      expect(res.redirect).toHaveBeenCalledWith('/')
    })
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 286048f and f6e5132.

📒 Files selected for processing (7)
  • src/controllers/checkDeepLinkController.js (1 hunks)
  • src/controllers/checkStartController.js (1 hunks)
  • src/controllers/endpointSubmissionFormDeepLinkController.js (1 hunks)
  • src/routes/form-wizard/check/steps.js (2 hunks)
  • test/PageObjectModels/startPage.js (1 hunks)
  • test/unit/checkDeepLinkController.test.js (1 hunks)
  • test/unit/endpointSubmissionFormLinkController.test.js (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/controllers/checkStartController.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (7)
src/controllers/checkStartController.js (1)

6-8: Redirect implementation looks correct

The implementation successfully fulfills the PR objective of redirecting to the landing page.

test/unit/checkDeepLinkController.test.js (1)

32-32: Redirect path updated correctly

The test now correctly expects a redirect to the landing page ('/'). This aligns with the PR objective of redirecting the /check endpoint to the landing page.

test/PageObjectModels/startPage.js (1)

6-6: Updated URL path with appropriate query parameters

The StartPage constructor now initializes with a specific deep link URL including dataset and organisation parameters. This change ensures the test properly accesses the check functionality via the deep link mechanism rather than directly accessing '/check/'.

src/routes/form-wizard/check/steps.js (2)

14-14: New controller import looks good

The checkStartController is correctly imported to be used in the route definition.


24-24: Root route controller correctly updated

The root route now correctly uses the checkStartController, which will redirect to the landing page. This implements the PR objective of redirecting routes to ensure users navigate through the main user journey.

src/controllers/checkDeepLinkController.js (1)

51-53: Consistent redirection implemented correctly

The redirection to the landing page has been correctly implemented, which aligns with the PR objectives to ensure users consistently navigate through the main journey.

src/controllers/endpointSubmissionFormDeepLinkController.js (1)

42-46: Improved validation and redirection logic

This change correctly implements the redirection to the landing page and adds an additional validation check to ensure the dataset exists in the datasets collection. The error handling has been appropriately replaced with a redirect mechanism, ensuring a better user experience for invalid deep links.

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/acceptance/request_check.test.js (1)

107-108:

Details

❓ Verification inconclusive

Verify that error handling still provides adequate user feedback.

The test has been simplified to check for a single error message rather than detailed validations that were likely removed. This aligns with the PR objective of redirecting users to the landing page, but ensure this simplified approach still provides adequate error feedback to users.

While the new message clearly states that issues must be fixed before submission, consider whether additional contextual information (like specific error details) might still be necessary for users to understand what needs fixing.


🏁 Script executed:

#!/bin/bash
# Check if there are other places in the codebase where similar error message checks were updated
# This will help verify consistency in the error handling approach

# Search for similar error message expectations in test files
rg -A 2 -B 2 "You cannot submit your data" --glob "test/**/*.js"

# Check if there are any other error message checks that might need updating
rg -A 2 -B 2 "description column is missing" --glob "test/**/*.js"

# Look at the removed error checks from git history
git log -p -- test/acceptance/request_check.test.js | grep -B 5 -A 5 "errorSummary" | head -n 20

Length of output: 939


Ensure Simplified Error Feedback Remains Clear for Users

The test now exclusively validates that the error message "You cannot submit your data to the platform until you fix these issues." is visible after clicking the "description column is missing" indication. This approach aligns with the PR’s objective of redirecting users to the landing page. However, please verify that this simplified error handling still delivers adequate and clear feedback, as users might benefit from retaining some specific context (e.g. delineating which input is problematic) to efficiently rectify the issues.

  • File: test/acceptance/request_check.test.js (Lines 107-108)
  • Confirm that no additional error details are necessary, or if supplementary contextual messages would enhance user understanding.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 017e903 and ff4f251.

📒 Files selected for processing (1)
  • test/acceptance/request_check.test.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test

Changes the flow due to deep linking
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: 8

🧹 Nitpick comments (1)
test/PageObjectModels/startPage.js (1)

4-6: Updated URL path is now tied to specific test data.

The constructor now uses a very specific URL with hardcoded query parameters (dataset, organisation name, and organisation ID). This might make the StartPage less reusable for tests with different contexts or datasets.

Consider making the URL parameters configurable through constructor arguments to increase reusability:

-  constructor (page) {
-    super(page, '/check/link?dataset=article-4-direction-area&orgName=Newcastle%20City%20Council&orgId=local-authority%3ANET')
+  constructor (page, dataset = 'article-4-direction-area', orgName = 'Newcastle%20City%20Council', orgId = 'local-authority%3ANET') {
+    super(page, `/check/link?dataset=${dataset}&orgName=${orgName}&orgId=${orgId}`)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ff4f251 and 002e1ca.

📒 Files selected for processing (4)
  • test/PageObjectModels/startPage.js (1 hunks)
  • test/integration/back_buttons.playwright.test.js (3 hunks)
  • test/integration/pages_load_ok.playwright.test.js (6 hunks)
  • test/integration/validation_errors.playwright.test.js (3 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
test/integration/back_buttons.playwright.test.js (2)
test/integration/validation_errors.playwright.test.js (14)
  • startPage (7-7)
  • startPage (29-29)
  • startPage (51-51)
  • startPage (76-76)
  • datasetPage (13-13)
  • datasetPage (35-35)
  • datasetPage (57-57)
  • datasetPage (82-82)
  • geometryTypePage (16-16)
  • uploadMethodPage (10-10)
  • uploadMethodPage (32-32)
  • uploadMethodPage (54-54)
  • uploadMethodPage (79-79)
  • uploadFilePage (63-63)
test/PageObjectModels/startPage.js (1)
  • StartPage (3-7)
test/integration/validation_errors.playwright.test.js (1)
test/PageObjectModels/startPage.js (1)
  • StartPage (3-7)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (21)
test/integration/back_buttons.playwright.test.js (7)

4-8: Imports now explicitly include page objects used in tests.

The imports have been updated to include the DatasetPage, UploadMethodPage, and LandingPage, making it clearer which page objects are being used in the tests.


17-25: Navigation flow updated to match new application behaviour.

The test now verifies that users can navigate from UploadMethodPage back to DatasetPage, and then finally to LandingPage, which aligns with the PR objective of redirecting users to the landing page.


32-46: Navigation testing for geometry type page now follows consistent pattern.

This change maintains the consistent pattern of verifying the UploadMethodPage first, then going back to DatasetPage before proceeding with the specific test flow.


53-61: Upload method page navigation test follows the same pattern as other tests.

The consistent approach of starting at UploadMethodPage and navigating back to DatasetPage improves code readability and maintenance.


68-88: Geometry type navigation flow maintains consistency with other tests.

The navigation pattern is consistent with other tests, ensuring thorough testing of back button functionality from various pages in the application flow.


95-117: Upload file page navigation test updated to match new flow.

This test follows the same pattern as others, providing consistent coverage of navigation paths through the application.


124-146: Upload URL page navigation test updated to match new flow.

The test maintains consistency with other tests and ensures proper coverage of back button functionality in the URL upload flow.

test/integration/validation_errors.playwright.test.js (5)

3-4: Import statements updated to include page object classes.

The imports now explicitly include DatasetPage and UploadMethodPage classes in addition to their exported constants, which improves code clarity.


10-13: Geometry type test now follows the new navigation pattern.

The test has been updated to start from UploadMethodPage and navigate back to DatasetPage before continuing with the test logic, which aligns with the new application flow.


32-35: Upload method test navigation updated for consistency.

The test now follows the same pattern of starting at UploadMethodPage and navigating back to DatasetPage before proceeding with specific test logic.


54-57: File upload test navigation updated to match new flow.

This test maintains consistency with the new navigation pattern implemented across all tests.


79-82: URL upload test navigation updated to match new flow.

The test ensures consistent navigation through the application, starting from UploadMethodPage and navigating back to DatasetPage.

test/integration/pages_load_ok.playwright.test.js (9)

7-9: Updated imports to include page object classes.

The imports now explicitly include DatasetPage and UploadMethodPage classes along with their exported constants, improving code clarity.


49-55: Updated test to reflect new routing path.

The test case was renamed from "/check/dataset" to "/check" and updated to verify that the UploadMethodPage is accessible, which aligns with the PR objective of redirecting "/check" to the landing page.


61-64: Geometry-type test navigation updated to match new flow.

The test now follows the consistent pattern of starting at UploadMethodPage and navigating back to DatasetPage before proceeding with specific test logic.


76-79: Upload-method test navigation updated for consistency.

The test maintains the consistent navigation pattern implemented across all tests in the application.


95-109: Upload test navigation and variable naming updated.

The test follows the new navigation pattern and renames the second instance of uploadMethodPage to uploadMethodPage2 to avoid confusion, which is a good practice.


118-132: URL test navigation and variable naming updated.

The test follows the new navigation pattern and uses consistent variable naming for page objects, improving code clarity and maintainability.


144-144: URL path updated in assertion to include "/check" prefix.

The assertion has been updated to check for '/check/status/processing' instead of '/status/processing', which aligns with the new URL structure.


156-156: URL path updated in assertion to include "/check" prefix.

The assertion has been updated to check for '/check/results/processing' in the URL, reflecting the new URL structure.


163-163: URL path updated in assertion to include "/check" prefix.

The assertion now checks for '/check/results/completed/1' in the URL, aligning with the new URL structure.

Comment thread test/integration/validation_errors.playwright.test.js Outdated
Comment thread test/integration/validation_errors.playwright.test.js Outdated
Comment thread test/integration/validation_errors.playwright.test.js Outdated
Comment thread test/integration/validation_errors.playwright.test.js Outdated
Comment thread test/integration/pages_load_ok.playwright.test.js Outdated
Comment thread test/integration/pages_load_ok.playwright.test.js Outdated
Comment thread test/integration/pages_load_ok.playwright.test.js Outdated
Comment thread test/integration/pages_load_ok.playwright.test.js Outdated
@DilwoarH DilwoarH force-pushed the 985-bug-check-tool-confirmation-page-send-invalid-values-to-endpoint-submission-form branch from fc54953 to cbafbe9 Compare March 24, 2025 16:33
@DilwoarH DilwoarH temporarily deployed to submit-pr-987 March 24, 2025 16:34 Inactive
@DilwoarH DilwoarH merged commit 180f446 into main Mar 24, 2025
@DilwoarH DilwoarH deleted the 985-bug-check-tool-confirmation-page-send-invalid-values-to-endpoint-submission-form branch March 24, 2025 17:41
@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

None yet

Development

Successfully merging this pull request may close these issues.

[Bug 🐛] Check tool confirmation page send invalid values to endpoint submission form

3 participants