Skip to content

added checkTool link to jira ticket#1078

Merged
feba-rajan merged 10 commits into
mainfrom
feat/create_check_url_request
Jul 29, 2025
Merged

added checkTool link to jira ticket#1078
feba-rajan merged 10 commits into
mainfrom
feat/create_check_url_request

Conversation

@feba-rajan
Copy link
Copy Markdown
Contributor

@feba-rajan feba-rajan commented Jul 21, 2025

Description

PR updates the submit form flow to trigger the check tool automatically when a endpoint URL is submitted. A link to the check tool results is attached to the Jira ticket created.

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

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

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Before

Screenshot 2025-07-22 at 09 59 41

After

Screenshot 2025-07-21 at 16 46 01

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

Summary by CodeRabbit

  • New Features

    • Introduced a processing page that displays the status of your submission and automatically updates until processing is complete.
    • Added a new route to show the progress of your submission with real-time updates and guidance if processing takes longer than expected.
    • Enhanced submission flow to validate dataset URLs and integrate asynchronous status tracking with Jira requests.
  • Bug Fixes

    • Improved error handling and messaging for invalid or missing dataset URLs during submission.
  • Tests

    • Enhanced test coverage for submission processing, URL validation, and error scenarios.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 21, 2025

Walkthrough

The update introduces a new processing step in the endpoint submission flow, including a dedicated controller and template for displaying processing status with client-side polling. The CheckAnswersController logic is revised to handle asynchronous URL requests and local validation, returning both issue and request ID. Related tests and route definitions are updated accordingly.

Changes

Cohort / File(s) Change Summary
CheckAnswersController logic and flow
src/controllers/CheckAnswersController.js
Refactored the post and createJiraServiceRequest methods to handle asynchronous URL request creation, local URL validation, and return both Jira issue and request ID. Added a nextPage method to manage redirection based on session state. Session variables for processing and request ID are now set.
CheckAnswersController tests
test/unit/checkAnswersController.test.js
Updated tests to mock and verify new asynchronous URL request and validation logic. Adjusted expectations to the new return signature ({ issue, requestId }). Added mocks for postUrlRequest and localUrlValidation.
Processing step route and flow
src/routes/form-wizard/endpoint-submission-form/steps.js
Added a new /processing/:id route using ProcessingController and a dynamic next step in /check-answers to redirect to the processing page. Defined template, controller, and journey logic for the new step.
Processing controller
src/controllers/ProcessingController.js
Introduced ProcessingController extending PageController, with a get method to set up processing page options, handle missing IDs, and configure polling and redirection URLs for the processing step.
Processing template
src/views/submit/processing.html
Added a new template for the processing page, displaying dynamic messages based on processing status. Embedded JavaScript polls a status endpoint with retry logic, updating the UI and redirecting on completion or failure.
Processing controller tests
test/unit/processingController.test.js
Added unit tests for ProcessingController verifying correct option setup on valid requests and proper error handling on missing request IDs.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CheckAnswersController
    participant AsyncRequestApi
    participant SubmitUrlController
    participant ProcessingController
    participant ProcessingTemplate

    User->>CheckAnswersController: POST /submit/check-answers
    CheckAnswersController->>SubmitUrlController: localUrlValidation(url)
    alt Validation fails
        CheckAnswersController-->>User: Redirect to /submit/check-answers (error)
    else Validation passes
        CheckAnswersController->>AsyncRequestApi: postUrlRequest(formData)
        AsyncRequestApi-->>CheckAnswersController: requestId
        CheckAnswersController->>Jira: createCustomerRequest(description with check tool link)
        CheckAnswersController-->>User: Redirect to /submit/processing/{requestId}
    end

    User->>ProcessingController: GET /submit/processing/{requestId}
    ProcessingController->>ProcessingTemplate: Render processing.html with options

    loop Polling (JS in Template)
        ProcessingTemplate->>API: GET /api/endpoint-request-status/{requestId}
        alt Status COMPLETE or FAILED
            ProcessingTemplate-->>User: Redirect to confirmation page
        else Retry < 20
            ProcessingTemplate->>API: Repeat after 3s
        else
            ProcessingTemplate-->>User: Show "taking longer than expected" message
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

In the warren, code hops anew,
A processing step for all to view.
With polling scripts and status checks,
The rabbits keep the bugs in check.
URLs validated, requests in flight—
Our burrow glows with screens so bright!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 c0a09a7 and d2a00f3.

📒 Files selected for processing (1)
  • test/unit/processingController.test.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/unit/processingController.test.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: run-tests / test
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/create_check_url_request

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests 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.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2b1a452 and b274a60.

📒 Files selected for processing (2)
  • src/controllers/CheckAnswersController.js (3 hunks)
  • test/unit/checkAnswersController.test.js (4 hunks)
🧰 Additional context used
🧠 Learnings (2)
src/controllers/CheckAnswersController.js (1)

