@lookiero/checkout 12.3.0 → 12.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cypress/integration/checkout.spec.ts +14 -9
- package/cypress/support/interceptViewCheckoutFeedbackDefinitionByCheckoutId.ts +6 -0
- package/dist/public/public/assets/adaptive-icon.png +0 -0
- package/dist/public/public/assets/favicon.png +0 -0
- package/dist/public/public/assets/icon.png +0 -0
- package/dist/public/public/assets/splash.png +0 -0
- package/dist/public/public/images/not-found.png +0 -0
- package/dist/src/ExpoRoot.js +2 -2
- package/dist/src/domain/checkoutItem/model/currency.d.ts +6 -0
- package/dist/src/domain/checkoutItem/model/currency.js +7 -0
- package/dist/src/domain/uiSetting/command/updateUiSetting.d.ts +15 -0
- package/dist/src/domain/uiSetting/command/updateUiSetting.js +10 -0
- package/dist/src/domain/uiSetting/model/uiSetting.d.ts +9 -0
- package/dist/src/domain/uiSetting/model/uiSetting.js +11 -0
- package/dist/src/domain/uiSetting/model/uiSettingUpdated.d.ts +15 -0
- package/dist/src/domain/uiSetting/model/uiSettingUpdated.js +8 -0
- package/dist/src/domain/uiSetting/model/uiSettings.d.ts +7 -0
- package/dist/src/domain/uiSetting/model/uiSettings.js +1 -0
- package/dist/src/infrastructure/delivery/baseBootstrap.d.ts +2 -2
- package/dist/src/infrastructure/delivery/baseBootstrap.js +4 -4
- package/dist/src/infrastructure/delivery/bootstrap.js +2 -2
- package/dist/src/infrastructure/delivery/bootstrap.mock.js +3 -3
- package/dist/src/infrastructure/domain/uiSetting/model/storageUiSettings.d.ts +17 -0
- package/dist/src/infrastructure/domain/uiSetting/model/storageUiSettings.js +20 -0
- package/dist/src/infrastructure/domain/uiSetting/react/useUpdateUiSetting.d.ts +18 -0
- package/dist/src/infrastructure/domain/uiSetting/react/useUpdateUiSetting.js +22 -0
- package/dist/src/infrastructure/integration/useRedirect.d.ts +7 -0
- package/dist/src/infrastructure/integration/useRedirect.js +1 -0
- package/dist/src/infrastructure/persistence/asyncStorageStorage.d.ts +5 -0
- package/dist/src/infrastructure/persistence/asyncStorageStorage.js +7 -0
- package/dist/src/infrastructure/persistence/uiSettingData.d.ts +6 -0
- package/dist/src/infrastructure/persistence/uiSettingData.js +1 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.d.ts +3 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.js +107 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.d.ts +12 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.js +10 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.d.ts +10 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.js +9 -0
- package/dist/src/infrastructure/projection/returnQuestion/returnQuestions.mock.js +47 -58
- package/dist/src/infrastructure/projection/uiSetting/react/useViewUiSettingByKey.d.ts +10 -0
- package/dist/src/infrastructure/projection/uiSetting/react/useViewUiSettingByKey.js +11 -0
- package/dist/src/infrastructure/projection/uiSetting/storageUiSettingByKeyView.d.ts +13 -0
- package/dist/src/infrastructure/projection/uiSetting/storageUiSettingByKeyView.js +15 -0
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.d.ts +2 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.js +4 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.d.ts +2 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.d.ts +5 -5
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.js +1 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.d.ts +5 -4
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.d.ts +2 -3
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.js +5 -7
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +1 -2
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.d.ts +4 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.js +17 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.style.d.ts +11 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.style.js +16 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.d.ts +1 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.js +3 -5
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.js +2 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.js +2 -4
- package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.d.ts +27 -0
- package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.js +97 -0
- package/dist/src/infrastructure/ui/routing/useBasePath.d.ts +8 -0
- package/dist/src/infrastructure/ui/routing/useBasePath.js +9 -0
- package/dist/src/infrastructure/ui/settings/UISettings.d.ts +3 -0
- package/dist/src/infrastructure/ui/settings/UISettings.js +4 -0
- package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.d.ts +12 -0
- package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +90 -0
- package/dist/src/infrastructure/ui/views/feedback/Feedback.js +10 -9
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.d.ts +2 -3
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.js +17 -9
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.js +1 -0
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +3 -1
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.constants.d.ts +11 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.constants.js +10 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.d.ts +22 -2
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.metadata.d.ts +21 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.metadata.js +1 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.typeguards.d.ts +3 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.typeguards.js +7 -0
- package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.d.ts +25 -0
- package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.js +8 -0
- package/dist/src/projection/returnQuestion/returnQuestion.constants.d.ts +1 -0
- package/dist/src/projection/returnQuestion/returnQuestion.constants.js +1 -0
- package/dist/src/projection/returnQuestion/returnQuestion.d.ts +2 -2
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.d.ts +2 -4
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.js +2 -2
- package/dist/src/projection/uiSetting/viewUiSettingByKey.d.ts +29 -0
- package/dist/src/projection/uiSetting/viewUiSettingByKey.js +8 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
- package/src/ExpoRoot.tsx +2 -2
- package/src/infrastructure/delivery/baseBootstrap.ts +9 -9
- package/src/infrastructure/delivery/bootstrap.mock.ts +5 -4
- package/src/infrastructure/delivery/bootstrap.ts +2 -2
- package/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.ts +110 -0
- package/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.test.ts +52 -0
- package/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.ts +30 -0
- package/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.test.ts +58 -0
- package/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.ts +25 -0
- package/src/infrastructure/projection/returnQuestion/returnQuestions.mock.ts +47 -58
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.test.tsx +25 -30
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.tsx +12 -13
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.test.tsx +19 -26
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.tsx +3 -3
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.test.tsx +26 -26
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.tsx +6 -6
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.ts +5 -4
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.test.tsx +7 -11
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultReturnQuestionItem.test.tsx +16 -10
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.test.tsx +16 -22
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.test.tsx +16 -14
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.tsx +13 -14
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.test.tsx +9 -19
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.tsx +7 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +1 -2
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.style.ts +19 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.tsx +36 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.test.tsx +46 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.tsx +7 -12
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.tsx +6 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/util/__snapshots__/returnQuestionFeedback.test.ts.snap +22 -2
- package/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.ts +2 -7
- package/src/infrastructure/ui/views/feedback/Feedback.test.tsx +11 -5
- package/src/infrastructure/ui/views/feedback/Feedback.tsx +10 -9
- package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.test.tsx +2 -2
- package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.tsx +20 -13
- package/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.tsx +1 -0
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +3 -1
- package/src/projection/checkoutFeedback/checkoutFeedback.constants.ts +16 -0
- package/src/projection/checkoutFeedback/checkoutFeedback.metadata.ts +28 -0
- package/src/projection/checkoutFeedback/checkoutFeedback.ts +38 -2
- package/src/projection/checkoutFeedback/checkoutFeedback.typeguards.ts +13 -0
- package/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.test.ts +52 -0
- package/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.ts +61 -0
- package/src/projection/returnQuestion/returnQuestion.constants.ts +1 -0
- package/src/projection/returnQuestion/returnQuestion.ts +6 -2
- package/src/projection/returnQuestion/returnQuestion.typeguard.ts +3 -11
- package/cypress/support/interceptListCheckoutQuestionsByCheckoutId.ts +0 -9
- package/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.ts +0 -108
- package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.test.ts +0 -55
- package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.ts +0 -34
- package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.test.ts +0 -38
- package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.ts +0 -21
- package/src/projection/checkoutQuestion/checkoutQuestion.ts +0 -20
- package/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.test.ts +0 -31
- package/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.ts +0 -61
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { mock } from "jest-mock-extended";
|
|
2
|
+
import { QueryBus } from "@lookiero/messaging";
|
|
3
|
+
import { CheckoutFeedbackQuestionProjection } from "./checkoutFeedback";
|
|
4
|
+
import { CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
|
|
5
|
+
import {
|
|
6
|
+
viewCheckoutFeedbackDefinitionByCheckoutId,
|
|
7
|
+
viewCheckoutFeedbackDefinitionByCheckoutIdHandler as sut,
|
|
8
|
+
} from "./viewCheckoutFeedbackDefinitionByCheckoutId";
|
|
9
|
+
|
|
10
|
+
const checkoutId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
11
|
+
const checkoutFeedbackDefinition: CheckoutFeedbackQuestionProjection[] = [
|
|
12
|
+
{
|
|
13
|
+
id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
|
|
14
|
+
type: CheckoutFeedbackQuestionType.HOST_DEFAULT,
|
|
15
|
+
translationKey: "checkout.feedback.question.default",
|
|
16
|
+
metadata: {
|
|
17
|
+
showCondition: [],
|
|
18
|
+
},
|
|
19
|
+
children: [
|
|
20
|
+
{
|
|
21
|
+
id: "01975911-d451-7651-b1ae-3f977928e8a2",
|
|
22
|
+
type: CheckoutFeedbackQuestionType.HOST_TEXTAREA,
|
|
23
|
+
metadata: {
|
|
24
|
+
showCondition: [],
|
|
25
|
+
},
|
|
26
|
+
children: [
|
|
27
|
+
{
|
|
28
|
+
id: "01975911-ec6b-768e-9b4a-a6f2645b01b2",
|
|
29
|
+
type: CheckoutFeedbackQuestionType.TEXTAREA,
|
|
30
|
+
translationKey: "checkout.feedback.question.textarea",
|
|
31
|
+
metadata: {
|
|
32
|
+
placeholder: "checkout.feedback.question.textarea.placeholder",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
const queryBus = mock<QueryBus>();
|
|
41
|
+
const signal = mock<AbortSignal>();
|
|
42
|
+
|
|
43
|
+
describe("viewCheckoutFeedbackDefinitionByCheckoutId", () => {
|
|
44
|
+
it("returns checkout questions by checkout id", async () => {
|
|
45
|
+
const query = viewCheckoutFeedbackDefinitionByCheckoutId({ checkoutId });
|
|
46
|
+
const view = jest.fn(() => Promise.resolve(checkoutFeedbackDefinition));
|
|
47
|
+
|
|
48
|
+
const checkoutFeedbackDefinitionResult = await sut({ view, queryBus, signal })(query);
|
|
49
|
+
|
|
50
|
+
expect(checkoutFeedbackDefinitionResult).toBe(checkoutFeedbackDefinition);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CancelableQueryViewArgs,
|
|
3
|
+
query,
|
|
4
|
+
Query,
|
|
5
|
+
QueryHandlerFunction,
|
|
6
|
+
QueryHandlerFunctionArgs,
|
|
7
|
+
} from "@lookiero/messaging";
|
|
8
|
+
import { CheckoutFeedbackQuestionProjection } from "./checkoutFeedback";
|
|
9
|
+
|
|
10
|
+
const VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID = "view_checkout_feedback_definition_by_checkout_id";
|
|
11
|
+
|
|
12
|
+
interface ViewCheckoutFeedbackDefinitionByCheckoutIdPayload {
|
|
13
|
+
readonly checkoutId: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface ViewCheckoutFeedbackDefinitionByCheckoutId
|
|
17
|
+
extends Query<typeof VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID>,
|
|
18
|
+
ViewCheckoutFeedbackDefinitionByCheckoutIdPayload {}
|
|
19
|
+
|
|
20
|
+
interface ViewCheckoutFeedbackDefinitionByCheckoutIdFunction {
|
|
21
|
+
(payload: ViewCheckoutFeedbackDefinitionByCheckoutIdPayload): ViewCheckoutFeedbackDefinitionByCheckoutId;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const viewCheckoutFeedbackDefinitionByCheckoutId: ViewCheckoutFeedbackDefinitionByCheckoutIdFunction = (payload) => ({
|
|
25
|
+
...query({ name: VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID }),
|
|
26
|
+
...payload,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
type ViewCheckoutFeedbackDefinitionByCheckoutIdResult = CheckoutFeedbackQuestionProjection[] | null;
|
|
30
|
+
|
|
31
|
+
interface CheckoutFeedbackDefinitionByCheckoutIdViewArgs extends CancelableQueryViewArgs {
|
|
32
|
+
readonly checkoutId: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface CheckoutFeedbackDefinitionByCheckoutIdView {
|
|
36
|
+
(args: CheckoutFeedbackDefinitionByCheckoutIdViewArgs): Promise<ViewCheckoutFeedbackDefinitionByCheckoutIdResult>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface ViewCheckoutFeedbackDefinitionByCheckoutIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
|
|
40
|
+
readonly view: CheckoutFeedbackDefinitionByCheckoutIdView;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const viewCheckoutFeedbackDefinitionByCheckoutIdHandler: QueryHandlerFunction<
|
|
44
|
+
ViewCheckoutFeedbackDefinitionByCheckoutId,
|
|
45
|
+
ViewCheckoutFeedbackDefinitionByCheckoutIdResult,
|
|
46
|
+
ViewCheckoutFeedbackDefinitionByCheckoutIdHandlerFunctionArgs
|
|
47
|
+
> =
|
|
48
|
+
({ view, signal }) =>
|
|
49
|
+
async ({ checkoutId }) =>
|
|
50
|
+
view({ checkoutId, signal });
|
|
51
|
+
|
|
52
|
+
export type {
|
|
53
|
+
ViewCheckoutFeedbackDefinitionByCheckoutId,
|
|
54
|
+
CheckoutFeedbackDefinitionByCheckoutIdView,
|
|
55
|
+
ViewCheckoutFeedbackDefinitionByCheckoutIdResult,
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID,
|
|
59
|
+
viewCheckoutFeedbackDefinitionByCheckoutId,
|
|
60
|
+
viewCheckoutFeedbackDefinitionByCheckoutIdHandler,
|
|
61
|
+
};
|
|
@@ -6,11 +6,15 @@ type ReturnQuestionTypesWithChildren =
|
|
|
6
6
|
| ReturnQuestionType.HOST_DEFAULT
|
|
7
7
|
| ReturnQuestionType.HOST_SELECT
|
|
8
8
|
| ReturnQuestionType.HOST_STACK
|
|
9
|
-
| ReturnQuestionType.HOST_TEXTAREA
|
|
9
|
+
| ReturnQuestionType.HOST_TEXTAREA
|
|
10
|
+
| ReturnQuestionType.HOST_RADIO_GROUP;
|
|
10
11
|
|
|
11
12
|
type ReturnQuestionTypesWithOptionalChildren = ReturnQuestionType.OPTION;
|
|
12
13
|
|
|
13
|
-
type ReturnQuestionTypesWithOptionalTranslationKeys =
|
|
14
|
+
type ReturnQuestionTypesWithOptionalTranslationKeys =
|
|
15
|
+
| ReturnQuestionType.HOST_DEFAULT
|
|
16
|
+
| ReturnQuestionType.HOST_STACK
|
|
17
|
+
| ReturnQuestionType.HOST_RADIO_GROUP;
|
|
14
18
|
|
|
15
19
|
type ReturnQuestionMetadata<RQT extends ReturnQuestionType> = ExcludePropertyIfOptional<
|
|
16
20
|
"metadata",
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ReturnQuestionProjection,
|
|
3
|
-
ReturnQuestionTypesWithChildren,
|
|
4
|
-
ReturnQuestionTypesWithOptionalTranslationKeys,
|
|
5
|
-
} from "./returnQuestion";
|
|
1
|
+
import { ReturnQuestionProjection, ReturnQuestionTypesWithChildren } from "./returnQuestion";
|
|
6
2
|
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
7
3
|
|
|
8
|
-
const returnQuestionWithTranslationKey = (
|
|
9
|
-
question: ReturnQuestionProjection,
|
|
10
|
-
): question is ReturnQuestionProjection<Exclude<ReturnQuestionType, ReturnQuestionTypesWithOptionalTranslationKeys>> =>
|
|
11
|
-
Boolean(question.translationKey);
|
|
12
|
-
|
|
13
4
|
const returnQuestionHasChildren = (
|
|
14
5
|
question: ReturnQuestionProjection,
|
|
15
6
|
): question is ReturnQuestionProjection<ReturnQuestionTypesWithChildren> =>
|
|
@@ -18,7 +9,8 @@ const returnQuestionHasChildren = (
|
|
|
18
9
|
ReturnQuestionType.HOST_SELECT,
|
|
19
10
|
ReturnQuestionType.HOST_STACK,
|
|
20
11
|
ReturnQuestionType.HOST_TEXTAREA,
|
|
12
|
+
ReturnQuestionType.HOST_RADIO_GROUP,
|
|
21
13
|
ReturnQuestionType.OPTION,
|
|
22
14
|
].includes(question.type);
|
|
23
15
|
|
|
24
|
-
export {
|
|
16
|
+
export { returnQuestionHasChildren };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CheckoutQuestionProjection } from "../../src/projection/checkoutQuestion/checkoutQuestion";
|
|
2
|
-
|
|
3
|
-
const interceptListCheckoutQuestionsByCheckoutId = (response: CheckoutQuestionProjection[]) =>
|
|
4
|
-
cy.intercept(
|
|
5
|
-
{ method: "POST", url: "/local-to-dev/list-checkout-questions-by-checkout-id" },
|
|
6
|
-
{ body: { result: response } },
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
export { interceptListCheckoutQuestionsByCheckoutId };
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CheckoutQuestionProjection,
|
|
3
|
-
CheckoutQuestionType,
|
|
4
|
-
} from "../../../projection/checkoutQuestion/checkoutQuestion";
|
|
5
|
-
|
|
6
|
-
const checkoutQuestions: CheckoutQuestionProjection[] = [
|
|
7
|
-
{
|
|
8
|
-
id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
|
|
9
|
-
name: "checkout_question.selection.question",
|
|
10
|
-
placeholder: "checkout_question.selection.placeholder",
|
|
11
|
-
type: CheckoutQuestionType.HOST_SELECT,
|
|
12
|
-
showCondition: [],
|
|
13
|
-
children: [
|
|
14
|
-
{
|
|
15
|
-
id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
|
|
16
|
-
name: "checkout_question.icon.bad",
|
|
17
|
-
placeholder: "",
|
|
18
|
-
type: CheckoutQuestionType.ICON,
|
|
19
|
-
showCondition: [],
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
id: "85e84a77-461c-41e6-8544-95b5294d0b80",
|
|
23
|
-
name: "checkout_question.icon.regular",
|
|
24
|
-
placeholder: "",
|
|
25
|
-
type: CheckoutQuestionType.ICON,
|
|
26
|
-
showCondition: [],
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
id: "29441d25-8d9f-471e-a13e-a03f61c88091",
|
|
30
|
-
name: "checkout_question.icon.good",
|
|
31
|
-
placeholder: "",
|
|
32
|
-
type: CheckoutQuestionType.ICON,
|
|
33
|
-
showCondition: [],
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: "6a6d3878-5561-412c-96f3-7ed79ee587bb",
|
|
39
|
-
name: "checkout_question.experience.question",
|
|
40
|
-
placeholder: "checkout_question.experience.placeholder",
|
|
41
|
-
type: CheckoutQuestionType.HOST_SELECT,
|
|
42
|
-
showCondition: [],
|
|
43
|
-
children: [
|
|
44
|
-
{
|
|
45
|
-
id: "a3d937b6-7499-4a3c-86bf-5c0af9ab2e23",
|
|
46
|
-
name: "checkout_question.icon.bad",
|
|
47
|
-
placeholder: "",
|
|
48
|
-
type: CheckoutQuestionType.ICON,
|
|
49
|
-
showCondition: [],
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
id: "7970edd3-fb5c-42d3-afe3-ce31bcbb856c",
|
|
53
|
-
name: "checkout_question.icon.regular",
|
|
54
|
-
placeholder: "",
|
|
55
|
-
type: CheckoutQuestionType.ICON,
|
|
56
|
-
showCondition: [],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
id: "bab3d4f9-0227-4550-a53f-3c125d68429c",
|
|
60
|
-
name: "checkout_question.icon.good",
|
|
61
|
-
placeholder: "",
|
|
62
|
-
type: CheckoutQuestionType.ICON,
|
|
63
|
-
showCondition: [],
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
id: "a1acdb2d-62c8-467f-b7cc-dc24d967290c",
|
|
69
|
-
name: "checkout_question.personalshopper.question",
|
|
70
|
-
placeholder: "checkout_question.personalshopper.placeholder",
|
|
71
|
-
type: CheckoutQuestionType.HOST_SELECT,
|
|
72
|
-
showCondition: ["68c0bb98-b00a-4b86-af43-528fe903cb69"],
|
|
73
|
-
children: [
|
|
74
|
-
{
|
|
75
|
-
id: "cce7851c-92c7-461b-8dcb-903c5de59ed1",
|
|
76
|
-
name: "checkout_question.personalshopper.yes",
|
|
77
|
-
placeholder: "",
|
|
78
|
-
type: CheckoutQuestionType.BUTTON,
|
|
79
|
-
showCondition: [],
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
id: "4bf8f27d-669b-4d36-8d39-b5599c671816",
|
|
83
|
-
name: "checkout_question.personalshopper.no",
|
|
84
|
-
placeholder: "",
|
|
85
|
-
type: CheckoutQuestionType.BUTTON,
|
|
86
|
-
showCondition: [],
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
id: "ce3e8d57-5eea-4dd3-bef4-2e811a143612",
|
|
92
|
-
name: "checkout_question.comment.question",
|
|
93
|
-
placeholder: "",
|
|
94
|
-
type: CheckoutQuestionType.HOST_TEXTAREA,
|
|
95
|
-
showCondition: [],
|
|
96
|
-
children: [
|
|
97
|
-
{
|
|
98
|
-
id: "1123a37d-bc00-43a4-9d28-cee1dfaf356c",
|
|
99
|
-
name: "checkout_question.comment.question",
|
|
100
|
-
placeholder: "checkout_question.comment.placeholder",
|
|
101
|
-
type: CheckoutQuestionType.TEXTAREA,
|
|
102
|
-
showCondition: [],
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
];
|
|
107
|
-
|
|
108
|
-
export { checkoutQuestions };
|
package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.test.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { mock } from "jest-mock-extended";
|
|
2
|
-
import { fetchHttpPost } from "@lookiero/sty-psp-http";
|
|
3
|
-
import { CheckoutQuestionProjection } from "../../../projection/checkoutQuestion/checkoutQuestion";
|
|
4
|
-
import { checkoutQuestions } from "./checkoutQuestions.mock";
|
|
5
|
-
import { httpCheckoutQuestionsByCheckoutIdView as sut } from "./httpCheckoutQuestionsByCheckoutIdView";
|
|
6
|
-
|
|
7
|
-
const fetchMock = jest.fn();
|
|
8
|
-
global.fetch = fetchMock;
|
|
9
|
-
const apiUrl = "/api";
|
|
10
|
-
const getAuthToken = () => Promise.resolve("token");
|
|
11
|
-
const view = sut({ httpPost: fetchHttpPost({ apiUrl: () => apiUrl, getAuthToken, device: "web", version: "1.0.0" }) });
|
|
12
|
-
const signal = mock<AbortSignal>();
|
|
13
|
-
|
|
14
|
-
const checkoutId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
15
|
-
const checkoutQuestionsResponse: { result: CheckoutQuestionProjection[] } = {
|
|
16
|
-
result: checkoutQuestions,
|
|
17
|
-
};
|
|
18
|
-
const checkoutQuestionsResponseOk: Response = {
|
|
19
|
-
ok: true,
|
|
20
|
-
status: 200,
|
|
21
|
-
text: () => Promise.resolve(JSON.stringify(checkoutQuestionsResponse)),
|
|
22
|
-
} as Response;
|
|
23
|
-
const checkoutQuestionsResponseNotFound: Response = {
|
|
24
|
-
ok: false,
|
|
25
|
-
status: 404,
|
|
26
|
-
} as Response;
|
|
27
|
-
const checkoutQuestionsResponseError: Response = {
|
|
28
|
-
ok: false,
|
|
29
|
-
} as Response;
|
|
30
|
-
|
|
31
|
-
describe("httpCheckoutQuestionsByCheckoutIdView", () => {
|
|
32
|
-
it("returns a CheckoutQuestions projection for a 200 response", async () => {
|
|
33
|
-
fetchMock.mockReturnValue(Promise.resolve(checkoutQuestionsResponseOk));
|
|
34
|
-
|
|
35
|
-
const returnedCheckoutQuestions = await view({ checkoutId, signal });
|
|
36
|
-
|
|
37
|
-
expect(returnedCheckoutQuestions).toStrictEqual(checkoutQuestionsResponse.result);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("returns null for a 404 response", async () => {
|
|
41
|
-
fetchMock.mockReturnValue(Promise.resolve(checkoutQuestionsResponseNotFound));
|
|
42
|
-
|
|
43
|
-
const returnedCheckoutQuestions = await view({ checkoutId, signal });
|
|
44
|
-
|
|
45
|
-
expect(returnedCheckoutQuestions).toBeNull();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("returns null for a non successfull response", async () => {
|
|
49
|
-
fetchMock.mockReturnValue(Promise.resolve(checkoutQuestionsResponseError));
|
|
50
|
-
|
|
51
|
-
const returnedCheckoutQuestions = await view({ checkoutId, signal });
|
|
52
|
-
|
|
53
|
-
expect(returnedCheckoutQuestions).toBeNull();
|
|
54
|
-
});
|
|
55
|
-
});
|
package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { HttpPostFunction } from "@lookiero/sty-psp-http";
|
|
2
|
-
import {
|
|
3
|
-
CheckoutQuestionsByCheckoutIdView,
|
|
4
|
-
ListCheckoutQuestionsByCheckoutIdResult,
|
|
5
|
-
} from "../../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
|
|
6
|
-
|
|
7
|
-
interface HttpCheckoutQuestionsByCheckoutIdView extends CheckoutQuestionsByCheckoutIdView {}
|
|
8
|
-
|
|
9
|
-
interface HttpCheckoutQuestionsByCheckoutIdViewFunctionArgs {
|
|
10
|
-
readonly httpPost: HttpPostFunction;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface HttpCheckoutQuestionsByCheckoutIdViewFunction {
|
|
14
|
-
(args: HttpCheckoutQuestionsByCheckoutIdViewFunctionArgs): HttpCheckoutQuestionsByCheckoutIdView;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface ListCheckoutQuestionsByCheckoutIdResponse {
|
|
18
|
-
readonly result: ListCheckoutQuestionsByCheckoutIdResult;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const httpCheckoutQuestionsByCheckoutIdView: HttpCheckoutQuestionsByCheckoutIdViewFunction =
|
|
22
|
-
({ httpPost }) =>
|
|
23
|
-
async ({ checkoutId, signal }) =>
|
|
24
|
-
await httpPost<ListCheckoutQuestionsByCheckoutIdResponse, ListCheckoutQuestionsByCheckoutIdResult>({
|
|
25
|
-
endpoint: "/list-checkout-questions-by-checkout-id",
|
|
26
|
-
body: { checkoutId },
|
|
27
|
-
signal,
|
|
28
|
-
result: {
|
|
29
|
-
error: null,
|
|
30
|
-
success: (response) => response.result,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
export { httpCheckoutQuestionsByCheckoutIdView };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { renderHook, waitFor } from "@testing-library/react-native";
|
|
2
|
-
import { bootstrap, QueryStatus } from "@lookiero/messaging-react";
|
|
3
|
-
import {
|
|
4
|
-
CheckoutQuestionProjection,
|
|
5
|
-
CheckoutQuestionType,
|
|
6
|
-
} from "../../../../projection/checkoutQuestion/checkoutQuestion";
|
|
7
|
-
import {
|
|
8
|
-
listCheckoutQuestionsByCheckoutIdHandler,
|
|
9
|
-
LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID,
|
|
10
|
-
} from "../../../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
|
|
11
|
-
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
12
|
-
import { useListCheckoutQuestionsByCheckoutId as sut } from "./useListCheckoutQuestionsByCheckoutId";
|
|
13
|
-
|
|
14
|
-
const checkoutId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
15
|
-
const checkoutQuestionProjection: CheckoutQuestionProjection = {
|
|
16
|
-
id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
|
|
17
|
-
name: "main_title",
|
|
18
|
-
placeholder: "",
|
|
19
|
-
type: CheckoutQuestionType.HOST_DEFAULT,
|
|
20
|
-
showCondition: [],
|
|
21
|
-
};
|
|
22
|
-
const view = jest.fn().mockReturnValue(checkoutQuestionProjection);
|
|
23
|
-
const { Component: Messaging } = bootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
24
|
-
.query(LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID, listCheckoutQuestionsByCheckoutIdHandler, { view })
|
|
25
|
-
.build();
|
|
26
|
-
|
|
27
|
-
describe("useListCheckoutQuestionsByCheckoutId integration hook", () => {
|
|
28
|
-
it("returns success as the query status and the result itself after rendering the hook", async () => {
|
|
29
|
-
const { result } = renderHook(() => sut({ checkoutId }), { wrapper: Messaging });
|
|
30
|
-
|
|
31
|
-
await waitFor(() => {
|
|
32
|
-
const [projection, status] = result.current;
|
|
33
|
-
|
|
34
|
-
expect(projection).toStrictEqual(checkoutQuestionProjection);
|
|
35
|
-
expect(status).toBe(QueryStatus.SUCCESS);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useQuery, UseQueryFunctionResult } from "@lookiero/messaging-react";
|
|
2
|
-
import { CheckoutQuestionProjection } from "../../../../projection/checkoutQuestion/checkoutQuestion";
|
|
3
|
-
import { listCheckoutQuestionsByCheckoutId } from "../../../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
|
|
4
|
-
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
5
|
-
|
|
6
|
-
interface UseListChckoutQuestionsByCheckoutIdFunctionArgs {
|
|
7
|
-
readonly checkoutId: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface UseListChckoutQuestionsByCheckoutIdFunction {
|
|
11
|
-
(args: UseListChckoutQuestionsByCheckoutIdFunctionArgs): UseQueryFunctionResult<CheckoutQuestionProjection[]>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const useListCheckoutQuestionsByCheckoutId: UseListChckoutQuestionsByCheckoutIdFunction = ({ checkoutId }) =>
|
|
15
|
-
useQuery({
|
|
16
|
-
query: listCheckoutQuestionsByCheckoutId({ checkoutId }),
|
|
17
|
-
contextId: MESSAGING_CONTEXT_ID,
|
|
18
|
-
options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export { useListCheckoutQuestionsByCheckoutId };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
enum CheckoutQuestionType {
|
|
2
|
-
HOST_DEFAULT = "HOST_DEFAULT",
|
|
3
|
-
HOST_TEXTAREA = "HOST_TEXTAREA",
|
|
4
|
-
HOST_SELECT = "HOST_SELECT",
|
|
5
|
-
TEXTAREA = "TEXTAREA",
|
|
6
|
-
ICON = "ICON",
|
|
7
|
-
BUTTON = "BUTTON",
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface CheckoutQuestionProjection {
|
|
11
|
-
readonly id: string;
|
|
12
|
-
readonly name: string;
|
|
13
|
-
readonly placeholder: string; // required for CheckoutQuestionType.SELECT | CheckoutQuestionType.TEXTAREA
|
|
14
|
-
readonly type: CheckoutQuestionType;
|
|
15
|
-
readonly children?: CheckoutQuestionProjection[];
|
|
16
|
-
readonly showCondition: string[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { CheckoutQuestionType };
|
|
20
|
-
export type { CheckoutQuestionProjection };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { mock } from "jest-mock-extended";
|
|
2
|
-
import { QueryBus } from "@lookiero/messaging";
|
|
3
|
-
import { CheckoutQuestionProjection, CheckoutQuestionType } from "./checkoutQuestion";
|
|
4
|
-
import {
|
|
5
|
-
listCheckoutQuestionsByCheckoutId,
|
|
6
|
-
listCheckoutQuestionsByCheckoutIdHandler as sut,
|
|
7
|
-
} from "./listCheckoutQuestionsByCheckoutId";
|
|
8
|
-
|
|
9
|
-
const checkoutId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
10
|
-
const checkoutQuestionsProjection: CheckoutQuestionProjection[] = [
|
|
11
|
-
{
|
|
12
|
-
id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
|
|
13
|
-
name: "main_title",
|
|
14
|
-
placeholder: "",
|
|
15
|
-
type: CheckoutQuestionType.HOST_DEFAULT,
|
|
16
|
-
showCondition: [],
|
|
17
|
-
},
|
|
18
|
-
];
|
|
19
|
-
const queryBus = mock<QueryBus>();
|
|
20
|
-
const signal = mock<AbortSignal>();
|
|
21
|
-
|
|
22
|
-
describe("listCheckoutQuestionsByCheckoutId", () => {
|
|
23
|
-
it("returns checkout questions by checkout id", async () => {
|
|
24
|
-
const query = listCheckoutQuestionsByCheckoutId({ checkoutId });
|
|
25
|
-
const view = jest.fn(() => Promise.resolve(checkoutQuestionsProjection));
|
|
26
|
-
|
|
27
|
-
const checkoutQuestionsProjectionResult = await sut({ view, queryBus, signal })(query);
|
|
28
|
-
|
|
29
|
-
expect(checkoutQuestionsProjectionResult).toBe(checkoutQuestionsProjection);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CancelableQueryViewArgs,
|
|
3
|
-
query,
|
|
4
|
-
Query,
|
|
5
|
-
QueryHandlerFunction,
|
|
6
|
-
QueryHandlerFunctionArgs,
|
|
7
|
-
} from "@lookiero/messaging";
|
|
8
|
-
import { CheckoutQuestionProjection } from "./checkoutQuestion";
|
|
9
|
-
|
|
10
|
-
const LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID = "list_checkout_questions_by_checkout_id";
|
|
11
|
-
|
|
12
|
-
interface ListCheckoutQuestionsByCheckoutIdPayload {
|
|
13
|
-
readonly checkoutId: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface ListCheckoutQuestionsByCheckoutId
|
|
17
|
-
extends Query<typeof LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID>,
|
|
18
|
-
ListCheckoutQuestionsByCheckoutIdPayload {}
|
|
19
|
-
|
|
20
|
-
interface ListCheckoutQuestionsByCheckoutIdFunction {
|
|
21
|
-
(payload: ListCheckoutQuestionsByCheckoutIdPayload): ListCheckoutQuestionsByCheckoutId;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const listCheckoutQuestionsByCheckoutId: ListCheckoutQuestionsByCheckoutIdFunction = (payload) => ({
|
|
25
|
-
...query({ name: LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID }),
|
|
26
|
-
...payload,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
type ListCheckoutQuestionsByCheckoutIdResult = CheckoutQuestionProjection[] | null;
|
|
30
|
-
|
|
31
|
-
interface CheckoutQuestionsByCheckoutIdViewArgs extends CancelableQueryViewArgs {
|
|
32
|
-
readonly checkoutId: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface CheckoutQuestionsByCheckoutIdView {
|
|
36
|
-
(args: CheckoutQuestionsByCheckoutIdViewArgs): Promise<ListCheckoutQuestionsByCheckoutIdResult>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface ListCheckoutQuestionsByCheckoutIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
|
|
40
|
-
readonly view: CheckoutQuestionsByCheckoutIdView;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const listCheckoutQuestionsByCheckoutIdHandler: QueryHandlerFunction<
|
|
44
|
-
ListCheckoutQuestionsByCheckoutId,
|
|
45
|
-
ListCheckoutQuestionsByCheckoutIdResult,
|
|
46
|
-
ListCheckoutQuestionsByCheckoutIdHandlerFunctionArgs
|
|
47
|
-
> =
|
|
48
|
-
({ view, signal }) =>
|
|
49
|
-
async ({ checkoutId }) =>
|
|
50
|
-
view({ checkoutId, signal });
|
|
51
|
-
|
|
52
|
-
export type {
|
|
53
|
-
ListCheckoutQuestionsByCheckoutId,
|
|
54
|
-
CheckoutQuestionsByCheckoutIdView,
|
|
55
|
-
ListCheckoutQuestionsByCheckoutIdResult,
|
|
56
|
-
};
|
|
57
|
-
export {
|
|
58
|
-
LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID,
|
|
59
|
-
listCheckoutQuestionsByCheckoutId,
|
|
60
|
-
listCheckoutQuestionsByCheckoutIdHandler,
|
|
61
|
-
};
|