@licklist/design 0.58.11 → 0.59.0-dev.1

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.
Files changed (200) hide show
  1. package/bitbucket-pipelines.yml +0 -8
  2. package/dist/assets/iframe/calendar.svg +2 -2
  3. package/dist/assets/iframe/calendar.svg.js +1 -1
  4. package/dist/assets/iframe/ticket.svg +2 -2
  5. package/dist/assets/iframe/ticket.svg.js +1 -1
  6. package/dist/calendar/Calendar.d.ts +1 -1
  7. package/dist/calendar/Calendar.d.ts.map +1 -1
  8. package/dist/calendar/Calendar.js +1 -1
  9. package/dist/calendar/components/CalendarDates/CalendarDates.d.ts +2 -2
  10. package/dist/calendar/components/CalendarDates/CalendarDates.d.ts.map +1 -1
  11. package/dist/calendar/components/CalendarDates/CalendarDates.js +1 -1
  12. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.d.ts +3 -1
  13. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.d.ts.map +1 -1
  14. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.js +1 -1
  15. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts +3 -1
  16. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts.map +1 -1
  17. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.js +1 -1
  18. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts +3 -1
  19. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts.map +1 -1
  20. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +1 -1
  21. package/dist/iframe/event/event-card/IframeEventCard.d.ts +2 -1
  22. package/dist/iframe/event/event-card/IframeEventCard.d.ts.map +1 -1
  23. package/dist/iframe/event/event-card/IframeEventCard.js +1 -1
  24. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts +2 -2
  25. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts.map +1 -1
  26. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.js +1 -1
  27. package/dist/iframe/order-process/components/BookingSummary/components/BookingSummaryAccordion/BookingSummaryAccordion.d.ts +4 -2
  28. package/dist/iframe/order-process/components/BookingSummary/components/BookingSummaryAccordion/BookingSummaryAccordion.d.ts.map +1 -1
  29. package/dist/iframe/order-process/components/BookingSummary/components/BookingSummaryAccordion/BookingSummaryAccordion.js +1 -1
  30. package/dist/iframe/order-process/components/BookingSummary/components/SummaryTotal/components/SummaryTotalBlock.d.ts +1 -1
  31. package/dist/iframe/order-process/components/BookingSummary/components/SummaryTotal/components/SummaryTotalBlock.d.ts.map +1 -1
  32. package/dist/iframe/order-process/components/BookingSummary/components/SummaryTotal/components/SummaryTotalBlock.js +1 -1
  33. package/dist/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.d.ts +4 -2
  34. package/dist/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.d.ts.map +1 -1
  35. package/dist/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.js +1 -1
  36. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts +4 -0
  37. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts.map +1 -1
  38. package/dist/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.js +1 -1
  39. package/dist/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.d.ts.map +1 -1
  40. package/dist/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.js +1 -1
  41. package/dist/iframe/page/components/PageBody/constants.d.ts +1 -0
  42. package/dist/iframe/page/components/PageBody/constants.d.ts.map +1 -1
  43. package/dist/iframe/page/components/PageBody/constants.js +1 -1
  44. package/dist/iframe/page/components/PageBody/hooks/useResizePageBody.d.ts.map +1 -1
  45. package/dist/iframe/page/components/PageBody/hooks/useResizePageBody.js +1 -1
  46. package/dist/iframe/payment/order-items-table/utils/paymentSummary.js +1 -1
  47. package/dist/iframe/payment/payment-page/PaymentPage.d.ts.map +1 -1
  48. package/dist/iframe/payment/payment-page/PaymentPage.js +1 -1
  49. package/dist/iframe/ryft/RyftPaymentForm.d.ts.map +1 -1
  50. package/dist/iframe/ryft/RyftPaymentForm.js +1 -1
  51. package/dist/iframe/ryft/utils/ryft-form.d.ts +5 -0
  52. package/dist/iframe/ryft/utils/ryft-form.d.ts.map +1 -0
  53. package/dist/iframe/ryft/utils/ryft-form.js +1 -0
  54. package/dist/product-set/control/DateAndRecurrenceInput.d.ts +1 -1
  55. package/dist/product-set/control/DateAndRecurrenceInput.d.ts.map +1 -1
  56. package/dist/product-set/control/DateAndRecurrenceInput.js +1 -1
  57. package/dist/product-set/control/DateInput.d.ts.map +1 -1
  58. package/dist/product-set/control/ProductSetControl.d.ts +1 -1
  59. package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
  60. package/dist/product-set/form/ProductSetForm.d.ts +4 -1
  61. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  62. package/dist/product-set/hooks/useSortableTreeFunctions.d.ts.map +1 -1
  63. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  64. package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts.map +1 -1
  65. package/dist/product-set/product-category/ProductCategoryControl.d.ts +1 -0
  66. package/dist/product-set/product-category/ProductCategoryControl.d.ts.map +1 -1
  67. package/dist/product-set/product-category/ProductCategoryControl.js +1 -1
  68. package/dist/provider/working-hours-input/WorkingHoursInputDescription.d.ts.map +1 -1
  69. package/dist/provider/working-hours-input/WorkingHoursInputDescription.js +1 -1
  70. package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.d.ts.map +1 -1
  71. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +3 -1
  72. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
  73. package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
  74. package/dist/recurring-date-picker-input/utils.d.ts +12 -0
  75. package/dist/recurring-date-picker-input/utils.d.ts.map +1 -1
  76. package/dist/recurring-date-picker-input/utils.js +1 -1
  77. package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
  78. package/dist/sales/booking/results/components/ResultCard.js +1 -1
  79. package/dist/setting/admin/AdminSettingForm.d.ts +2 -2
  80. package/dist/setting/admin/AdminSettingForm.d.ts.map +1 -1
  81. package/dist/static/manual-date-picker/ManualDatePicker.js +1 -1
  82. package/dist/static/manual-date-picker/constants/index.d.ts +4 -1
  83. package/dist/static/manual-date-picker/constants/index.d.ts.map +1 -1
  84. package/dist/static/manual-date-picker/constants/index.js +1 -1
  85. package/dist/static/manual-date-picker/utils/index.d.ts +4 -0
  86. package/dist/static/manual-date-picker/utils/index.d.ts.map +1 -1
  87. package/dist/static/manual-date-picker/utils/index.js +1 -1
  88. package/dist/styles/iframe-events/Card.scss +24 -8
  89. package/dist/styles/iframe-events/PoweredBy.scss +2 -2
  90. package/dist/styles/iframe-order-process/IframeOrderProcess.scss +57 -20
  91. package/dist/styles/iframe-page/Page.scss +1 -0
  92. package/dist/styles/iframe-page/PageBody.scss +34 -12
  93. package/dist/styles/iframe-page/PageHeader.scss +41 -39
  94. package/dist/styles/ryft-payment-form/RyftPaymentForm.scss +125 -2
  95. package/dist/styles/sales/BookingResults.scss +1 -1
  96. package/dist/zone/form/ZoneForm.d.ts +2 -2
  97. package/dist/zone/form/ZoneForm.d.ts.map +1 -1
  98. package/dist/zone/form/ZoneForm.js +1 -1
  99. package/dist/zone/form/components/ZoneControl.d.ts +2 -2
  100. package/dist/zone/form/components/ZoneControl.d.ts.map +1 -1
  101. package/dist/zone/form/components/ZoneControl.js +1 -1
  102. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts +4 -4
  103. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts.map +1 -1
  104. package/dist/zone/form/components/ZoneRecurrencesControl.js +1 -1
  105. package/dist/zone/form/utils/dates.d.ts.map +1 -1
  106. package/package.json +10 -35
  107. package/src/assets/iframe/calendar.svg +2 -2
  108. package/src/assets/iframe/ticket.svg +2 -2
  109. package/src/calendar/Calendar.stories.tsx +23 -0
  110. package/src/calendar/Calendar.tsx +5 -5
  111. package/src/calendar/components/CalendarDates/CalendarDates.tsx +0 -5
  112. package/src/events/edit-event-modal/component/EditEventForm/EditEventForm.tsx +4 -0
  113. package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +10 -8
  114. package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +4 -0
  115. package/src/iframe/event/event-card/IframeEventCard.stories.tsx +1 -0
  116. package/src/iframe/event/event-card/IframeEventCard.tsx +7 -8
  117. package/src/iframe/order-process/components/BookingSummary/BookingSummary.stories.tsx +9 -0
  118. package/src/iframe/order-process/components/BookingSummary/BookingSummary.tsx +58 -7
  119. package/src/iframe/order-process/components/BookingSummary/components/BookingSummaryAccordion/BookingSummaryAccordion.tsx +8 -0
  120. package/src/iframe/order-process/components/BookingSummary/components/SummaryTotal/components/SummaryTotalBlock.tsx +4 -4
  121. package/src/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.tsx +63 -10
  122. package/src/iframe/order-process/components/BookingSummary/types/index.ts +4 -0
  123. package/src/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.tsx +1 -1
  124. package/src/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.tsx +3 -1
  125. package/src/iframe/page/components/PageBody/constants.ts +2 -0
  126. package/src/iframe/page/components/PageBody/hooks/useResizePageBody.ts +10 -0
  127. package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +6 -6
  128. package/src/iframe/payment/payment-page/PaymentPage.stories.tsx +546 -6
  129. package/src/iframe/payment/payment-page/PaymentPage.tsx +38 -29
  130. package/src/iframe/ryft/RyftPaymentForm.tsx +11 -5
  131. package/src/iframe/ryft/utils/ryft-form.ts +47 -0
  132. package/src/product-set/control/DateAndRecurrenceInput.tsx +3 -2
  133. package/src/product-set/control/DateInput.tsx +1 -3
  134. package/src/product-set/control/ProductSetControl.tsx +1 -1
  135. package/src/product-set/form/ProductCategoriesControl.tsx +1 -1
  136. package/src/product-set/form/ProductSetForm.tsx +5 -1
  137. package/src/product-set/hooks/useSortableTreeFunctions.ts +2 -0
  138. package/src/product-set/product/ProductControl.tsx +6 -3
  139. package/src/product-set/product/fixed-duration-fields/FixedDurationOptions.tsx +0 -2
  140. package/src/product-set/product-category/ProductCategoryControl.tsx +89 -27
  141. package/src/provider/working-hours-input/WorkingHoursInputDescription.tsx +4 -18
  142. package/src/recurring-date-picker-input/RecurrenceAndFrequencyInput.tsx +0 -1
  143. package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +11 -1
  144. package/src/recurring-date-picker-input/utils.ts +77 -0
  145. package/src/sales/booking/results/BookingResults.stories.tsx +3 -2
  146. package/src/sales/booking/results/components/ResultCard.tsx +2 -5
  147. package/src/setting/admin/AdminSettingForm.tsx +2 -2
  148. package/src/sortable-tree/SortableTreeItem.tsx +1 -1
  149. package/src/static/manual-date-picker/ManualDatePicker.tsx +3 -3
  150. package/src/static/manual-date-picker/constants/index.ts +6 -2
  151. package/src/static/manual-date-picker/utils/index.ts +11 -0
  152. package/src/static/switch/BooleanSwitch.tsx +1 -1
  153. package/src/styles/iframe-events/Card.scss +24 -8
  154. package/src/styles/iframe-events/PoweredBy.scss +2 -2
  155. package/src/styles/iframe-order-process/IframeOrderProcess.scss +57 -20
  156. package/src/styles/iframe-page/Page.scss +1 -0
  157. package/src/styles/iframe-page/PageBody.scss +34 -12
  158. package/src/styles/iframe-page/PageHeader.scss +41 -39
  159. package/src/styles/ryft-payment-form/RyftPaymentForm.scss +125 -2
  160. package/src/styles/sales/BookingResults.scss +1 -1
  161. package/src/zone/form/ZoneForm.tsx +3 -2
  162. package/src/zone/form/components/ZoneControl.tsx +3 -3
  163. package/src/zone/form/components/ZoneRecurrencesControl.tsx +7 -5
  164. package/src/zone/form/utils/dates.ts +9 -10
  165. package/jest.config.js +0 -29
  166. package/tests/Auth/Authorizer.test.tsx +0 -194
  167. package/tests/Auth/Layout/UserNavDropDown.test.tsx +0 -43
  168. package/tests/Auth/Layout/UserNavDropDownToggle.test.tsx +0 -33
  169. package/tests/Auth/Login/LoginComponent.test.tsx +0 -246
  170. package/tests/Auth/Login/LoginFormComponent.test.tsx +0 -182
  171. package/tests/Auth/Register/RegisterComponent.test.tsx +0 -285
  172. package/tests/Auth/Register/RegisterFormComponent.test.tsx +0 -170
  173. package/tests/Auth/Settings/Dashboard/IpInput.test.tsx +0 -130
  174. package/tests/Auth/Social/SocialCallbackComponent.test.tsx +0 -133
  175. package/tests/Auth/Social/SocialFormComponent.test.tsx +0 -118
  176. package/tests/FileUpload/FileUpload.test.tsx +0 -42
  177. package/tests/Notification/EmailTemplate.test.tsx +0 -82
  178. package/tests/ProductSet/ProductSetPopover.test.tsx +0 -40
  179. package/tests/Report/Report.test.tsx +0 -48
  180. package/tests/Sales/Coupon.test.tsx +0 -51
  181. package/tests/Sales/SalesAndVIews.test.tsx +0 -63
  182. package/tests/SnippetTemplates/SnippetTemplates.test.tsx +0 -56
  183. package/tests/Table/FilterHelperComponent.test.tsx +0 -88
  184. package/tests/Table/PaginationHelperComponent.test.tsx +0 -109
  185. package/tests/Table/PerPageHelperComponent.test.tsx +0 -34
  186. package/tests/Table/TableHelperComponent.test.tsx +0 -295
  187. package/tests/TipTapEditor/TipTapEditor.test.tsx +0 -28
  188. package/tests/__mock__/hooks/useAuthApi.ts +0 -13
  189. package/tests/__mock__/hooks/useAuthMock.ts +0 -13
  190. package/tests/__mock__/hooks/useFormMock.ts +0 -27
  191. package/tests/__mock__/hooks/useNotificationMock.ts +0 -13
  192. package/tests/__mock__/hooks/useQueryMock.ts +0 -16
  193. package/tests/__mock__/hooks/useSocialApiMock.ts +0 -20
  194. package/tests/__mock__/hooks/useTranslationMock.ts +0 -17
  195. package/tests/__mock__/hooks/useUserApiMock.ts +0 -18
  196. package/tests/__mock__/hooks/useUserMock.ts +0 -13
  197. package/tests/__mock__/styleMock.js +0 -1
  198. package/tests/__mock__/windowMock.ts +0 -5
  199. package/tests/packages/react-query.tsx +0 -28
  200. package/tests/setupTests.ts +0 -10