Learnt from: GeorgeGoodall-GovUk
PR: #593
File: index.js:20-20
Timestamp: 2024-10-29T14:58:22.843Z
Learning: The function initDatasetSlugToReadableNameFilter() in src/utils/datasetSlugToReadableName.js already includes appropriate error handling and logging.

test/unit/checkAnswersController.test.js (2)

Learnt from: GeorgeGoodall-GovUk
PR: #609
File: test/unit/noErrorsPage.test.js:68-68
Timestamp: 2024-11-12T10:54:09.485Z
Learning: In test/unit/noErrorsPage.test.js, avoid using prettifyColumnName for column headers because the table can contain spec fields, as requested by Alex.

Learnt from: rosado
PR: #657
File: test/unit/middleware/issueDetails.middleware.test.js:43-43
Timestamp: 2024-11-14T16:38:49.883Z
Learning: In test/unit/middleware/issueDetails.middleware.test.js, template params are verified with a schema, so it's acceptable for the test expectations to use primitive values while the test input uses an object for issueEntitiesCount.

🔇 Additional comments (8)
test/unit/checkAnswersController.test.js (5)

5-5: LGTM: Import addition for new async request service.

The import for postUrlRequest is correctly added to support the new check tool integration functionality.


8-8: LGTM: Mock setup for async request API.

The mock setup follows existing patterns and is properly placed alongside other service mocks.


28-28: LGTM: Mock reset in beforeEach.

Properly resets the mock to ensure test isolation between test cases.


68-68: LGTM: Mock implementation for URL request.

The mock correctly resolves with a fixed 'requestId' string that will be used to construct the check tool URL.


87-94: LGTM: Test verification of new integration points.

The test properly verifies that:

  1. postUrlRequest is called during execution
  2. The Jira description contains the constructed check tool URL with the expected format

This ensures the new async request integration is working as intended.

src/controllers/CheckAnswersController.js (3)

7-9: LGTM: Import additions for new functionality.

The imports for postUrlRequest, SubmitUrlController, and datasets are correctly added to support the check tool integration feature.


65-71: LGTM: Form data construction for async request.

The form data object is properly constructed with the required fields:

  • URL from request body or session
  • Dataset from session
  • Collection from dataset metadata
  • Geometry type from session

This follows a logical structure for the async request.


94-95: LGTM: Integration of check tool link in Jira description.

The check tool link is properly appended to the Jira issue description, providing easy access to the validation results within the ticket.

Comment thread src/controllers/CheckAnswersController.js Outdated
Comment thread src/controllers/CheckAnswersController.js Outdated
Comment thread src/controllers/CheckAnswersController.js Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 21, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 66.39% 6025 / 9075
🔵 Statements 66.39% 6025 / 9075
🔵 Functions 64.46% 254 / 394
🔵 Branches 80.51% 777 / 965
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/controllers/CheckAnswersController.js 86.7% 80% 66.66% 86.7% 50-55, 71-74, 78-81, 93-99
src/controllers/ProcessingController.js 100% 100% 100% 100%
src/routes/form-wizard/endpoint-submission-form/steps.js 0% 0% 0% 0% 1-58
Generated in workflow #1133 for commit d2a00f3 by the Vitest Coverage Report Action

Copy link
Copy Markdown
Contributor

@DilwoarH DilwoarH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code generally looks good but I think we'll need a loading spinner or some sort of page that shows users not to kill the request

Comment thread src/controllers/CheckAnswersController.js Outdated
Comment thread src/controllers/CheckAnswersController.js
Comment thread src/controllers/CheckAnswersController.js
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

🧹 Nitpick comments (3)
src/controllers/ProcessingController.js (1)

7-8: Consider making URLs configurable.

The polling endpoint and confirmation URL are hardcoded. Consider using configuration values for better maintainability and environment flexibility.

- req.form.options.pollingEndpoint = `/api/status/${requestId}`
- req.form.options.confirmationUrl = '/submit/confirmation'
+ req.form.options.pollingEndpoint = `${config.api.baseUrl}/status/${requestId}`
+ req.form.options.confirmationUrl = config.routes.confirmation || '/submit/confirmation'
src/views/submit/processing.html (1)

30-30: Make polling intervals configurable.

Hardcoded polling intervals make it difficult to adjust behaviour for different environments or requirements.

Consider passing polling intervals as template variables:

+ const pollingInterval = {{ options.pollingInterval | default(3000) }};
+ const retryInterval = {{ options.retryInterval | default(5000) }};
 const finishedStatuses = ['COMPLETE', 'FAILED'];

Then use these variables in the setTimeout calls.

src/controllers/CheckAnswersController.js (1)

79-84: Consider adding validation for form data fields.

