@controleonline/ui-default 1.0.276 → 1.0.277

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@controleonline/ui-default",
3
- "version": "1.0.276",
3
+ "version": "1.0.277",
4
4
  "author": "ControleOnline",
5
5
  "description": "ControleOnline Default Quasar UI Component",
6
6
  "license": "MIT",
@@ -404,7 +404,7 @@ const DefaultTable = ({
404
404
  showTotalItemsInFooter,
405
405
  storedViewMode,
406
406
  tableFiltersVisible,
407
- sortedDataLength: sortedData.length,
407
+ sortedData: stableSerialize(sortedData),
408
408
  toolbarActionsLength: Array.isArray(toolbarActions) ? toolbarActions.length : 0,
409
409
  }),
410
410
  [
@@ -442,7 +442,7 @@ const DefaultTable = ({
442
442
  showTotalItemsInFooter,
443
443
  storedViewMode,
444
444
  tableFiltersVisible,
445
- sortedData.length,
445
+ sortedData,
446
446
  toolbarActions,
447
447
  ],
448
448
  );
@@ -25,13 +25,13 @@ const {
25
25
  useDefaultTableStoreSync,
26
26
  } = require('../../../../react/components/table/useDefaultTableStoreSync');
27
27
 
28
- function Harness({data, store, storeFilters, columnsForTable, tablePreferenceScope}) {
28
+ function Harness({data, store, storeFilters, columnsForTable, tablePreferenceScope, configsSignature = 'sig', configs = {}}) {
29
29
  useDefaultTableStoreSync({
30
30
  columns: [],
31
31
  columnsForTable: columnsForTable || [],
32
32
  data,
33
- defaultTableConfigs: {},
34
- defaultTableConfigsSignature: 'sig',
33
+ defaultTableConfigs: configs,
34
+ defaultTableConfigsSignature: configsSignature,
35
35
  store,
36
36
  storeColumnsLength: 0,
37
37
  storeFilters: storeFilters || {},
@@ -158,4 +158,40 @@ describe('useDefaultTableStoreSync', () => {
158
158
  expect(areTableFiltersEqual(a, {alterDate: {shortcut: 'all'}})).toBe(false);
159
159
  expect(areTableFiltersEqual({}, {})).toBe(true);
160
160
  });
161
+
162
+ it('publishes changed same-count table configs but ignores equivalent snapshots', () => {
163
+ const setConfigs = jest.fn();
164
+ const store = {actions: {setConfigs, setItems}, getters: {}};
165
+ const first = [{id: 'device:396', configs: [{id: 487}]}];
166
+ const second = [{id: 'device:403', configs: [{id: 510}]}];
167
+ let tree;
168
+ renderer.act(() => {
169
+ tree = renderer.create(React.createElement(Harness, {
170
+ data: first,
171
+ store,
172
+ configs: {sortedData: first},
173
+ configsSignature: JSON.stringify(first),
174
+ }));
175
+ });
176
+ expect(setConfigs).toHaveBeenCalledTimes(1);
177
+ renderer.act(() => {
178
+ tree.update(React.createElement(Harness, {
179
+ data: second,
180
+ store,
181
+ configs: {sortedData: second},
182
+ configsSignature: JSON.stringify(second),
183
+ }));
184
+ });
185
+ expect(setConfigs).toHaveBeenCalledTimes(2);
186
+ renderer.act(() => {
187
+ tree.update(React.createElement(Harness, {
188
+ data: [{id: 'device:403', configs: [{id: 510}]}],
189
+ store: {actions: {setConfigs, setItems}, getters: {}},
190
+ configs: {sortedData: second},
191
+ configsSignature: JSON.stringify(second),
192
+ }));
193
+ });
194
+ expect(setConfigs).toHaveBeenCalledTimes(2);
195
+ tree.unmount();
196
+ });
161
197
  });