Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: feedback analytics and previously submitted answers #3948

Merged
merged 7 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { gql } from "graphql-request";

import { Passport } from "@opensystemslab/planx-core";

import { $api } from "../../../../client/index.js";
import type { Operation } from "../sanitiseApplicationData/types.js";

Expand All @@ -20,6 +21,7 @@ const ALLOW_LIST = [
"application.information.sensitive",
"application.type",
"drawBoundary.action",
"_feedback",
"findProperty.action",
"_overrides",
"planningConstraints.action",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import ErrorWrapper from "ui/shared/ErrorWrapper";
import Input from "ui/shared/Input/Input";
import ReactMarkdownOrHtml from "ui/shared/ReactMarkdownOrHtml/ReactMarkdownOrHtml";

import { getPreviouslySubmittedData, makeData } from "../../shared/utils";
import { makeData } from "../../shared/utils";
import { FaceBox } from "../components/FaceBox";
import { createFeedbackSchema, Feedback, FormProps } from "../model";
import { StyledToggleButtonGroup } from "../styled";
Expand Down Expand Up @@ -50,7 +50,7 @@ const FeedbackComponent = (props: PublicProps<Feedback>): FCReturn => {
};

const formik = useFormik<FormProps>({
initialValues: getPreviouslySubmittedData(props) ?? {
initialValues: props.previouslySubmittedData?.data?._feedback ?? {
feedbackScore: "",
userComment: "",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,34 @@ describe("when feedback is required but the user does not submit any data", asyn
});
});
});

describe("When the user presses to go back to the feedback component", () => {
it("recovers the previously submitted answers", async () => {
const handleSubmit = vi.fn();

const { user } = setup(
<FeedbackComponent
handleSubmit={handleSubmit}
feedbackRequired={false}
previouslySubmittedData={{
data: {
_feedback: {
userComment: "I wrote this previously",
feedbackScore: 2,
},
},
}}
/>,
);

expect(screen.getByText("I wrote this previously")).toBeVisible();

await user.click(screen.getByTestId("continue-button"));

expect(insertFeedbackMutation).toHaveBeenCalledWith({
feedbackScore: 2,
feedbackType: "component",
userComment: "I wrote this previously",
});
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DocumentNode } from "@apollo/client";
import { ComponentType as TYPES } from "@opensystemslab/planx-core/types";
import { PASSPORT_FEEDBACK_KEY } from "@planx/components/Feedback/Public/Public";
import Bowser from "bowser";
import { publicClient } from "lib/graphql";
import React, { createContext, useContext, useEffect } from "react";
Expand Down Expand Up @@ -48,6 +49,7 @@ export const ALLOW_LIST = [
"application.information.sensitive",
"application.type",
"drawBoundary.action",
PASSPORT_FEEDBACK_KEY,
"findProperty.action",
"_overrides",
"planningConstraints.action",
Expand Down
Loading
Loading