While URL validation is handled, other form data fields like dataset and geomType aren't validated before being sent to the external service.

 const formData = {
   url,
-  dataset: req.sessionModel.get('dataset'),
+  dataset: req.sessionModel.get('dataset') || 'unknown',
   collection: datasetMeta.dataSubject,
-  geomType: req.sessionModel.get('geomType')
+  geomType: req.sessionModel.get('geomType') || 'unknown'
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6f3e264 and 0fb935e.

📒 Files selected for processing (5)
  • src/controllers/CheckAnswersController.js (6 hunks)
  • src/controllers/ProcessingController.js (1 hunks)
  • src/routes/form-wizard/endpoint-submission-form/steps.js (2 hunks)
  • src/views/submit/processing.html (1 hunks)
  • test/unit/checkAnswersController.test.js (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/unit/checkAnswersController.test.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (7)
src/routes/form-wizard/endpoint-submission-form/steps.js (2)

5-5: Import statement looks good.

The import for ProcessingController follows the existing pattern and naming convention.


46-52: Processing route configuration is well-structured.

The new route properly integrates with the existing form wizard pattern and includes appropriate configuration options.

src/controllers/CheckAnswersController.js (5)

24-30: Session management integration looks good.

The destructuring of issue and requestId from the enhanced createJiraServiceRequest method and setting of session variables properly supports the new processing flow.


66-77: Error handling for missing/invalid URLs has been properly addressed.

The implementation now correctly handles both missing URLs and validation failures by setting appropriate error messages and redirecting back to the check-answers page. This addresses the concerns raised in past reviews.


85-95: Async URL request error handling looks good.

The try-catch block properly handles postUrlRequest failures and sets requestId to null on error, which is then handled gracefully in the check tool link generation. This addresses the past review concern.


96-98: Check tool link generation is well-implemented.

The conditional check for requestId and fallback message properly handles the case where the async request fails. The use of config.jira.requestTypeId instead of hardcoded values is also good practice.


150-150: Return structure properly supports new flow.

The enhanced return value with both issue and requestId correctly supports the new processing workflow while maintaining backward compatibility.

Comment thread src/controllers/CheckAnswersController.js
Comment thread src/controllers/ProcessingController.js
Comment thread src/routes/form-wizard/endpoint-submission-form/steps.js
Comment thread src/views/submit/processing.html Outdated
Comment thread src/views/submit/processing.html
@feba-rajan feba-rajan force-pushed the feat/create_check_url_request branch from 95a464a to e8dbffa Compare July 25, 2025 13:56
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)
src/controllers/processingController.js (1)

5-8: Good error handling for missing request ID.

The validation and early return with appropriate HTTP status code is well-implemented. Consider adding validation for malformed request IDs if needed based on your ID format requirements.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f11b7af and e8dbffa.

📒 Files selected for processing (1)
  • src/controllers/processingController.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (3)
src/controllers/processingController.js (3)

1-3: LGTM! Clean class structure and appropriate inheritance.

The import, class declaration extending PageController, and export are well-structured and follow established patterns.

Also applies to: 26-26


9-20: Well-structured form options configuration.

The setup provides comprehensive configuration for the processing page including polling endpoint, confirmation URL, and appropriate user-facing text for different states. The dynamic polling endpoint construction using the requestId is correctly implemented.


22-23: Proper delegation to parent class.

The call to super.get(req, res, next) correctly delegates to the parent PageController after setting up the processing-specific options, maintaining the established controller pattern.

Copy link
Copy Markdown
Contributor

@DilwoarH DilwoarH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, well done 🏅

I tested it with a small Article 4-direction area dataset, and it worked well. I also checked it with a large tree dataset, and it worked well, too.

Some feedback:

  1. Add tests for the processing Controller
  2. You should also look at the names of existing controllers using the Pascal case.
  3. Change the content for the processing page to say something like this:

Please wait while we check your submission. Do not exit this page; large datasets may take a few minutes.

Check with @maddie-broxup

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need add some tests for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, will add some

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please can you share a screenshot of what this looks like currently and i can write some content for it? thanks for tagging me!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-07-28 at 15 51 38

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

23-23: Remove redundant nested describe block.

The nested describe('ProcessingController()') block has the same name as the parent block, which creates confusion and serves no organisational purpose.

-  describe('ProcessingController()', () => {
+  describe('get method', () => {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 541f4a6 and c0a09a7.

📒 Files selected for processing (1)
  • test/unit/processingController.test.js (1 hunks)
🔇 Additional comments (3)
test/unit/processingController.test.js (3)

1-21: LGTM! Well-structured test setup.

The import statements and test setup follow Vitest best practices with proper mocking of Express.js request/response objects and clean beforeEach initialisation.


24-39: LGTM! Comprehensive test coverage for valid request ID scenario.

The test thoroughly validates that all expected form options are properly set when a valid request ID is provided, including polling configuration and UI text elements.


40-45: LGTM! Proper error handling validation.

The test correctly validates that the controller responds with a 400 status and renders an error page when the request ID is missing.

@feba-rajan feba-rajan merged commit 5c08f22 into main Jul 29, 2025
5 checks passed
@feba-rajan feba-rajan deleted the feat/create_check_url_request branch July 29, 2025 10:52
@coderabbitai coderabbitai Bot mentioned this pull request Dec 12, 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.

4 participants