@@ -11,15 +11,15 @@ import { GameDurationControl } from "./GameDurationControl";
11
11
 
12
12
  export type ZoneControlProps = {
13
13
  isLoading: boolean;
14
- workHours?: WorkHour[];
14
+ workHours: WorkHour[] | undefined;
15
15
  };
16
16
 
17
- export const ZoneControl = ({ isLoading }: ZoneControlProps) => {
17
+ export const ZoneControl = ({ isLoading, workHours }: ZoneControlProps) => {
18
18
  return (
19
19
  <Row>
20
20
  <Col md={6} sm={12} className="pr-5">
21
21
  <NameControl isLoading={isLoading} />
22
- <ZoneRecurrencesControl />
22
+ <ZoneRecurrencesControl workHours={workHours} />
23
23
  <hr />
24
24
  <Row>
25
25
  <Col md={6} sm={6}>
@@ -25,12 +25,13 @@ export interface DateAndRecurrenceInputValues {
25
25
  zoneRecurrences?: Partial<ZoneRecurrence>[];
26
26
  }
27
27
 
28
- export type ZoneRecurrenceControlProps = {
29
- workHours?: WorkHour[];
30
- isLoading?: boolean;
28
+ type ZoneRecurrenceControlProps = {
29
+ workHours: WorkHour[] | undefined;
31
30
  };
32
31
 
33
- export const ZoneRecurrencesControl = () => {
32
+ export const ZoneRecurrencesControl = ({
33
+ workHours,
34
+ }: ZoneRecurrenceControlProps) => {
34
35
  const {
35
36
  control,
36
37
  register,
@@ -69,7 +70,7 @@ export const ZoneRecurrencesControl = () => {
69
70
  clearEditState();
70
71
  });
71
72
 
72
- const popoverId = useId()!;
73
+ const popoverId = useId();
73
74
 
74
75
  const { t } = useTranslation(["Design", "Validation"]);
75
76
 
@@ -166,6 +167,7 @@ export const ZoneRecurrencesControl = () => {
166
167
  onChange={handleRecurringDateChange}
167
168
  onDelete={handleDelete}
168
169
  setInitialStartDateAfterSelect
170
+ workHours={workHours}
169
171
  />
170
172
  </Popover.Content>
171
173
  </Popover>
@@ -53,18 +53,17 @@ export const getCheckboxesByWorkHours = (workHours?: WorkHour[]) => {
53
53
  if (!workHours || !workHours.length)
54
54
  return getTimeCheckboxRanges(DEFAULT_START_DAY_TIME, DEFAULT_END_DAY_TIME);
55
55
 
56
- const providerWorkHoursByWeek = workHours.reduce(
57
- (workHoursNextArray: { start: string; end: string }[], currentWorkHour) => {
58
- const { start, end } = currentWorkHour;
56
+ const providerWorkHoursByWeek = workHours.reduce<
57
+ { start: string; end: string }[]
58
+ >((workHoursNextArray, currentWorkHour) => {
59
+ const { start, end } = currentWorkHour;
59
60
 
60
- if (start && end) {
61
- return [...workHoursNextArray, { start, end }];
62
- }
61
+ if (start && end) {
62
+ return [...workHoursNextArray, { start, end }];
63
+ }
63
64
 
64
- return workHoursNextArray;
65
- },
66
- []
67
- );
65
+ return workHoursNextArray;
66
+ }, []);
68
67
 
69
68
  // If venue has filled only 1 work day from wee
70
69
  // For another days we use default 00:00 and 23:59
package/jest.config.js DELETED
@@ -1,29 +0,0 @@
1
- // For a detailed explanation regarding each configuration property, visit:
2
- // https://jestjs.io/docs/en/configuration.html
3
-
4
- module.exports = {
5
- modulePathIgnorePatterns: ["/dist/"],
6
- roots: ["<rootDir>/src", "<rootDir>/tests"],
7
- globals: {
8
- "ts-jest": {
9
- isolatedModules: true,
10
- babelConfig: {
11
- presets: ["@babel/preset-env", "@babel/preset-react"],
12
- },
13
- },
14
- },
15
- transform: {
16
- "^.+\\.(t|j)sx?$": "ts-jest",
17
- },
18
- transformIgnorePatterns: [
19
- "node_modules/(?!(redux-persist)/)",
20
- "node_modules/(?!(@licklist)/)",
21
- ],
22
- testRegex: ["(\\/tests\\/.*.(test|spec))\\.tsx?$"],
23
- moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
24
- setupFilesAfterEnv: ["<rootDir>/tests/setupTests.ts"],
25
- moduleNameMapper: {
26
- "^.+\\.(css|scss|sass|less)$": "<rootDir>/tests/__mock__/styleMock.js",
27
- ".+\\.(svg|png|jpg)$": "identity-obj-proxy",
28
- },
29
- };
@@ -1,194 +0,0 @@
1
- import RouteService from "@licklist/plugins/dist/services/Route/RouteService";
2
- import { mount, shallow } from "enzyme";
3
- import * as React from "react";
4
- import { act } from "react-dom/test-utils";
5
- import { QueryClientProvider } from "react-query";
6
- import { Authorizer } from "../../src/auth/Authorizer";
7
- import useAuthMock from "../__mock__/hooks/useAuthMock";
8
- import useUserMock from "../__mock__/hooks/useUserMock";
9
- import useAuthApi from "../__mock__/hooks/useAuthApi";
10
- import { queryClient } from "../packages/react-query";
11
-
12
- jest.mock("react-i18next", () => ({
13
- Trans: jest.fn().mockReturnValue("test"),
14
- useTranslation: () => ({
15
- t: jest.fn((arg) => arg),
16
- }),
17
- }));
18
- jest.mock("@licklist/plugins/dist/context/user/hooks/useAuth");
19
- jest.mock("@licklist/plugins/dist/context/user/hooks/useUser");
20
- jest.mock("@licklist/plugins/dist/hooks/Api/useAuthApi");
21
-
22
- const DEFAULT_PROFILE_RESPONSE = {
23
- useProfile: () => ({
24
- isLoading: false,
25
- isFetching: false,
26
- isError: false,
27
- data: { access_token: "test" },
28
- }),
29
- };
30
-
31
- const DEFAULT_PROFILE_LOADING_RESPONSE = {
32
- useProfile: () => ({
33
- isLoading: true,
34
- isFetching: false,
35
- isError: false,
36
- data: { access_token: "test" },
37
- }),
38
- };
39
-
40
- describe("Authorizer", () => {
41
- it("should be rendered without issues", () => {
42
- useAuthMock({
43
- secrets: null,
44
- });
45
- useUserMock({
46
- profile: null,
47
- });
48
- useAuthApi(DEFAULT_PROFILE_LOADING_RESPONSE);
49
-
50
- const component = shallow(
51
- <QueryClientProvider client={queryClient}>
52
- <Authorizer />
53
- </QueryClientProvider>
54
- );
55
-
56
- expect(component.exists()).toBeTruthy();
57
- });
58
-
59
- it("should render children if authorized", () => {
60
- let component: any;
61
-
62
- useAuthMock({
63
- secrets: "not-null",
64
- });
65
- useUserMock({
66
- profile: "not-null",
67
- });
68
- useAuthApi(DEFAULT_PROFILE_LOADING_RESPONSE);
69
-
70
- RouteService.getCurrentPage = jest.fn();
71
- RouteService.getCurrentRoute = jest.fn();
72
- RouteService.cleanRedirect = jest.fn();
73
-
74
- act(() => {
75
- component = mount(
76
- <QueryClientProvider client={queryClient}>
77
- <Authorizer>
78
- <p>test</p>
79
- </Authorizer>
80
- </QueryClientProvider>
81
- );
82
- });
83
-
84
- component.update();
85
-
86
- expect(RouteService.getCurrentPage).toHaveBeenCalledTimes(0);
87
- expect(RouteService.getCurrentRoute).toHaveBeenCalledTimes(0);
88
- expect(RouteService.cleanRedirect).toHaveBeenCalledTimes(0);
89
- expect(component.exists()).toBeTruthy();
90
- expect(component.find("BlockLoader").exists()).toBeTruthy();
91
- });
92
-
93
- it("should render children if current page is login", () => {
94
- let component: any;
95
-
96
- useAuthMock({
97
- secrets: null,
98
- });
99
- useUserMock({
100
- profile: null,
101
- });
102
- useAuthApi(DEFAULT_PROFILE_LOADING_RESPONSE);
103
-
104
- RouteService.getCurrentPage = jest.fn().mockReturnValue("/login");
105
- RouteService.getCurrentRoute = jest.fn();
106
- RouteService.cleanRedirect = jest.fn();
107
-
108
- act(() => {
109
- component = mount(
110
- <QueryClientProvider client={queryClient}>
111
- <Authorizer>
112
- <p>test</p>
113
- </Authorizer>
114
- </QueryClientProvider>
115
- );
116
- });
117
-
118
- component.update();
119
-
120
- expect(RouteService.getCurrentPage).toHaveBeenCalledTimes(0);
121
- expect(RouteService.getCurrentRoute).toHaveBeenCalledTimes(0);
122
- expect(RouteService.cleanRedirect).toHaveBeenCalledTimes(0);
123
- expect(component.exists()).toBeTruthy();
124
- expect(component.find("BlockLoader").exists()).toBeTruthy();
125
- });
126
-
127
- it("should NOT render children if profile is loading or fetching", () => {
128
- let component: any;
129
-
130
- useAuthMock({
131
- secrets: null,
132
- });
133
- useUserMock({
134
- profile: null,
135
- });
136
- useAuthApi(DEFAULT_PROFILE_LOADING_RESPONSE);
137
-
138
- RouteService.getCurrentPage = jest.fn();
139
- RouteService.getCurrentRoute = jest.fn();
140
- RouteService.cleanRedirect = jest.fn();
141
-
142
- act(() => {
143
- component = mount(
144
- <QueryClientProvider client={queryClient}>
145
- <Authorizer>
146
- <p>test</p>
147
- </Authorizer>
148
- </QueryClientProvider>
149
- );
150
- });
151
-
152
- component.update();
153
-
154
- expect(RouteService.getCurrentPage).toHaveBeenCalledTimes(0);
155
- expect(RouteService.getCurrentRoute).toHaveBeenCalledTimes(0);
156
- expect(RouteService.cleanRedirect).toHaveBeenCalledTimes(0);
157
- expect(component.exists()).toBeTruthy();
158
- expect(component.find("BlockLoader").exists()).toBeTruthy();
159
- });
160
-
161
- it("should NOT render children if unauthorized and current page is not login", () => {
162
- let component: any;
163
-
164
- useAuthMock({
165
- secrets: null,
166
- });
167
- useUserMock({
168
- profile: null,
169
- });
170
- useAuthApi(DEFAULT_PROFILE_RESPONSE);
171
-
172
- RouteService.getCurrentPage = jest.fn();
173
- RouteService.getCurrentRoute = jest.fn();
174
- RouteService.cleanRedirect = jest.fn();
175
-
176
- act(() => {
177
- component = mount(
178
- <QueryClientProvider client={queryClient}>
179
- <Authorizer>
180
- <p>test</p>
181
- </Authorizer>
182
- </QueryClientProvider>
183
- );
184
- });
185
-
186
- component.update();
187
-
188
- expect(RouteService.getCurrentPage).toHaveBeenCalledTimes(3);
189
- expect(RouteService.getCurrentRoute).toHaveBeenCalledTimes(1);
190
- expect(RouteService.cleanRedirect).toHaveBeenCalledTimes(1);
191
- expect(component.exists()).toBeTruthy();
192
- expect(component.find("BlockLoader").exists()).toBeTruthy();
193
- });
194
- });
@@ -1,43 +0,0 @@
1
- import RouteService from "@licklist/plugins/dist/services/Route/RouteService";
2
- import { mount, shallow } from "enzyme";
3
- import * as React from "react";
4
- import useTranslationMock from "../../__mock__/hooks/useTranslationMock";
5
- import useUserMock from "../../__mock__/hooks/useUserMock";
6
- import { UserNavDropDown } from "../../../src/auth/Layout/UserNavDropDown";
7
-
8
- jest.mock("react-i18next");
9
- jest.mock("@licklist/plugins/dist/context/user/hooks/useUser");
10
-
11
- describe("UserNavDropDown", () => {
12
- it("should be rendered without issues", () => {
13
- useTranslationMock({
14
- t: jest.fn(),
15
- });
16
- useUserMock({
17
- profile: null,
18
- });
19
-
20
- const component = shallow(<UserNavDropDown />);
21
-
22
- expect(component.exists()).toBeTruthy();
23
- });
24
-
25
- it("should logout on click", () => {
26
- useTranslationMock({
27
- t: jest.fn(),
28
- });
29
- useUserMock({
30
- logout: jest.fn(),
31
- });
32
-
33
- RouteService.redirectTo = jest.fn();
34
-
35
- const component = mount(<UserNavDropDown />);
36
-
37
- expect(component.exists()).toBeTruthy();
38
-
39
- component.children().prop("onClick")();
40
-
41
- expect(RouteService.redirectTo).toHaveBeenCalledTimes(1);
42
- });
43
- });
@@ -1,33 +0,0 @@
1
- import { IUser } from "@licklist/plugins/dist/types/context/user/IUser";
2
- import { shallow } from "enzyme";
3
- import * as React from "react";
4
- import { UserNavDropDownToggle } from "../../../src/auth/Layout/UserNavDropDownToggle";
5
- import useTranslationMock from "../../__mock__/hooks/useTranslationMock";
6
-
7
- jest.mock("react-i18next");
8
- jest.mock("@licklist/plugins/dist/context/user/hooks/useUser");
9
-
10
- const user: IUser = {
11
- id: 1,
12
- first_name: "first_name",
13
- last_name: "last_name",
14
- email: "email",
15
- user_roles: [],
16
- user_detail: {
17
- postcode: "",
18
- birthday: "",
19
- phone: "",
20
- },
21
- };
22
-
23
- describe("UserNavDropDownToggle", () => {
24
- it("should be rendered without issues", () => {
25
- useTranslationMock({
26
- t: jest.fn(),
27
- });
28
-
29
- const component = shallow(<UserNavDropDownToggle user={user} />);
30
-
31
- expect(component.exists()).toBeTruthy();
32
- });
33
- });
@@ -1,246 +0,0 @@
1
- import RouteService from "@licklist/plugins/dist/services/Route/RouteService";
2
- import { UserLoginRequest } from "@licklist/plugins/dist/types/Request/UserLoginRequest";
3
- import { mount, shallow } from "enzyme";
4
- import * as React from "react";
5
- import { act } from "react-dom/test-utils";
6
- import { MemoryRouter } from "react-router-dom";
7
- import { LoginComponent, LoginFormComponent } from "../../../src/auth/Login";
8
- import useAuthMock from "../../__mock__/hooks/useAuthMock";
9
- import useFormMock from "../../__mock__/hooks/useFormMock";
10
- import useNotificationMock from "../../__mock__/hooks/useNotificationMock";
11
- import useTranslationMock from "../../__mock__/hooks/useTranslationMock";
12
- import useUserApiMock from "../../__mock__/hooks/useUserApiMock";
13
- import useUserMock from "../../__mock__/hooks/useUserMock";
14
-
15
- jest.mock("react-i18next", () => ({
16
- Trans: jest.fn().mockReturnValue("test"),
17
- useTranslation: jest.fn(),
18
- }));
19
- jest.mock("react-hook-form");
20
- jest.mock("@licklist/plugins/dist/context/app/hooks/useNotification");
21
- jest.mock("@licklist/plugins/dist/context/user/hooks/useAuth");
22
- jest.mock("@licklist/plugins/dist/context/user/hooks/useUser");
23
- jest.mock("@licklist/plugins/dist/hooks/Api/useUserApi");
24
-
25
- beforeEach(() => {
26
- useTranslationMock();
27
- useNotificationMock({
28
- danger: jest.fn(),
29
- success: jest.fn(),
30
- });
31
- useAuthMock({
32
- setSecrets: jest.fn(),
33
- });
34
- useUserMock({
35
- login: jest.fn(),
36
- clearInvitation: jest.fn(),
37
- });
38
- useFormMock();
39
- });
40
-
41
- afterAll(() => {
42
- jest.resetAllMocks();
43
- });
44
-
45
- describe("LoginComponent", () => {
46
- it("should be rendered without issues", () => {
47
- const component = shallow(
48
- <MemoryRouter initialEntries={["/"]}>
49
- <LoginComponent />
50
- </MemoryRouter>
51
- );
52
-
53
- expect(component.exists()).toBeTruthy();
54
- });
55
-
56
- it("should show danger notification if login did not succeed", async () => {
57
- let component: any;
58
-
59
- const notificationDangerMock = jest.fn();
60
- const notificationSuccessMock = jest.fn();
61
- const loginMock = jest.fn(() => Promise.reject(new Error("danger")));
62
- const profileMock = jest.fn();
63
-
64
- useNotificationMock({
65
- danger: notificationDangerMock,
66
- success: notificationSuccessMock,
67
- });
68
- useUserApiMock({
69
- login: loginMock,
70
- profile: profileMock,
71
- });
72
-
73
- RouteService.redirectTo = jest.fn();
74
-
75
- act(() => {
76
- component = mount(
77
- <MemoryRouter>
78
- <LoginComponent />
79
- </MemoryRouter>
80
- );
81
- });
82
-
83
- await act(async () => {
84
- const credentials: UserLoginRequest = {
85
- email: "email",
86
- password: "password",
87
- };
88
-
89
- await component.find(LoginFormComponent).prop("onSubmit")(credentials);
90
- });
91
-
92
- component.update();
93
-
94
- expect(component.exists()).toBeTruthy();
95
- expect(loginMock).toHaveBeenCalledTimes(1);
96
- expect(notificationDangerMock).toHaveBeenCalledTimes(1);
97
- expect(profileMock).toHaveBeenCalledTimes(0);
98
- expect(notificationSuccessMock).toHaveBeenCalledTimes(0);
99
- });
100
-
101
- it("should show danger notification if profile did not succeed", async () => {
102
- let component: any;
103
-
104
- const loginResponse = {
105
- access_token: "access_token",
106
- refresh_token: "refresh_token",
107
- token_type: "token_type",
108
- expires_in: null,
109
- };
110
-
111
- const notificationDangerMock = jest.fn();
112
- const notificationSuccessMock = jest.fn();
113
- const loginMock = jest.fn(() => Promise.resolve(loginResponse));
114
- const profileMock = jest.fn(() => Promise.reject(new Error("danger")));
115
- const setAuthorizationTokenMock = jest.fn();
116
- const setSecretsMock = jest.fn();
117
-
118
- useNotificationMock({
119
- danger: notificationDangerMock,
120
- success: notificationSuccessMock,
121
- });
122
- useUserApiMock({
123
- login: loginMock,
124
- profile: profileMock,
125
- setAuthorizationToken: setAuthorizationTokenMock,
126
- });
127
- useAuthMock({
128
- setSecrets: setSecretsMock,
129
- });
130
-
131
- RouteService.redirectTo = jest.fn();
132
-
133
- act(() => {
134
- component = mount(
135
- <MemoryRouter>
136
- <LoginComponent />
137
- </MemoryRouter>
138
- );
139
- });
140
-
141
- await act(async () => {
142
- const credentials: UserLoginRequest = {
143
- email: "email",
144
- password: "password",
145
- };
146
-
147
- await component.find(LoginFormComponent).prop("onSubmit")(credentials);
148
- });
149
-
150
- component.update();
151
-
152
- expect(component.exists()).toBeTruthy();
153
- expect(loginMock).toHaveBeenCalledTimes(1);
154
- expect(setSecretsMock).toHaveBeenCalledTimes(1);
155
- expect(setSecretsMock).toHaveBeenCalledWith(loginResponse);
156
- expect(setAuthorizationTokenMock).toHaveBeenCalledTimes(1);
157
- expect(setAuthorizationTokenMock).toHaveBeenCalledWith(
158
- loginResponse.access_token
159
- );
160
- expect(profileMock).toHaveBeenCalledTimes(1);
161
- expect(notificationDangerMock).toHaveBeenCalledTimes(1);
162
- expect(notificationSuccessMock).toHaveBeenCalledTimes(0);
163
- });
164
-
165
- it("should show success notification if login and profile did succeed", async () => {
166
- let component: any;
167
-
168
- const loginResponse = {
169
- access_token: "access_token",
170
- refresh_token: "refresh_token",
171
- token_type: "token_type",
172
- expires_in: null,
173
- };
174
- const profileResponse = {
175
- id: 1,
176
- first_name: "first_name",
177
- last_name: "last_name",
178
- email: "email",
179
- role: null,
180
- };
181
-
182
- const notificationDangerMock = jest.fn();
183
- const notificationSuccessMock = jest.fn();
184
- const loginMock = jest.fn(() => Promise.resolve(loginResponse));
185
- const profileMock = jest.fn(() =>
186
- Promise.resolve({
187
- data: profileResponse,
188
- })
189
- );
190
- const setAuthorizationTokenMock = jest.fn();
191
- const setSecretsMock = jest.fn();
192
- const userLoginMock = jest.fn();
193
-
194
- useNotificationMock({
195
- danger: notificationDangerMock,
196
- success: notificationSuccessMock,
197
- });
198
- useUserApiMock({
199
- login: loginMock,
200
- profile: profileMock,
201
- setAuthorizationToken: setAuthorizationTokenMock,
202
- });
203
- useAuthMock({
204
- setSecrets: setSecretsMock,
205
- });
206
- useUserMock({
207
- login: userLoginMock,
208
- });
209
-
210
- RouteService.redirectTo = jest.fn();
211
-
212
- act(() => {
213
- component = mount(
214
- <MemoryRouter>
215
- <LoginComponent />
216
- </MemoryRouter>
217
- );
218
- });
219
-
220
- await act(async () => {
221
- const credentials: UserLoginRequest = {
222
- email: "email",
223
- password: "password",
224
- };
225
-
226
- await component.find(LoginFormComponent).prop("onSubmit")(credentials);
227
- });
228
-
229
- component.update();
230
-
231
- expect(component.exists()).toBeTruthy();
232
- expect(loginMock).toHaveBeenCalledTimes(1);
233
- expect(setSecretsMock).toHaveBeenCalledTimes(1);
234
- expect(setSecretsMock).toHaveBeenCalledWith(loginResponse);
235
- expect(setAuthorizationTokenMock).toHaveBeenCalledTimes(1);
236
- expect(setAuthorizationTokenMock).toHaveBeenCalledWith(
237
- loginResponse.access_token
238
- );
239
- expect(profileMock).toHaveBeenCalledTimes(1);
240
- expect(userLoginMock).toHaveBeenCalledTimes(1);
241
- expect(userLoginMock).toHaveBeenCalledWith(profileResponse);
242
- expect(notificationDangerMock).toHaveBeenCalledTimes(0);
243
- expect(notificationSuccessMock).toHaveBeenCalledTimes(1);
244
- expect(RouteService.redirectTo).toHaveBeenCalledTimes(1);
245
- });
246
- });