Skip to content

fix: Finalize survey#1276

Merged
mariush2 merged 5 commits into
mainfrom
fix/finalize-survey
Apr 29, 2026
Merged

fix: Finalize survey#1276
mariush2 merged 5 commits into
mainfrom
fix/finalize-survey

Conversation

@mariush2

Copy link
Copy Markdown
Contributor
  • Needs to be tested locally by reviewer

Description

Call the new finalize endpoint when completing a survey

Copilot AI review requested due to automatic review settings April 28, 2026 12:11
@mariush2 mariush2 requested a review from a team as a code owner April 28, 2026 12:11
@mariush2 mariush2 requested a review from arkadiy93 April 28, 2026 12:11

Copilot AI left a comment

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.

Pull request overview

This PR updates the survey completion flow to call the new “finalize” endpoint when a survey is completed, and bumps the @equinor/subsurface-app-management dependency accordingly.

Changes:

  • Add useCompleteActiveSurvey usage and invoke completion finalize when finishing the last question.
  • Update Storybook MSW handlers to mock the new finalize endpoint.
  • Minor robustness tweak in SurveyDialog to always reset loading state, plus dependency/lockfile updates.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/providers/SurveyProvider/SurveyProvider.tsx Calls the new finalize/completion mutation when completing a survey.
src/providers/SurveyProvider/SurveyProvider.stories.tsx Adds an MSW handler for the finalize endpoint used during completion.
src/providers/SurveyProvider/SurveyDialog/SurveyDialog.tsx Ensures isAnswering is reset via try/finally around answer submission.
public/mockServiceWorker.js Updates MSW worker package version constant (generated artifact).
package.json Bumps library version and @equinor/subsurface-app-management to 5.4.7.
bun.lock Lockfile refresh reflecting dependency bumps (including MSW).
Comments suppressed due to low confidence (1)

src/providers/SurveyProvider/SurveyProvider.tsx:100

  • completeSurvey(...) is triggered and a success toast/confetti is shown immediately, regardless of whether the finalize request succeeds or fails. To avoid false-positive UX, wire the toast/confetti to the mutation success callback (or use mutateAsync + try/catch), and show an error toast on failure.
    completeSurvey(activeSurvey.surveyResponseId.value);

    showToast({
      variant: 'success',
      title: 'Survey completed',
      description: 'Thanks for helping us improve!',
      duration: 5,
    });

    if (activeSurvey.showConfettiOnComplete) {
      shower({
        mode: 'shower',
        shapes: ['square'],
        duration: 5000,
      });
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/providers/SurveyProvider/SurveyProvider.tsx
Comment thread src/providers/SurveyProvider/SurveyProvider.tsx
Comment thread public/mockServiceWorker.js
@github-actions

github-actions Bot commented Apr 28, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 100% (🎯 100%) 17193 / 17193
🔵 Statements 100% (🎯 100%) 17193 / 17193
🔵 Functions 100% (🎯 100%) 1242 / 1242
🔵 Branches 100% (🎯 100%) 4379 / 4379
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/providers/SurveyProvider/SurveyProvider.tsx 100% 100% 100% 100%
src/providers/SurveyProvider/SurveyDialog/SurveyDialog.tsx 100% 100% 100% 100%
Generated in workflow #2257 for commit a1cd7b5 by the Vitest Coverage Report Action

arkadiy93
arkadiy93 previously approved these changes Apr 28, 2026
Copilot AI review requested due to automatic review settings April 29, 2026 06:56

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/providers/SurveyProvider/SurveyProvider.tsx:92

  • completeSurvey(...) is fired and a success toast is shown immediately without waiting for the finalize mutation to succeed (and without any error handling). This can show “Survey completed” even if the request fails. Prefer awaiting the mutation (e.g., mutateAsync) or moving the toast/confetti into the mutation’s onSuccess, and showing an error toast on onError.
    completeSurvey(activeSurvey.surveyResponseId.value);

    showToast({
      variant: 'success',
      title: 'Survey completed',
      description: 'Thanks for helping us improve!',
      duration: 5,
    });

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/providers/SurveyProvider/SurveyProvider.test.tsx
Comment thread src/providers/SurveyProvider/SurveyProvider.test.tsx Outdated
Comment thread src/providers/SurveyProvider/SurveyProvider.test.tsx Outdated

@arkadiy93 arkadiy93 left a comment

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.

LGTM ✔️

@mariush2 mariush2 merged commit 8058032 into main Apr 29, 2026
22 of 25 checks passed
@mariush2 mariush2 deleted the fix/finalize-survey branch April 29, 2026 12:44
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.

3 participants