@webitel/ui-sdk 24.10.3 → 24.10.4
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/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.js +111 -114
- package/dist/ui-sdk.umd.cjs +8 -8
- package/package.json +6 -4
- package/src/api/axios/generateInstance.js +1 -4
- package/src/api/clients/agents/agents.js +31 -78
- package/src/api/clients/buckets/buckets.js +17 -57
- package/src/api/clients/calendars/calendars.js +18 -71
- package/src/api/clients/chatGateways/chatGateways.js +23 -61
- package/src/api/clients/chatGateways/defaults/webChatGateway.js +6 -8
- package/src/api/clients/chatGateways/enums/WebchatAlternativeChannel.enum.js +3 -3
- package/src/api/clients/communications/communications.js +20 -62
- package/src/api/clients/configurations/configurations.js +18 -3
- package/src/api/clients/flows/flow.js +17 -60
- package/src/api/clients/gateways/gateways.js +20 -59
- package/src/api/clients/index.js +1 -1
- package/src/api/clients/lists/blacklists.js +18 -60
- package/src/api/clients/media/media.js +13 -43
- package/src/api/clients/queues/defaults/processing.js +10 -6
- package/src/api/clients/queues/queues.js +21 -69
- package/src/api/clients/roles/roles.js +15 -33
- package/src/api/clients/users/__tests__/users.spec.js +43 -26
- package/src/api/clients/users/users.js +21 -56
- package/src/api/crm/contactChatMessagesHistory.js +8 -23
- package/src/api/crm/index.js +1 -3
- package/src/api/defaults/getDefaultGetParams/getDefaultGetParams.js +1 -4
- package/src/api/defaults/getDefaultInstance/getDefaultInstance.js +10 -11
- package/src/api/defaults/getDefaultOpenAPIConfig/getDefaultOpenAPIConfig.js +6 -5
- package/src/api/defaults/index.js +2 -4
- package/src/api/history/index.js +1 -3
- package/src/api/history/transcript/callTranscript.js +10 -30
- package/src/api/interceptors/request/updateToken.interceptor.js +1 -2
- package/src/api/transformers/merge/merge.transformer.js +4 -1
- package/src/api/transformers/mergeEach/mergeEach.transformer.js +4 -4
- package/src/api/transformers/notify/notify.transformer.js +9 -6
- package/src/api/transformers/starToSearch/starToSearch.transformer.js +8 -6
- package/src/components/index.js +3 -6
- package/src/components/on-demand/wt-cc-agent-status-timers/__tests__/wt-cc-agent-status-timers.spec.js +2 -4
- package/src/components/transitions/wt-expand-transition.vue +2 -3
- package/src/components/wt-app-header/__tests__/WtAppNavigator.spec.js +1 -2
- package/src/components/wt-app-header/__tests__/WtHeaderActions.spec.js +1 -2
- package/src/components/wt-app-header/wt-app-navigator.vue +15 -9
- package/src/components/wt-avatar/wt-avatar.vue +8 -3
- package/src/components/wt-button/wt-button.vue +0 -1
- package/src/components/wt-button-select/__tests__/WtButtonSelect.spec.js +4 -5
- package/src/components/wt-button-select/wt-button-select.vue +0 -1
- package/src/components/wt-context-menu/wt-context-menu.vue +32 -35
- package/src/components/wt-dummy/wt-dummy.vue +2 -5
- package/src/components/wt-expansion-panel/wt-expansion-panel.vue +10 -7
- package/src/components/wt-filters-panel-wrapper/__tests__/WtFiltersPanelWrapper.spec.js +4 -8
- package/src/components/wt-icon/wt-icon.vue +0 -1
- package/src/components/wt-indicator/__tests__/WtIndicator.spec.js +3 -2
- package/src/components/wt-indicator/wt-indicator.vue +10 -1
- package/src/components/wt-input/wt-input.vue +7 -10
- package/src/components/wt-item-link/wt-item-link.vue +7 -4
- package/src/components/wt-navigation-bar/__tests__/WtNavigationBar.spec.js +7 -15
- package/src/components/wt-navigation-bar/wt-navigation-bar.vue +7 -7
- package/src/components/wt-notification/wt-notification.vue +1 -2
- package/src/components/wt-notifications-bar/__tests__/WtNotificationsBar.spec.js +6 -3
- package/src/components/wt-notifications-bar/wt-notifications-bar.vue +4 -1
- package/src/components/wt-page-wrapper/__tests__/WtPageWrapper.spec.js +1 -2
- package/src/components/wt-pagination/wt-pagination.vue +1 -3
- package/src/components/wt-player/scripts/__tests__/createPlyrURL.spec.js +4 -8
- package/src/components/wt-player/wt-player.vue +13 -4
- package/src/components/wt-popup/wt-popup.vue +2 -1
- package/src/components/wt-search-bar/wt-search-bar.vue +1 -1
- package/src/components/wt-select/mixins/multiselectMixin.js +2 -5
- package/src/components/wt-select/wt-select.vue +12 -11
- package/src/components/wt-slider/wt-slider.vue +4 -2
- package/src/components/wt-status-select/wt-status-select.vue +10 -6
- package/src/components/wt-stepper/wt-stepper.vue +6 -4
- package/src/components/wt-switcher/wt-switcher.vue +1 -3
- package/src/components/wt-table/__tests__/WtTable.spec.js +2 -5
- package/src/components/wt-table/wt-table.vue +18 -16
- package/src/components/wt-table-column-select/wt-table-column-select.vue +9 -8
- package/src/components/wt-tabs/wt-tabs.vue +1 -3
- package/src/components/wt-tags-input/mixin/taggableMixin.js +7 -7
- package/src/components/wt-textarea/__tests__/WtTextarea.spec.js +2 -4
- package/src/components/wt-textarea/wt-textarea.vue +3 -2
- package/src/components/wt-timepicker/wt-timepicker.vue +1 -3
- package/src/components/wt-tooltip/_internals/useTooltipTriggerSubscriptions.js +1 -3
- package/src/components/wt-tooltip/_internals/wt-tooltip-floating.vue +8 -12
- package/src/components/wt-tooltip/wt-tooltip.vue +13 -13
- package/src/composables/useCachedInterval/__tests__/useCachedInterval.spec.js +6 -4
- package/src/composables/useCachedInterval/useCachedInterval.js +3 -8
- package/src/composables/useRepresentableAgentPauseCause/__tests__/useRepresentableAgentPauseCause.spec.js +11 -33
- package/src/composables/useRepresentableAgentPauseCause/useRepresentableAgentPauseCause.js +11 -9
- package/src/enums/WebitelApplications/AdminSections.enum.js +28 -28
- package/src/enums/WebitelApplications/CrmSections.enum.js +1 -1
- package/src/locale/en/en.js +12 -15
- package/src/locale/es/es.js +4 -8
- package/src/locale/kz/kz.js +5 -7
- package/src/locale/ru/ru.js +7 -11
- package/src/locale/ua/ua.js +13 -17
- package/src/mixins/dataFilterMixins/__tests__/enumFilterMixin.spec.js +1 -2
- package/src/mixins/dataFilterMixins/__tests__/sortFilterMixin.spec.js +4 -2
- package/src/mixins/dataFilterMixins/__tests__/urlControllerMixin.spec.js +4 -1
- package/src/mixins/dataFilterMixins/_urlControllerMixin/_urlControllerMixin.js +1 -1
- package/src/mixins/dataFilterMixins/apiFilterMixin.js +1 -2
- package/src/mixins/dataFilterMixins/baseFilterMixin/baseFilterMixin.js +1 -2
- package/src/mixins/dataFilterMixins/enumFilterMixin.js +5 -6
- package/src/mixins/dataFilterMixins/paginationFilterMixin.js +1 -2
- package/src/mixins/dataFilterMixins/sortFilterMixin.js +1 -4
- package/src/mixins/validationMixin/__tests__/validationMixin.spec.js +1 -2
- package/src/mixins/validationMixin/useValidation.js +25 -19
- package/src/mixins/validationMixin/validationMixin.js +22 -10
- package/src/modules/AgentStatusSelect/api/pause-cause.js +3 -11
- package/src/modules/AgentStatusSelect/components/__tests__/wt-cc-agent-status-select.spec.js +16 -18
- package/src/modules/AgentStatusSelect/components/__tests__/wt-cc-pause-cause-popup.spec.js +1 -2
- package/src/modules/AgentStatusSelect/components/_internals/wt-cc-pause-cause-popup.vue +12 -12
- package/src/modules/AgentStatusSelect/components/_internals/wt-cc-status-select-error-popup.vue +0 -1
- package/src/modules/AgentStatusSelect/components/wt-cc-agent-status-select.vue +20 -7
- package/src/modules/Appearance/components/__tests__/wt-dark-mode-switcher.spec.js +2 -4
- package/src/modules/Appearance/components/wt-dark-mode-switcher.vue +0 -1
- package/src/modules/AuditForm/components/__tests__/audit-form-question-read-wrapper.spec.js +1 -2
- package/src/modules/AuditForm/components/__tests__/audit-form-question-write-wrapper.spec.js +15 -25
- package/src/modules/AuditForm/components/__tests__/audit-form.spec.js +11 -20
- package/src/modules/AuditForm/components/audit-form-question-read-wrapper.vue +1 -4
- package/src/modules/AuditForm/components/audit-form-question-write-wrapper.vue +4 -7
- package/src/modules/AuditForm/components/audit-form-question.vue +18 -17
- package/src/modules/AuditForm/components/audit-form.vue +12 -14
- package/src/modules/AuditForm/components/questions/options/__tests__/audit-form-question-options-write-row.spec.js +1 -2
- package/src/modules/AuditForm/components/questions/options/__tests__/audit-form-question-options.spec.js +1 -3
- package/src/modules/AuditForm/components/questions/options/audit-form-question-options-write-row.vue +11 -15
- package/src/modules/AuditForm/components/questions/options/audit-form-question-options.vue +1 -4
- package/src/modules/AuditForm/components/questions/score/audit-form-question-score.vue +16 -20
- package/src/modules/AuditForm/schemas/AuditFormQuestionOptionsSchema.js +1 -3
- package/src/modules/CSVExport/CSVExport.js +3 -7
- package/src/modules/CSVExport/XLSExport.js +6 -7
- package/src/modules/CSVExport/__tests__/CSVExport.spec.js +1 -2
- package/src/modules/CSVExport/mixins/exportCSVMixin.js +2 -5
- package/src/modules/CSVExport/mixins/exportXLSMixin.js +2 -4
- package/src/modules/CardStoreModule/store/CardStoreModule.js +2 -6
- package/src/modules/DeleteConfirmationPopup/__tests__/delete-confirmation-popup.spec.js +13 -10
- package/src/modules/DeleteConfirmationPopup/components/delete-confirmation-popup.vue +5 -14
- package/src/modules/FilesExport/FilesExport.js +4 -3
- package/src/modules/FilesExport/__tests__/FilesExport.spec.js +12 -12
- package/src/modules/FilesExport/mixins/exportFilesMixin.js +6 -7
- package/src/modules/FilesExport/scripts/generateMediaURL.js +1 -2
- package/src/modules/Filters/classes/BaseFilterSchema.js +21 -25
- package/src/modules/Filters/components/filter-pagination.vue +7 -3
- package/src/modules/Filters/components/filter-search.vue +21 -12
- package/src/modules/Filters/components/filter-table-fields.vue +1 -3
- package/src/modules/Filters/scripts/getters/index.js +1 -5
- package/src/modules/Filters/scripts/getters/queryGetter.js +2 -3
- package/src/modules/Filters/scripts/restores/index.js +1 -4
- package/src/modules/Filters/scripts/setters/index.js +1 -5
- package/src/modules/Filters/scripts/setters/querySetter.js +24 -22
- package/src/modules/Filters/scripts/utils/changeRouteQuery.js +16 -15
- package/src/modules/Filters/store/FiltersStoreModule.js +51 -45
- package/src/modules/Filters/store/__tests__/FiltersStoreModule.spec.js +51 -45
- package/src/modules/Notifications/store/NotificationsStoreModule.js +41 -38
- package/src/modules/Notifications/store/__tests__/NotificationsStoreModule.actions.spec.js +6 -6
- package/src/modules/QueryFilters/api/defaults.js +2 -3
- package/src/modules/QueryFilters/classes/ApiFilterSchema.js +1 -4
- package/src/modules/QueryFilters/classes/EnumFilterSchema.js +1 -4
- package/src/modules/QueryFilters/components/__tests__/filter-datetime.spec.js +1 -2
- package/src/modules/QueryFilters/components/__tests__/filter-from-to.spec.js +2 -4
- package/src/modules/QueryFilters/components/__tests__/filter-search.spec.js +2 -4
- package/src/modules/QueryFilters/components/filter-table-fields.vue +1 -5
- package/src/modules/QueryFilters/mixins/__tests__/apiFilterMixin.spec.js +4 -3
- package/src/modules/QueryFilters/mixins/__tests__/enumFilterMixin.spec.js +2 -4
- package/src/modules/QueryFilters/mixins/__tests__/sortFilterMixin.spec.js +4 -2
- package/src/modules/QueryFilters/mixins/__tests__/urlControllerMixin.spec.js +4 -1
- package/src/modules/QueryFilters/mixins/_urlControllerMixin/_urlControllerMixin.js +1 -1
- package/src/modules/QueryFilters/mixins/apiFilterMixin.js +1 -1
- package/src/modules/QueryFilters/mixins/baseFilterMixin/baseFilterMixin.js +4 -2
- package/src/modules/QueryFilters/mixins/enumFilterMixin.js +9 -11
- package/src/modules/QueryFilters/mixins/paginationFilterMixin.js +2 -4
- package/src/modules/QueryFilters/mixins/sortFilterMixin.js +2 -5
- package/src/modules/QueryFilters/store/QueryFiltersStoreModule.js +13 -17
- package/src/modules/QueryFilters/store/__tests__/QueryFiltersStoreModule.spec.js +15 -16
- package/src/modules/TableStoreModule/store/TableStoreModule.js +14 -33
- package/src/modules/TableStoreModule/store/__tests__/TableStoreModule.spec.js +69 -83
- package/src/modules/Userinfo/api/userinfo.js +6 -19
- package/src/modules/Userinfo/classes/ApplicationsAccess.js +5 -12
- package/src/modules/Userinfo/store/UserinfoStoreModule.js +38 -41
- package/src/plugins/breakpoint/breakpoint.plugin.js +11 -16
- package/src/scripts/__tests__/caseConverters.spec.js +1 -4
- package/src/scripts/__tests__/debounce.spec.js +3 -1
- package/src/scripts/__tests__/prettifyFileSize.spec.js +2 -2
- package/src/scripts/__tests__/preventHiddenPageCallsDecorator.spec.js +7 -4
- package/src/scripts/__tests__/updateObject.spec.js +3 -5
- package/src/scripts/caseConverters.js +22 -38
- package/src/scripts/debounce.js +1 -5
- package/src/scripts/editProxy.js +8 -7
- package/src/scripts/prettifyFileSize.js +1 -1
- package/src/scripts/preventHiddenPageCallsDecorator.js +3 -6
- package/src/store/BaseStoreModules/ApiStoreModule.js +7 -33
- package/src/store/BaseStoreModules/BaseStoreModule.js +14 -23
- package/src/store/BaseStoreModules/__tests__/BaseStoreModule.spec.js +7 -28
- package/src/store/helpers/getNamespacedState.js +2 -4
- package/src/store/new/modules/apiStoreModule/apiStoreModule.js +7 -27
- package/src/store/new/modules/cardStoreModule/cardStoreModule.js +0 -1
- package/src/store/new/modules/tableStoreModule/__tests__/tableStoreModule.spec.js +64 -77
- package/src/store/new/modules/tableStoreModule/tableStoreModule.js +12 -29
- package/src/tests/mocks/axiosMock.js +25 -19
- package/src/validators/decimalValidator.js +5 -4
- package/src/validators/websocketValidator/__tests__/websocketValidator.spec.js +1 -2
- package/src/validators/websocketValidator/websocketValidator.js +1 -1
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
sortToQueryAdapter,
|
|
4
|
-
} from '../../../scripts/sortQueryAdapters.js';
|
|
5
|
-
import BaseStoreModule
|
|
6
|
-
from '../../../store/BaseStoreModules/BaseStoreModule.js';
|
|
1
|
+
import { queryToSortAdapter, sortToQueryAdapter } from '../../../scripts/sortQueryAdapters.js';
|
|
2
|
+
import BaseStoreModule from '../../../store/BaseStoreModules/BaseStoreModule.js';
|
|
7
3
|
import FilterEvent from '../../Filters/enums/FilterEvent.enum.js';
|
|
8
4
|
|
|
9
5
|
export default class TableStoreModule extends BaseStoreModule {
|
|
@@ -48,10 +44,7 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
48
44
|
|
|
49
45
|
actions = {
|
|
50
46
|
// FIXME: maybe move to filters module?
|
|
51
|
-
SET_FILTER: (
|
|
52
|
-
context,
|
|
53
|
-
payload,
|
|
54
|
-
) => context.dispatch('filters/SET_FILTER', payload),
|
|
47
|
+
SET_FILTER: (context, payload) => context.dispatch('filters/SET_FILTER', payload),
|
|
55
48
|
|
|
56
49
|
// FIXME: maybe move to filters module?
|
|
57
50
|
ON_FILTER_EVENT: async (context, { event, payload }) => {
|
|
@@ -66,10 +59,7 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
66
59
|
},
|
|
67
60
|
|
|
68
61
|
// FIXME: maybe move to filters module?
|
|
69
|
-
HANDLE_FILTERS_RESTORE: async (context, {
|
|
70
|
-
fields,
|
|
71
|
-
sort,
|
|
72
|
-
}) => {
|
|
62
|
+
HANDLE_FILTERS_RESTORE: async (context, { fields, sort }) => {
|
|
73
63
|
if (sort) await context.dispatch('HANDLE_SORT_CHANGE', { value: sort });
|
|
74
64
|
if (fields?.length) await context.dispatch('HANDLE_FIELDS_CHANGE', { value: fields });
|
|
75
65
|
return context.dispatch('LOAD_DATA_LIST');
|
|
@@ -109,10 +99,7 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
109
99
|
const nextSort = queryToSortAdapter(value?.slice(0, 1) || '');
|
|
110
100
|
const field = nextSort ? value.slice(1) : value;
|
|
111
101
|
|
|
112
|
-
const headers = context.state.headers.map(({
|
|
113
|
-
sort: currentSort,
|
|
114
|
-
...header
|
|
115
|
-
}) => {
|
|
102
|
+
const headers = context.state.headers.map(({ sort: currentSort, ...header }) => {
|
|
116
103
|
let sort;
|
|
117
104
|
|
|
118
105
|
if (field) {
|
|
@@ -133,10 +120,10 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
133
120
|
|
|
134
121
|
const params = context.getters.GET_LIST_PARAMS(query);
|
|
135
122
|
try {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
123
|
+
const { items = [], next = false } = await context.dispatch('api/GET_LIST', {
|
|
124
|
+
context,
|
|
125
|
+
params,
|
|
126
|
+
});
|
|
140
127
|
|
|
141
128
|
context.commit('SET', { path: 'dataList', value: items });
|
|
142
129
|
context.commit('SET', { path: 'isNextPage', value: next });
|
|
@@ -159,9 +146,7 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
159
146
|
});
|
|
160
147
|
},
|
|
161
148
|
|
|
162
|
-
PATCH_ITEM_PROPERTY: async (context, {
|
|
163
|
-
item: _item, index, prop, value,
|
|
164
|
-
}) => {
|
|
149
|
+
PATCH_ITEM_PROPERTY: async (context, { item: _item, index, prop, value }) => {
|
|
165
150
|
const item = _item || context.state.dataList[index];
|
|
166
151
|
|
|
167
152
|
const { id, etag } = item;
|
|
@@ -200,8 +185,7 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
200
185
|
await context.dispatch('LOAD_DATA_LIST');
|
|
201
186
|
|
|
202
187
|
/* if no items on current page after DELETE, move to prev page [WTEL-3793] */
|
|
203
|
-
if (!context.state.dataList.length && context.getters.FILTERS.page >
|
|
204
|
-
1) {
|
|
188
|
+
if (!context.state.dataList.length && context.getters.FILTERS.page > 1) {
|
|
205
189
|
await context.dispatch('SET_FILTER', {
|
|
206
190
|
name: 'page',
|
|
207
191
|
value: context.getters.FILTERS.page - 1,
|
|
@@ -218,18 +202,15 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
218
202
|
}
|
|
219
203
|
},
|
|
220
204
|
|
|
221
|
-
DELETE_BULK: async (
|
|
222
|
-
context,
|
|
223
|
-
deleted,
|
|
224
|
-
) => Promise.allSettled(deleted.map((item) => context.dispatch('DELETE_SINGLE', item))),
|
|
205
|
+
DELETE_BULK: async (context, deleted) =>
|
|
206
|
+
Promise.allSettled(deleted.map((item) => context.dispatch('DELETE_SINGLE', item))),
|
|
225
207
|
|
|
226
208
|
SET_SELECTED: (context, selected) => {
|
|
227
209
|
context.commit('SET', { path: 'selected', value: selected });
|
|
228
210
|
},
|
|
229
211
|
};
|
|
230
212
|
|
|
231
|
-
mutations = {
|
|
232
|
-
};
|
|
213
|
+
mutations = {};
|
|
233
214
|
|
|
234
215
|
constructor({ headers = [] }) {
|
|
235
216
|
super();
|
|
@@ -15,8 +15,7 @@ describe('TableStoreModule', () => {
|
|
|
15
15
|
|
|
16
16
|
const state = { headers };
|
|
17
17
|
|
|
18
|
-
expect(new TableStoreModule({}).getters.FIELDS(state))
|
|
19
|
-
.toEqual(['id', 'age']);
|
|
18
|
+
expect(new TableStoreModule({}).getters.FIELDS(state)).toEqual(['id', 'age']);
|
|
20
19
|
});
|
|
21
20
|
});
|
|
22
21
|
|
|
@@ -28,24 +27,22 @@ describe('TableStoreModule integration with FiltersStoreModule', () => {
|
|
|
28
27
|
|
|
29
28
|
it('filters restore event triggers LOAD_DATA_LIST', async () => {
|
|
30
29
|
const filters = new FiltersStoreModule()
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const table = new TableStoreModule({})
|
|
42
|
-
.getModule({
|
|
30
|
+
.addFilter({
|
|
31
|
+
name: 'vi',
|
|
32
|
+
value: 23,
|
|
33
|
+
defaultValue: 23,
|
|
34
|
+
get: ['value'],
|
|
35
|
+
set: ['value'],
|
|
36
|
+
restore: () => 'vivi',
|
|
37
|
+
})
|
|
38
|
+
.getModule();
|
|
39
|
+
|
|
40
|
+
const table = new TableStoreModule({}).getModule({
|
|
43
41
|
modules: { filters },
|
|
44
42
|
});
|
|
45
43
|
|
|
46
44
|
const mock = vi.fn();
|
|
47
|
-
vi.spyOn(table.actions, 'LOAD_DATA_LIST')
|
|
48
|
-
.mockImplementationOnce(mock);
|
|
45
|
+
vi.spyOn(table.actions, 'LOAD_DATA_LIST').mockImplementationOnce(mock);
|
|
49
46
|
|
|
50
47
|
const store = createStore({
|
|
51
48
|
state: { router },
|
|
@@ -66,24 +63,22 @@ describe('TableStoreModule integration with FiltersStoreModule', () => {
|
|
|
66
63
|
|
|
67
64
|
it('FILTER_SET event triggers LOAD_DATA_LIST', async () => {
|
|
68
65
|
const filters = new FiltersStoreModule()
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const table = new TableStoreModule({})
|
|
80
|
-
.getModule({
|
|
66
|
+
.addFilter({
|
|
67
|
+
name: 'vi',
|
|
68
|
+
value: 23,
|
|
69
|
+
defaultValue: 23,
|
|
70
|
+
get: ['value'],
|
|
71
|
+
set: ['value'],
|
|
72
|
+
restore: () => {},
|
|
73
|
+
})
|
|
74
|
+
.getModule();
|
|
75
|
+
|
|
76
|
+
const table = new TableStoreModule({}).getModule({
|
|
81
77
|
modules: { filters },
|
|
82
78
|
});
|
|
83
79
|
|
|
84
80
|
const mock = vi.fn();
|
|
85
|
-
vi.spyOn(table.actions, 'LOAD_DATA_LIST')
|
|
86
|
-
.mockImplementationOnce(mock);
|
|
81
|
+
vi.spyOn(table.actions, 'LOAD_DATA_LIST').mockImplementationOnce(mock);
|
|
87
82
|
|
|
88
83
|
const store = createStore({
|
|
89
84
|
state: { router },
|
|
@@ -109,33 +104,31 @@ describe('TableStoreModule integration with FiltersStoreModule', () => {
|
|
|
109
104
|
|
|
110
105
|
it('FILTER_SET with not-page filter name resets page filter', async () => {
|
|
111
106
|
const filters = new FiltersStoreModule()
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const table = new TableStoreModule({})
|
|
133
|
-
.getModule({
|
|
107
|
+
.addFilter([
|
|
108
|
+
{
|
|
109
|
+
name: 'vi',
|
|
110
|
+
value: 23,
|
|
111
|
+
defaultValue: 23,
|
|
112
|
+
get: ['value'],
|
|
113
|
+
set: ['value'],
|
|
114
|
+
restore: () => {},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'page',
|
|
118
|
+
value: 12,
|
|
119
|
+
defaultValue: 12,
|
|
120
|
+
get: ['value'],
|
|
121
|
+
set: ['value'],
|
|
122
|
+
restore: () => {},
|
|
123
|
+
},
|
|
124
|
+
])
|
|
125
|
+
.getModule();
|
|
126
|
+
|
|
127
|
+
const table = new TableStoreModule({}).getModule({
|
|
134
128
|
modules: { filters },
|
|
135
129
|
});
|
|
136
130
|
|
|
137
|
-
vi.spyOn(table.actions, 'LOAD_DATA_LIST')
|
|
138
|
-
.mockImplementationOnce(vi.fn());
|
|
131
|
+
vi.spyOn(table.actions, 'LOAD_DATA_LIST').mockImplementationOnce(vi.fn());
|
|
139
132
|
|
|
140
133
|
const store = createStore({
|
|
141
134
|
state: { router },
|
|
@@ -161,26 +154,22 @@ describe('TableStoreModule integration with FiltersStoreModule', () => {
|
|
|
161
154
|
|
|
162
155
|
it('SORT changes both headers and sort filter', async () => {
|
|
163
156
|
const filters = new FiltersStoreModule()
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
157
|
+
.addFilter({
|
|
158
|
+
name: 'sort',
|
|
159
|
+
value: '',
|
|
160
|
+
get: ['value'],
|
|
161
|
+
set: ['value'],
|
|
162
|
+
restore: () => {},
|
|
163
|
+
})
|
|
164
|
+
.getModule();
|
|
172
165
|
|
|
173
|
-
const headers = [
|
|
174
|
-
{ value: 'id', field: 'sort_me', sort: SortSymbols.NONE },
|
|
175
|
-
];
|
|
166
|
+
const headers = [{ value: 'id', field: 'sort_me', sort: SortSymbols.NONE }];
|
|
176
167
|
|
|
177
|
-
const table = new TableStoreModule({ headers })
|
|
178
|
-
.getModule({
|
|
168
|
+
const table = new TableStoreModule({ headers }).getModule({
|
|
179
169
|
modules: { filters },
|
|
180
170
|
});
|
|
181
171
|
|
|
182
|
-
vi.spyOn(table.actions, 'LOAD_DATA_LIST')
|
|
183
|
-
.mockImplementationOnce(vi.fn());
|
|
172
|
+
vi.spyOn(table.actions, 'LOAD_DATA_LIST').mockImplementationOnce(vi.fn());
|
|
184
173
|
|
|
185
174
|
const store = createStore({
|
|
186
175
|
state: { router },
|
|
@@ -206,27 +195,25 @@ describe('TableStoreModule integration with FiltersStoreModule', () => {
|
|
|
206
195
|
|
|
207
196
|
it('fields filter change changes headers', async () => {
|
|
208
197
|
const filters = new FiltersStoreModule()
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
198
|
+
.addFilter({
|
|
199
|
+
name: 'fields',
|
|
200
|
+
value: [],
|
|
201
|
+
get: ['value'],
|
|
202
|
+
set: ['value'],
|
|
203
|
+
restore: () => {},
|
|
204
|
+
})
|
|
205
|
+
.getModule();
|
|
217
206
|
|
|
218
207
|
const headers = [
|
|
219
208
|
{ value: 'surname', field: 'included', show: false },
|
|
220
209
|
{ value: 'name', field: 'excluded', show: true },
|
|
221
210
|
];
|
|
222
211
|
|
|
223
|
-
const table = new TableStoreModule({ headers })
|
|
224
|
-
.getModule({
|
|
212
|
+
const table = new TableStoreModule({ headers }).getModule({
|
|
225
213
|
modules: { filters },
|
|
226
214
|
});
|
|
227
215
|
|
|
228
|
-
vi.spyOn(table.actions, 'LOAD_DATA_LIST')
|
|
229
|
-
.mockImplementationOnce(vi.fn());
|
|
216
|
+
vi.spyOn(table.actions, 'LOAD_DATA_LIST').mockImplementationOnce(vi.fn());
|
|
230
217
|
|
|
231
218
|
const store = createStore({
|
|
232
219
|
state: { router },
|
|
@@ -243,8 +230,7 @@ describe('TableStoreModule integration with FiltersStoreModule', () => {
|
|
|
243
230
|
value: ['surname'],
|
|
244
231
|
});
|
|
245
232
|
|
|
246
|
-
expect(store.getters['table/filters/GET_FILTER']('fields'))
|
|
247
|
-
.toEqual(['surname']);
|
|
233
|
+
expect(store.getters['table/filters/GET_FILTER']('fields')).toEqual(['surname']);
|
|
248
234
|
|
|
249
235
|
expect(store.getters['table/FIELDS']).toEqual(['id', 'included']);
|
|
250
236
|
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import applyTransform, {
|
|
2
|
-
notify,
|
|
3
|
-
snakeToCamel,
|
|
4
|
-
} from '../../../api/transformers/index.js';
|
|
1
|
+
import applyTransform, { notify, snakeToCamel } from '../../../api/transformers/index.js';
|
|
5
2
|
|
|
6
3
|
const userinfo = (instance) => ({
|
|
7
4
|
async getSession() {
|
|
8
5
|
const url = '/userinfo';
|
|
9
6
|
try {
|
|
10
7
|
const response = await instance.get(url);
|
|
11
|
-
return applyTransform(response.data, [
|
|
12
|
-
snakeToCamel(),
|
|
13
|
-
]);
|
|
8
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
14
9
|
} catch (err) {
|
|
15
|
-
throw applyTransform(err, [
|
|
16
|
-
notify,
|
|
17
|
-
]);
|
|
10
|
+
throw applyTransform(err, [notify]);
|
|
18
11
|
}
|
|
19
12
|
},
|
|
20
13
|
|
|
@@ -22,13 +15,9 @@ const userinfo = (instance) => ({
|
|
|
22
15
|
const url = 'role/metadata/access';
|
|
23
16
|
try {
|
|
24
17
|
const response = await instance.get(url);
|
|
25
|
-
return applyTransform(response.data, [
|
|
26
|
-
snakeToCamel(),
|
|
27
|
-
]);
|
|
18
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
28
19
|
} catch (err) {
|
|
29
|
-
throw applyTransform(err, [
|
|
30
|
-
notify,
|
|
31
|
-
]);
|
|
20
|
+
throw applyTransform(err, [notify]);
|
|
32
21
|
}
|
|
33
22
|
},
|
|
34
23
|
|
|
@@ -38,9 +27,7 @@ const userinfo = (instance) => ({
|
|
|
38
27
|
try {
|
|
39
28
|
return await instance.post(url, {});
|
|
40
29
|
} catch (err) {
|
|
41
|
-
throw applyTransform(err, [
|
|
42
|
-
notify,
|
|
43
|
-
]);
|
|
30
|
+
throw applyTransform(err, [notify]);
|
|
44
31
|
}
|
|
45
32
|
},
|
|
46
33
|
});
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import deepCopy from 'deep-copy';
|
|
2
2
|
import deepmerge from 'deepmerge';
|
|
3
|
-
import AdminSections
|
|
4
|
-
|
|
5
|
-
import AuditorSections
|
|
6
|
-
from '../../../enums/WebitelApplications/AuditorSections.enum.js';
|
|
3
|
+
import AdminSections from '../../../enums/WebitelApplications/AdminSections.enum.js';
|
|
4
|
+
import AuditorSections from '../../../enums/WebitelApplications/AuditorSections.enum.js';
|
|
7
5
|
import CrmSections from '../../../enums/WebitelApplications/CrmSections.enum.js';
|
|
8
|
-
import SupervisorSections
|
|
9
|
-
|
|
10
|
-
import WebitelApplications
|
|
11
|
-
from '../../../enums/WebitelApplications/WebitelApplications.enum.js';
|
|
6
|
+
import SupervisorSections from '../../../enums/WebitelApplications/SupervisorSections.enum.js';
|
|
7
|
+
import WebitelApplications from '../../../enums/WebitelApplications/WebitelApplications.enum.js';
|
|
12
8
|
|
|
13
9
|
const applicationsAccess = (value = true) => ({
|
|
14
10
|
[WebitelApplications.AGENT]: {
|
|
@@ -196,16 +192,13 @@ export default class ApplicationsAccess {
|
|
|
196
192
|
constructor({ access, value } = { value: true }) {
|
|
197
193
|
/* if access, deeply merge with falsy values schema
|
|
198
194
|
if no access, "not configured => full permissions" */
|
|
199
|
-
this.access = access
|
|
200
|
-
? ApplicationsAccess.restore(access)
|
|
201
|
-
: applicationsAccess(value);
|
|
195
|
+
this.access = access ? ApplicationsAccess.restore(access) : applicationsAccess(value);
|
|
202
196
|
}
|
|
203
197
|
|
|
204
198
|
// minify schema for API sending
|
|
205
199
|
static minify(access) {
|
|
206
200
|
const rmEmptyKeys = (obj) => {
|
|
207
201
|
Object.keys(obj).forEach((key) => {
|
|
208
|
-
|
|
209
202
|
if (!obj[key] || key === '_locale') delete obj[key];
|
|
210
203
|
if (typeof obj[key] === 'object') {
|
|
211
204
|
rmEmptyKeys(obj[key]);
|
|
@@ -29,33 +29,33 @@ export default class UserinfoStoreModule extends BaseStoreModule {
|
|
|
29
29
|
getters = {
|
|
30
30
|
THIS_APP: (state) => state.thisApp,
|
|
31
31
|
// if no access[app] => accessed by default
|
|
32
|
-
CHECK_APP_ACCESS: (state) => (app) => !state.access[app] ||
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
!state.access[getters.THIS_APP]._enabled)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
CHECK_APP_ACCESS: (state) => (app) => !state.access[app] || state.access[app]?._enabled,
|
|
33
|
+
CHECK_OBJECT_ACCESS:
|
|
34
|
+
(state, getters) =>
|
|
35
|
+
({ name, route }) => {
|
|
36
|
+
if (!state.access[getters.THIS_APP] || !state.access[getters.THIS_APP]._enabled)
|
|
37
|
+
return false;
|
|
38
|
+
if (route) return getters.CHECK_OBJECT_ACCESS_BY_ROUTE(route);
|
|
39
|
+
return getters.CHECK_OBJECT_ACCESS_BY_NAME(name);
|
|
40
|
+
},
|
|
41
|
+
CHECK_OBJECT_ACCESS_BY_NAME: (state, getters) => (name) =>
|
|
42
|
+
state.access[getters.THIS_APP][name]?._enabled,
|
|
43
43
|
CHECK_OBJECT_ACCESS_BY_ROUTE: (state, getters) => (route) => {
|
|
44
|
-
const accessKey = Object.keys(state.access[getters.THIS_APP])
|
|
45
|
-
|
|
44
|
+
const accessKey = Object.keys(state.access[getters.THIS_APP]).find((object) =>
|
|
45
|
+
route.name.includes(object),
|
|
46
|
+
);
|
|
46
47
|
return state.access[getters.THIS_APP][accessKey]?._enabled;
|
|
47
48
|
},
|
|
48
|
-
GET_OBJECT_SCOPE:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.find((object) => route.name.includes(object.route))
|
|
58
|
-
),
|
|
49
|
+
GET_OBJECT_SCOPE:
|
|
50
|
+
(state, getters) =>
|
|
51
|
+
({ name, route }) => {
|
|
52
|
+
if (route) return getters.GET_OBJECT_SCOPE_BY_ROUTE(route);
|
|
53
|
+
return getters.GET_OBJECT_SCOPE_BY_NAME(name);
|
|
54
|
+
},
|
|
55
|
+
GET_OBJECT_SCOPE_BY_NAME: (state) => (name) =>
|
|
56
|
+
Object.values(state.scope).find((object) => name === object.name),
|
|
57
|
+
GET_OBJECT_SCOPE_BY_ROUTE: (state) => (route) =>
|
|
58
|
+
Object.values(state.scope).find((object) => route.name.includes(object.route)),
|
|
59
59
|
HAS_READ_ACCESS: (state, getters) => (checkedObject) => {
|
|
60
60
|
if (!getters.CHECK_OBJECT_ACCESS(checkedObject)) return false;
|
|
61
61
|
if (state.permissions[Permissions.READ]) return true;
|
|
@@ -86,13 +86,13 @@ export default class UserinfoStoreModule extends BaseStoreModule {
|
|
|
86
86
|
CONVERT_USER_PERMISSIONS: (context, initialPermissions) => {
|
|
87
87
|
let permissions = {};
|
|
88
88
|
if (!initialPermissions) return permissions;
|
|
89
|
-
permissions = initialPermissions.reduce(
|
|
90
|
-
permissions,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
permissions = initialPermissions.reduce(
|
|
90
|
+
(permissions, currentPermission) => ({
|
|
91
|
+
...permissions,
|
|
92
|
+
[currentPermission.id]: currentPermission,
|
|
93
|
+
}),
|
|
94
|
+
{},
|
|
95
|
+
);
|
|
96
96
|
return permissions;
|
|
97
97
|
},
|
|
98
98
|
|
|
@@ -105,14 +105,17 @@ export default class UserinfoStoreModule extends BaseStoreModule {
|
|
|
105
105
|
|
|
106
106
|
const session = await userinfo.getSession();
|
|
107
107
|
|
|
108
|
-
if (
|
|
108
|
+
if (session.expiresAt - Date.now() < HOUR_LENGTH) {
|
|
109
109
|
await context.dispatch('LOGOUT');
|
|
110
110
|
throw new Error(`Session expires soon ${session.expiresAt}`);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
await context.dispatch('SET_SESSION', session);
|
|
114
114
|
const access = await userinfo.getApplicationsAccess();
|
|
115
|
-
await context.dispatch(
|
|
115
|
+
await context.dispatch(
|
|
116
|
+
'SET_APPLICATIONS_ACCESS',
|
|
117
|
+
new ApplicationsAccess({ access }).getAccess(),
|
|
118
|
+
);
|
|
116
119
|
await context.dispatch('AFTER_OPEN_SESSION_HOOK');
|
|
117
120
|
},
|
|
118
121
|
SET_SESSION: async (context, _session) => {
|
|
@@ -137,19 +140,13 @@ export default class UserinfoStoreModule extends BaseStoreModule {
|
|
|
137
140
|
}
|
|
138
141
|
},
|
|
139
142
|
|
|
140
|
-
LOGOUT: async (
|
|
141
|
-
context,
|
|
142
|
-
{ authUrl = import.meta.env.VITE_AUTH_URL } = {},
|
|
143
|
-
) => {
|
|
143
|
+
LOGOUT: async (context, { authUrl = import.meta.env.VITE_AUTH_URL } = {}) => {
|
|
144
144
|
if (!authUrl) throw new Error('No authUrl for LOGOUT provided');
|
|
145
145
|
await userinfo.logout();
|
|
146
146
|
window.location.href = authUrl;
|
|
147
147
|
},
|
|
148
148
|
|
|
149
|
-
SET_APPLICATIONS_ACCESS: (
|
|
150
|
-
context,
|
|
151
|
-
access,
|
|
152
|
-
) => context.commit('SET_APPLICATIONS_ACCESS', access),
|
|
149
|
+
SET_APPLICATIONS_ACCESS: (context, access) => context.commit('SET_APPLICATIONS_ACCESS', access),
|
|
153
150
|
|
|
154
151
|
SET_LOADING: (context, isLoading) => {
|
|
155
152
|
context.commit('SET_LOADING', isLoading);
|
|
@@ -37,15 +37,10 @@ const breakpoint = reactive({
|
|
|
37
37
|
width: 0,
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
const getClientWidth = () => Math.max(
|
|
41
|
-
document.documentElement.clientWidth,
|
|
42
|
-
window.innerWidth || 0,
|
|
43
|
-
);
|
|
40
|
+
const getClientWidth = () => Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
|
|
44
41
|
|
|
45
|
-
const getClientHeight = () =>
|
|
46
|
-
document.documentElement.clientHeight,
|
|
47
|
-
window.innerHeight || 0,
|
|
48
|
-
);
|
|
42
|
+
const getClientHeight = () =>
|
|
43
|
+
Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
|
49
44
|
|
|
50
45
|
const thresholds = {
|
|
51
46
|
xs: 600,
|
|
@@ -62,9 +57,9 @@ const onResize = () => {
|
|
|
62
57
|
|
|
63
58
|
const xs = width < thresholds.xs;
|
|
64
59
|
const sm = width < thresholds.sm && !xs;
|
|
65
|
-
const md = width <
|
|
66
|
-
const lg = width <
|
|
67
|
-
const xl = width >=
|
|
60
|
+
const md = width < thresholds.md - scrollBarWidth && !(sm || xs);
|
|
61
|
+
const lg = width < thresholds.lg - scrollBarWidth && !(md || sm || xs);
|
|
62
|
+
const xl = width >= thresholds.lg - scrollBarWidth;
|
|
68
63
|
|
|
69
64
|
breakpoint.height = height;
|
|
70
65
|
breakpoint.width = width;
|
|
@@ -88,16 +83,16 @@ const onResize = () => {
|
|
|
88
83
|
breakpoint.xlOnly = xl;
|
|
89
84
|
|
|
90
85
|
switch (true) {
|
|
91
|
-
case
|
|
86
|
+
case xs:
|
|
92
87
|
breakpoint.name = 'xs';
|
|
93
88
|
break;
|
|
94
|
-
case
|
|
89
|
+
case sm:
|
|
95
90
|
breakpoint.name = 'sm';
|
|
96
91
|
break;
|
|
97
|
-
case
|
|
92
|
+
case md:
|
|
98
93
|
breakpoint.name = 'md';
|
|
99
94
|
break;
|
|
100
|
-
case
|
|
95
|
+
case lg:
|
|
101
96
|
breakpoint.name = 'lg';
|
|
102
97
|
break;
|
|
103
98
|
default:
|
|
@@ -106,7 +101,7 @@ const onResize = () => {
|
|
|
106
101
|
}
|
|
107
102
|
|
|
108
103
|
if (typeof mobileBreakpoint === 'number') {
|
|
109
|
-
breakpoint.mobile = width < parseInt(mobileBreakpoint, 10);
|
|
104
|
+
breakpoint.mobile = width < Number.parseInt(mobileBreakpoint, 10);
|
|
110
105
|
|
|
111
106
|
return;
|
|
112
107
|
}
|
|
@@ -60,10 +60,7 @@ describe('Case converters', () => {
|
|
|
60
60
|
|
|
61
61
|
it('Camel-Snake Arrays', () => {
|
|
62
62
|
const camelArr = ['camelToSnake', { camelToSnake: { camelToSnake: null } }];
|
|
63
|
-
const snakeArr = [
|
|
64
|
-
'camel_to_snake',
|
|
65
|
-
{ camel_to_snake: { camel_to_snake: null } },
|
|
66
|
-
];
|
|
63
|
+
const snakeArr = ['camel_to_snake', { camel_to_snake: { camel_to_snake: null } }];
|
|
67
64
|
expect(objCamelToSnake(camelArr)).toEqual(snakeArr);
|
|
68
65
|
expect(objSnakeToCamel(snakeArr)).toEqual(camelArr);
|
|
69
66
|
});
|
|
@@ -3,7 +3,9 @@ import debounce from '../debounce.js';
|
|
|
3
3
|
describe('debounce', () => {
|
|
4
4
|
it('debounces call', async () => {
|
|
5
5
|
let isFnCalled = false;
|
|
6
|
-
let fn = () => {
|
|
6
|
+
let fn = () => {
|
|
7
|
+
isFnCalled = true;
|
|
8
|
+
};
|
|
7
9
|
fn = debounce(fn, 50);
|
|
8
10
|
fn();
|
|
9
11
|
expect(isFnCalled).toBeFalsy();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import prettifyFileSize from '../prettifyFileSize.js';
|
|
2
2
|
|
|
3
3
|
describe('prettifyFileSize', () => {
|
|
4
|
-
it(
|
|
4
|
+
it("prettifies bytes to kb's", () => {
|
|
5
5
|
const size = 1025;
|
|
6
6
|
expect(prettifyFileSize(size)).toBe('1 Kb');
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
it(
|
|
9
|
+
it("prettifies bytes to mb's", () => {
|
|
10
10
|
const size = 1205 ** 2;
|
|
11
11
|
expect(prettifyFileSize(size)).toBe('1.38 Mb');
|
|
12
12
|
});
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import preventHiddenPageCallsDecorator
|
|
2
|
-
from '../preventHiddenPageCallsDecorator.js';
|
|
1
|
+
import preventHiddenPageCallsDecorator from '../preventHiddenPageCallsDecorator.js';
|
|
3
2
|
|
|
4
3
|
describe('preventHiddenPageCallsDecorator', () => {
|
|
5
4
|
it('prevents call on hidden page', () => {
|
|
6
5
|
let isFnCalled = false;
|
|
7
|
-
let fn = () => {
|
|
6
|
+
let fn = () => {
|
|
7
|
+
isFnCalled = true;
|
|
8
|
+
};
|
|
8
9
|
fn = preventHiddenPageCallsDecorator(fn, 50);
|
|
9
10
|
Object.defineProperty(document, 'hidden', {
|
|
10
11
|
configurable: true,
|
|
11
|
-
get() {
|
|
12
|
+
get() {
|
|
13
|
+
return true;
|
|
14
|
+
},
|
|
12
15
|
});
|
|
13
16
|
expect(isFnCalled).toBeFalsy();
|
|
14
17
|
fn();
|