@nordicsemiconductor/pc-nrfconnect-shared 221.0.0 → 224.0.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/Changelog.md +79 -55
- package/README.md +30 -21
- package/ipc/apps.ts +3 -12
- package/ipc/launcherConfig.ts +0 -2
- package/ipc/sources.ts +0 -5
- package/nrfutil/device/logLibVersions.ts +5 -5
- package/nrfutil/sandbox.ts +1 -1
- package/nrfutil/version/jlinkVersion.test.ts +13 -13
- package/nrfutil/version/jlinkVersion.ts +5 -5
- package/package.json +2 -2
- package/release_notes.md +4 -7
- package/scripts/is-releasable.ts +1 -1
- package/scripts/latest-changelog-entry.test.ts +4 -4
- package/src/Device/DeviceSelector/DeviceSelector.test.tsx +11 -11
- package/src/Device/deviceLister.ts +1 -1
- package/src/Dialog/Dialog.test.tsx +9 -10
- package/src/Dropdown/Dropdown.test.tsx +3 -3
- package/src/Dropdown/DropdownHelpers.test.ts +20 -21
- package/src/ErrorBoundary/ErrorBoundary.test.tsx +4 -4
- package/src/ErrorDialog/ErrorDialog.test.tsx +3 -3
- package/src/ErrorDialog/errorDialogSlice.test.ts +5 -5
- package/src/FactoryReset/FactoryResetButton.test.tsx +23 -17
- package/src/FactoryReset/FactoryResetButton.tsx +3 -1
- package/src/Slider/Factor.test.ts +4 -4
- package/src/index.ts +0 -2
- package/src/logging/appTransport.test.ts +6 -6
- package/src/logging/logBuffer.test.ts +4 -4
- package/src/utils/systemReport.ts +1 -1
- package/typings/generated/ipc/apps.d.ts +5 -11
- package/typings/generated/ipc/apps.d.ts.map +1 -1
- package/typings/generated/ipc/launcherConfig.d.ts +0 -2
- package/typings/generated/ipc/launcherConfig.d.ts.map +1 -1
- package/typings/generated/ipc/sources.d.ts +0 -7
- package/typings/generated/ipc/sources.d.ts.map +1 -1
- package/typings/generated/main/index.d.ts +1 -9
- package/typings/generated/main/index.d.ts.map +1 -1
- package/typings/generated/nrfutil/version/jlinkVersion.d.ts +4 -4
- package/typings/generated/src/FactoryReset/FactoryResetButton.d.ts.map +1 -1
- package/typings/generated/src/index.d.ts +1 -1
- package/typings/generated/src/index.d.ts.map +1 -1
|
@@ -34,7 +34,7 @@ export const hasExpectedVersionFormat = (
|
|
|
34
34
|
|
|
35
35
|
if (!result && logFailure) {
|
|
36
36
|
console.error(
|
|
37
|
-
`The J-Link version was not reported in the expected format. ` +
|
|
37
|
+
`The SEGGER J-Link version was not reported in the expected format. ` +
|
|
38
38
|
`Format: ${dependency.versionFormat}, ` +
|
|
39
39
|
`version: ${JSON.stringify(dependency)}, `
|
|
40
40
|
);
|
|
@@ -99,7 +99,7 @@ export const getJlinkCompatibility = (moduleVersion: ModuleVersion) => {
|
|
|
99
99
|
? strippedVersionName(jlinkVersionDependency.expectedVersion)
|
|
100
100
|
: nrfutilDeviceToJLink(moduleVersion.version);
|
|
101
101
|
return {
|
|
102
|
-
kind: 'No J-Link installed',
|
|
102
|
+
kind: 'No SEGGER J-Link installed',
|
|
103
103
|
requiredJlink: requiredVersion,
|
|
104
104
|
actualJlink: 'none',
|
|
105
105
|
} as const;
|
|
@@ -115,7 +115,7 @@ export const getJlinkCompatibility = (moduleVersion: ModuleVersion) => {
|
|
|
115
115
|
const actualJlink = strippedVersionName(jlinkVersionDependency);
|
|
116
116
|
|
|
117
117
|
return {
|
|
118
|
-
kind: 'Outdated J-Link',
|
|
118
|
+
kind: 'Outdated SEGGER J-Link',
|
|
119
119
|
requiredJlink,
|
|
120
120
|
actualJlink,
|
|
121
121
|
} as const;
|
|
@@ -127,7 +127,7 @@ export const getJlinkCompatibility = (moduleVersion: ModuleVersion) => {
|
|
|
127
127
|
jlinkVersionDependency.expectedVersion.version
|
|
128
128
|
) {
|
|
129
129
|
return {
|
|
130
|
-
kind: 'Tested J-Link is used',
|
|
130
|
+
kind: 'Tested SEGGER J-Link is used',
|
|
131
131
|
} as const;
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -137,7 +137,7 @@ export const getJlinkCompatibility = (moduleVersion: ModuleVersion) => {
|
|
|
137
137
|
const actualJlink = strippedVersionName(jlinkVersionDependency);
|
|
138
138
|
|
|
139
139
|
return {
|
|
140
|
-
kind: 'Newer J-Link is used',
|
|
140
|
+
kind: 'Newer SEGGER J-Link is used',
|
|
141
141
|
requiredJlink,
|
|
142
142
|
actualJlink,
|
|
143
143
|
} as const;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nordicsemiconductor/pc-nrfconnect-shared",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "224.0.0",
|
|
4
4
|
"description": "Shared commodities for developing pc-nrfconnect-* packages",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/NordicSemiconductor/pc-nrfconnect-shared.git"
|
|
8
8
|
},
|
|
9
9
|
"author": "Nordic Semiconductor ASA",
|
|
10
|
-
"license": "
|
|
10
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
11
11
|
"bin": {
|
|
12
12
|
"check-for-typescript": "scripts/check-for-typescript.ts",
|
|
13
13
|
"check-app-properties": "scripts/check-app-properties.ts",
|
package/release_notes.md
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
###
|
|
1
|
+
### Fixed
|
|
2
2
|
|
|
3
|
-
-
|
|
4
|
-
- Narrower Dropdown variant.
|
|
5
|
-
- Automatic character limit derivation for number input components based on
|
|
6
|
-
their range constraints.
|
|
3
|
+
- Apps did not reload after restoring the default settings.
|
|
7
4
|
|
|
8
|
-
###
|
|
5
|
+
### Removed
|
|
9
6
|
|
|
10
|
-
-
|
|
7
|
+
- Removed the `isSkipUpdate*` properties from the launcher config.
|
package/scripts/is-releasable.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { getLatestEntry } from './latest-changelog-entry';
|
|
8
8
|
|
|
9
9
|
describe('getLatestEntry', () => {
|
|
10
|
-
it('
|
|
10
|
+
it('extracts the latest changelog entry', () => {
|
|
11
11
|
const changelog = `# Changelog
|
|
12
12
|
|
|
13
13
|
All notable changes to this project will be documented in this file.
|
|
@@ -29,7 +29,7 @@ All notable changes to this project will be documented in this file.
|
|
|
29
29
|
expect(result.content).toBe('### Changed\n\n- Something');
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
it('
|
|
32
|
+
it('handles changelog with only one entry', () => {
|
|
33
33
|
const changelog = `# Changelog
|
|
34
34
|
|
|
35
35
|
All notable changes to this project will be documented in this file.
|
|
@@ -46,7 +46,7 @@ All notable changes to this project will be documented in this file.
|
|
|
46
46
|
expect(result.content).toBe('### Added\n\n- Something else');
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
it('
|
|
49
|
+
it('handles changelog with empty content', () => {
|
|
50
50
|
const changelog = `# Changelog
|
|
51
51
|
|
|
52
52
|
All notable changes to this project will be documented in this file.
|
|
@@ -65,7 +65,7 @@ All notable changes to this project will be documented in this file.
|
|
|
65
65
|
expect(result.content).toBe('');
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
it('
|
|
68
|
+
it('handles changelog with nothing before the first entry', () => {
|
|
69
69
|
const changelog = `## 33.0.0 - 2022-02-01
|
|
70
70
|
|
|
71
71
|
### Added
|
|
@@ -105,7 +105,7 @@ const validFirmware = {
|
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
describe('DeviceSelector', () => {
|
|
108
|
-
it('
|
|
108
|
+
it('has no device selected by default', () => {
|
|
109
109
|
render(
|
|
110
110
|
<DeviceSelector
|
|
111
111
|
deviceListing={{
|
|
@@ -119,7 +119,7 @@ describe('DeviceSelector', () => {
|
|
|
119
119
|
expect(screen.getByText('Select device')).toBeInTheDocument();
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
-
it('
|
|
122
|
+
it('shows an information when no devices are connected', () => {
|
|
123
123
|
render(
|
|
124
124
|
<DeviceSelector
|
|
125
125
|
deviceListing={{
|
|
@@ -134,7 +134,7 @@ describe('DeviceSelector', () => {
|
|
|
134
134
|
expect(screen.getByText('Nordic development kit')).toBeInTheDocument();
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
it('
|
|
137
|
+
it('shows a list of connected devices', () => {
|
|
138
138
|
render(
|
|
139
139
|
<DeviceSelector
|
|
140
140
|
deviceListing={{
|
|
@@ -149,7 +149,7 @@ describe('DeviceSelector', () => {
|
|
|
149
149
|
expect(screen.getByText(DEVICE_SERIAL_NUMBER)).toBeInTheDocument();
|
|
150
150
|
});
|
|
151
151
|
|
|
152
|
-
it('
|
|
152
|
+
it('does not show disconnected devices', () => {
|
|
153
153
|
render(
|
|
154
154
|
<DeviceSelector
|
|
155
155
|
deviceListing={{
|
|
@@ -164,7 +164,7 @@ describe('DeviceSelector', () => {
|
|
|
164
164
|
expect(screen.queryByText(DEVICE_SERIAL_NUMBER)).toBeNull();
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
-
it('
|
|
167
|
+
it('shows more device info when selecting the expand button', () => {
|
|
168
168
|
render(
|
|
169
169
|
<DeviceSelector
|
|
170
170
|
deviceListing={{
|
|
@@ -181,7 +181,7 @@ describe('DeviceSelector', () => {
|
|
|
181
181
|
expect(screen.getAllByText(/COM/)).toHaveLength(2);
|
|
182
182
|
});
|
|
183
183
|
|
|
184
|
-
it('
|
|
184
|
+
it('allows selecting a device', async () => {
|
|
185
185
|
render(
|
|
186
186
|
<DeviceSelector
|
|
187
187
|
deviceListing={{
|
|
@@ -203,7 +203,7 @@ describe('DeviceSelector', () => {
|
|
|
203
203
|
expect(screen.getAllByText(DEVICE_SERIAL_NUMBER)).toHaveLength(2);
|
|
204
204
|
});
|
|
205
205
|
|
|
206
|
-
it('
|
|
206
|
+
it('allows disconnecting a device', async () => {
|
|
207
207
|
render(
|
|
208
208
|
<DeviceSelector
|
|
209
209
|
deviceListing={{
|
|
@@ -223,7 +223,7 @@ describe('DeviceSelector', () => {
|
|
|
223
223
|
expect(screen.getByText('Select device')).toBeInTheDocument();
|
|
224
224
|
});
|
|
225
225
|
|
|
226
|
-
it('
|
|
226
|
+
it('allows selecting a device when custom devices are enabled and no valid firmware is defined', async () => {
|
|
227
227
|
render(
|
|
228
228
|
<DeviceSelector
|
|
229
229
|
deviceListing={{
|
|
@@ -259,7 +259,7 @@ describe('DeviceSelector', () => {
|
|
|
259
259
|
expect(screen.getAllByText(DEVICE_SERIAL_NUMBER)).toHaveLength(2);
|
|
260
260
|
});
|
|
261
261
|
|
|
262
|
-
it('
|
|
262
|
+
it('allows deselecting a device when custom devices are disabled and no valid firmware is defined', async () => {
|
|
263
263
|
render(
|
|
264
264
|
<DeviceSelector
|
|
265
265
|
deviceListing={{
|
|
@@ -295,7 +295,7 @@ describe('DeviceSelector', () => {
|
|
|
295
295
|
await screen.findByText('Select device');
|
|
296
296
|
});
|
|
297
297
|
|
|
298
|
-
it('
|
|
298
|
+
it('shows firmware prompt when a valid firmware is defined', async () => {
|
|
299
299
|
render(
|
|
300
300
|
<DeviceSelector
|
|
301
301
|
deviceListing={{
|
|
@@ -317,7 +317,7 @@ describe('DeviceSelector', () => {
|
|
|
317
317
|
);
|
|
318
318
|
});
|
|
319
319
|
|
|
320
|
-
it('
|
|
320
|
+
it('selects a device when cancelling firmware prompt', async () => {
|
|
321
321
|
render(
|
|
322
322
|
<DeviceSelector
|
|
323
323
|
deviceListing={{
|
|
@@ -162,7 +162,7 @@ const removeDeviceFromList =
|
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
/*
|
|
165
|
-
* Starts watching for devices with the given traits. See the nrfutil
|
|
165
|
+
* Starts watching for devices with the given traits. See the nrfutil device
|
|
166
166
|
* library for available traits. Whenever devices are attached/detached, this
|
|
167
167
|
* will dispatch AddDevice or removeDevice and trigger events.
|
|
168
168
|
*/
|
|
@@ -28,18 +28,17 @@ describe('Dialog', () => {
|
|
|
28
28
|
</Dialog>
|
|
29
29
|
);
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
it('is rendered when visible', () => {
|
|
32
32
|
render(dialog());
|
|
33
33
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
34
|
-
test;
|
|
35
34
|
});
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
it('is not rendered when not visible', () => {
|
|
38
37
|
render(dialog(false));
|
|
39
38
|
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
40
39
|
});
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
it('shows the expected content', () => {
|
|
43
42
|
render(dialog());
|
|
44
43
|
|
|
45
44
|
expect(screen.getByText('Test Title')).toBeInTheDocument();
|
|
@@ -55,7 +54,7 @@ describe('InfoDialog creator', () => {
|
|
|
55
54
|
</InfoDialog>
|
|
56
55
|
);
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
it('shows the expected content', () => {
|
|
59
58
|
render(dialog());
|
|
60
59
|
|
|
61
60
|
expect(screen.getByText('Info')).toBeInTheDocument();
|
|
@@ -63,7 +62,7 @@ describe('InfoDialog creator', () => {
|
|
|
63
62
|
expect(screen.getByText('Close')).toBeInTheDocument();
|
|
64
63
|
});
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
it('invokes the expected action', () => {
|
|
67
66
|
render(dialog());
|
|
68
67
|
|
|
69
68
|
const closeButton = screen.getByText('Close');
|
|
@@ -80,7 +79,7 @@ describe('ErrorDialog creator', () => {
|
|
|
80
79
|
</ErrorDialog>
|
|
81
80
|
);
|
|
82
81
|
|
|
83
|
-
|
|
82
|
+
it('shows the expected content', () => {
|
|
84
83
|
render(dialog());
|
|
85
84
|
|
|
86
85
|
expect(screen.getByText('Error')).toBeInTheDocument();
|
|
@@ -88,7 +87,7 @@ describe('ErrorDialog creator', () => {
|
|
|
88
87
|
expect(screen.getByText('Close')).toBeInTheDocument();
|
|
89
88
|
});
|
|
90
89
|
|
|
91
|
-
|
|
90
|
+
it('invokes the expected action', () => {
|
|
92
91
|
render(dialog());
|
|
93
92
|
|
|
94
93
|
const closeButton = screen.getByText('Close');
|
|
@@ -111,7 +110,7 @@ describe('ConfirmationDialog creator', () => {
|
|
|
111
110
|
</ConfirmationDialog>
|
|
112
111
|
);
|
|
113
112
|
|
|
114
|
-
|
|
113
|
+
it('shows the expected content', () => {
|
|
115
114
|
render(dialog());
|
|
116
115
|
|
|
117
116
|
expect(screen.getByText('Confirm')).toBeInTheDocument();
|
|
@@ -121,7 +120,7 @@ describe('ConfirmationDialog creator', () => {
|
|
|
121
120
|
expect(screen.getByText('Cancel')).toBeInTheDocument();
|
|
122
121
|
});
|
|
123
122
|
|
|
124
|
-
|
|
123
|
+
it('invokes the expected action', () => {
|
|
125
124
|
render(dialog());
|
|
126
125
|
|
|
127
126
|
fireEvent.click(screen.getByText('Optional'));
|
|
@@ -22,7 +22,7 @@ const items = [
|
|
|
22
22
|
];
|
|
23
23
|
|
|
24
24
|
describe('Dropdown', () => {
|
|
25
|
-
it('
|
|
25
|
+
it('shows a list of items', () => {
|
|
26
26
|
render(
|
|
27
27
|
<Dropdown
|
|
28
28
|
items={items}
|
|
@@ -34,7 +34,7 @@ describe('Dropdown', () => {
|
|
|
34
34
|
expect(screen.getByText('Bar')).toBeInTheDocument();
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
it('calls onSelect
|
|
37
|
+
it('calls onSelect', () => {
|
|
38
38
|
const onSelect = jest.fn();
|
|
39
39
|
const item = items[1];
|
|
40
40
|
render(
|
|
@@ -49,7 +49,7 @@ describe('Dropdown', () => {
|
|
|
49
49
|
expect(onSelect).toHaveBeenCalledWith(item);
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
it('correct item
|
|
52
|
+
it('selects the correct item', () => {
|
|
53
53
|
render(
|
|
54
54
|
<Dropdown
|
|
55
55
|
items={items}
|
|
@@ -10,40 +10,39 @@ import {
|
|
|
10
10
|
getSelectedDropdownItem,
|
|
11
11
|
} from './DropdownHelpers';
|
|
12
12
|
|
|
13
|
+
const itemList = [
|
|
14
|
+
{ label: 'foo label', value: 'foo' },
|
|
15
|
+
{ label: 'bar label', value: 'bar' },
|
|
16
|
+
];
|
|
17
|
+
|
|
13
18
|
describe('getSelectedDropdownItem', () => {
|
|
19
|
+
it('returns the item with the correct value', () => {
|
|
20
|
+
expect(getSelectedDropdownItem(itemList, 'bar')).toBe(itemList[1]);
|
|
21
|
+
});
|
|
22
|
+
|
|
14
23
|
it('returns the first item if value is undefined', () => {
|
|
15
|
-
const itemList = [{ label: 'foo', value: 'foo' }];
|
|
16
24
|
expect(getSelectedDropdownItem(itemList, undefined)).toBe(itemList[0]);
|
|
17
25
|
});
|
|
18
26
|
|
|
19
27
|
it('returns the first item if value is not found', () => {
|
|
20
|
-
|
|
21
|
-
expect(getSelectedDropdownItem(itemList, 'bar')).toBe(itemList[0]);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('returns the item with the correct value', () => {
|
|
25
|
-
const itemList = [
|
|
26
|
-
{ label: 'foo', value: 'foo' },
|
|
27
|
-
{ label: 'bar', value: 'bar' },
|
|
28
|
-
];
|
|
29
|
-
expect(getSelectedDropdownItem(itemList, 'bar')).toBe(itemList[1]);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('returns the item with the correct value when value is a boolean', () => {
|
|
33
|
-
const itemList = [
|
|
34
|
-
{ label: 'on', value: 'on' },
|
|
35
|
-
{ label: 'off', value: 'off' },
|
|
36
|
-
];
|
|
37
|
-
expect(getSelectedDropdownItem(itemList, true)).toBe(itemList[0]);
|
|
28
|
+
expect(getSelectedDropdownItem(itemList, 'unknown')).toBe(itemList[0]);
|
|
38
29
|
});
|
|
39
30
|
|
|
40
31
|
it('returns the notFound item if value is not found', () => {
|
|
41
|
-
const itemList = [{ label: 'foo', value: 'foo' }];
|
|
42
32
|
const notFound = { label: 'not found', value: 'not found' };
|
|
43
|
-
expect(getSelectedDropdownItem(itemList, '
|
|
33
|
+
expect(getSelectedDropdownItem(itemList, 'unknown', notFound)).toBe(
|
|
44
34
|
notFound
|
|
45
35
|
);
|
|
46
36
|
});
|
|
37
|
+
|
|
38
|
+
it('handles booleans as the strings `on` and `off`', () => {
|
|
39
|
+
const booleanList = [
|
|
40
|
+
{ label: 'on label', value: 'on' },
|
|
41
|
+
{ label: 'off label', value: 'off' },
|
|
42
|
+
];
|
|
43
|
+
expect(getSelectedDropdownItem(booleanList, true).value).toBe('on');
|
|
44
|
+
expect(getSelectedDropdownItem(booleanList, false).value).toBe('off');
|
|
45
|
+
});
|
|
47
46
|
});
|
|
48
47
|
|
|
49
48
|
describe('convertToDropDownItems', () => {
|
|
@@ -43,7 +43,7 @@ describe('ErrorBoundary', () => {
|
|
|
43
43
|
jest.clearAllMocks();
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
it('
|
|
46
|
+
it('accepts custom reporting functions', () => {
|
|
47
47
|
const sendTelemetryEvent = jest.fn();
|
|
48
48
|
|
|
49
49
|
render(
|
|
@@ -54,7 +54,7 @@ describe('ErrorBoundary', () => {
|
|
|
54
54
|
expect(sendTelemetryEvent).toHaveBeenCalled();
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
it('
|
|
57
|
+
it('renders error boundary component when there is an error', () => {
|
|
58
58
|
render(
|
|
59
59
|
<ErrorBoundary>
|
|
60
60
|
<Child />
|
|
@@ -64,7 +64,7 @@ describe('ErrorBoundary', () => {
|
|
|
64
64
|
expect(errorMessage).toBeDefined();
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
it('
|
|
67
|
+
it('clears store on factory reset', async () => {
|
|
68
68
|
render(
|
|
69
69
|
<ErrorBoundary>
|
|
70
70
|
<Child />
|
|
@@ -76,7 +76,7 @@ describe('ErrorBoundary', () => {
|
|
|
76
76
|
expect(store().clear).toHaveBeenCalled();
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
it('
|
|
79
|
+
it('presents system information', async () => {
|
|
80
80
|
render(
|
|
81
81
|
<ErrorBoundary>
|
|
82
82
|
<Child />
|
|
@@ -21,14 +21,14 @@ describe('ErrorDialog', () => {
|
|
|
21
21
|
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
it('
|
|
24
|
+
it('renders visible dialog with one message', () => {
|
|
25
25
|
render(<ErrorDialog />, [showDialog('An error occured')]);
|
|
26
26
|
|
|
27
27
|
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
28
28
|
expect(screen.getByText('An error occured')).toBeInTheDocument();
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
it('
|
|
31
|
+
it('renders visible dialog with two messages', () => {
|
|
32
32
|
render(<ErrorDialog />, [
|
|
33
33
|
showDialog('An error occured'),
|
|
34
34
|
showDialog('Another error occured'),
|
|
@@ -54,7 +54,7 @@ describe('ErrorDialog', () => {
|
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
it('can have
|
|
57
|
+
it('can have custom error resolutions', () => {
|
|
58
58
|
const specialHandling = jest.fn();
|
|
59
59
|
|
|
60
60
|
render(<ErrorDialog />, [
|
|
@@ -11,13 +11,13 @@ const anErrorMessage = 'An error occurred';
|
|
|
11
11
|
const anotherErrorMessage = 'Another error occurred';
|
|
12
12
|
|
|
13
13
|
describe('errorDialogReducer', () => {
|
|
14
|
-
it('
|
|
14
|
+
it('is hidden by default', () => {
|
|
15
15
|
const initialState = dispatchTo(reducer);
|
|
16
16
|
|
|
17
17
|
expect(initialState.isVisible).toEqual(false);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
it('
|
|
20
|
+
it('shows a message', () => {
|
|
21
21
|
const withAnError = dispatchTo(reducer, [
|
|
22
22
|
showDialog(anErrorMessage, {}),
|
|
23
23
|
]);
|
|
@@ -27,7 +27,7 @@ describe('errorDialogReducer', () => {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
it('
|
|
30
|
+
it('shows multiple messages', () => {
|
|
31
31
|
const withTwoErrors = dispatchTo(reducer, [
|
|
32
32
|
showDialog(anErrorMessage, {}),
|
|
33
33
|
showDialog(anotherErrorMessage, {}),
|
|
@@ -41,7 +41,7 @@ describe('errorDialogReducer', () => {
|
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
it('
|
|
44
|
+
it('does not show duplicate messages', () => {
|
|
45
45
|
const withAnError = dispatchTo(reducer, [
|
|
46
46
|
showDialog(anErrorMessage, {}),
|
|
47
47
|
showDialog(anErrorMessage, {}),
|
|
@@ -52,7 +52,7 @@ describe('errorDialogReducer', () => {
|
|
|
52
52
|
]);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
it('
|
|
55
|
+
it('can be hidden and cleared', () => {
|
|
56
56
|
const withAClearedError = dispatchTo(reducer, [
|
|
57
57
|
showDialog(anErrorMessage, {}),
|
|
58
58
|
hideDialog(),
|
|
@@ -11,36 +11,42 @@ import render from '../../test/testrenderer';
|
|
|
11
11
|
import { getAppSpecificStore as store } from '../utils/persistentStore';
|
|
12
12
|
import FactoryResetButton from './FactoryResetButton';
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const FACTORY_RESET = 'Factory reset';
|
|
15
|
+
const OK = 'Restore';
|
|
16
|
+
const CANCEL = 'Cancel';
|
|
16
17
|
|
|
17
18
|
describe('FactoryReset', () => {
|
|
18
19
|
afterEach(() => {
|
|
19
20
|
jest.resetAllMocks();
|
|
20
21
|
});
|
|
21
22
|
|
|
22
|
-
it('
|
|
23
|
-
render(<FactoryResetButton label={
|
|
24
|
-
fireEvent.click(screen.getByText(
|
|
25
|
-
await screen.findByText(
|
|
26
|
-
fireEvent.click(screen.getByText(
|
|
23
|
+
it('clears the store', async () => {
|
|
24
|
+
render(<FactoryResetButton label={FACTORY_RESET} />);
|
|
25
|
+
fireEvent.click(screen.getByText(FACTORY_RESET));
|
|
26
|
+
await screen.findByText(OK);
|
|
27
|
+
fireEvent.click(screen.getByText(OK));
|
|
27
28
|
expect(store().clear).toHaveBeenCalled();
|
|
28
29
|
});
|
|
29
30
|
|
|
30
|
-
it('
|
|
31
|
-
render(<FactoryResetButton label={
|
|
32
|
-
fireEvent.click(screen.getByText(
|
|
33
|
-
await screen.findByText(
|
|
34
|
-
fireEvent.click(screen.getByText(
|
|
31
|
+
it('does not clear the store when cancelled', async () => {
|
|
32
|
+
render(<FactoryResetButton label={FACTORY_RESET} />);
|
|
33
|
+
fireEvent.click(screen.getByText(FACTORY_RESET));
|
|
34
|
+
await screen.findByText(CANCEL);
|
|
35
|
+
fireEvent.click(screen.getByText(CANCEL));
|
|
35
36
|
expect(store().clear).not.toHaveBeenCalled();
|
|
36
37
|
});
|
|
37
38
|
|
|
38
|
-
it('
|
|
39
|
+
it('allows overriding the reset function', async () => {
|
|
39
40
|
const overrideResetFn = jest.fn();
|
|
40
|
-
render(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
render(
|
|
42
|
+
<FactoryResetButton
|
|
43
|
+
label={FACTORY_RESET}
|
|
44
|
+
resetFn={overrideResetFn}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
fireEvent.click(screen.getByText(FACTORY_RESET));
|
|
48
|
+
await screen.findByText(OK);
|
|
49
|
+
fireEvent.click(screen.getByText(OK));
|
|
44
50
|
expect(overrideResetFn).toHaveBeenCalled();
|
|
45
51
|
});
|
|
46
52
|
});
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import React, { FC, useRef, useState } from 'react';
|
|
8
|
+
import { getCurrentWindow } from '@electron/remote';
|
|
8
9
|
|
|
9
10
|
import Button, { ButtonVariants } from '../Button/Button';
|
|
10
11
|
import { Dialog, DialogButton } from '../Dialog/Dialog';
|
|
@@ -21,7 +22,7 @@ interface Props {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const DEFAULT_MODAL_TEXT =
|
|
24
|
-
'By restoring
|
|
25
|
+
'By restoring the default settings, all locally stored, app-specific configuration values will be lost. This does not include configurations such as device renames and favorites. The app will be reloaded. Are you sure you want to proceed?';
|
|
25
26
|
|
|
26
27
|
const FactoryResetButton: FC<Props> = ({
|
|
27
28
|
resetFn,
|
|
@@ -36,6 +37,7 @@ const FactoryResetButton: FC<Props> = ({
|
|
|
36
37
|
const defaultResetFn = () => {
|
|
37
38
|
store().clear();
|
|
38
39
|
logger.info('Successfully restored defaults');
|
|
40
|
+
getCurrentWindow().reload();
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
return (
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { isFactor } from './factor';
|
|
8
8
|
|
|
9
9
|
describe('Factor', () => {
|
|
10
|
-
|
|
10
|
+
test('Valid integer factors ', () => {
|
|
11
11
|
expect(isFactor(20, 5)).toBe(true);
|
|
12
12
|
expect(isFactor(28, 2)).toBe(true);
|
|
13
13
|
expect(isFactor(27, 3)).toBe(true);
|
|
@@ -16,7 +16,7 @@ describe('Factor', () => {
|
|
|
16
16
|
expect(isFactor(21, 7)).toBe(true);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
test('Invalid integer factors ', () => {
|
|
20
20
|
expect(isFactor(20, 6)).toBe(false);
|
|
21
21
|
expect(isFactor(28, 3)).toBe(false);
|
|
22
22
|
expect(isFactor(27, 4)).toBe(false);
|
|
@@ -25,7 +25,7 @@ describe('Factor', () => {
|
|
|
25
25
|
expect(isFactor(21, 8)).toBe(false);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
test('Valid decimal factors ', () => {
|
|
29
29
|
expect(isFactor(0.15, 0.05)).toBe(true);
|
|
30
30
|
expect(isFactor(0.2331, 0.0001)).toBe(true);
|
|
31
31
|
expect(isFactor(0.22, 0.02)).toBe(true);
|
|
@@ -36,7 +36,7 @@ describe('Factor', () => {
|
|
|
36
36
|
expect(isFactor(0.2331, 0.1)).toBe(true);
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
test('Invalid decimal factors ', () => {
|
|
40
40
|
expect(isFactor(0.16, 0.05)).toBe(false);
|
|
41
41
|
expect(isFactor(0.2331, 0.0002)).toBe(false);
|
|
42
42
|
expect(isFactor(0.22, 0.03)).toBe(false);
|
package/src/index.ts
CHANGED
|
@@ -196,12 +196,10 @@ export {
|
|
|
196
196
|
inMain as apps,
|
|
197
197
|
type App as AppType,
|
|
198
198
|
type AppSpec,
|
|
199
|
-
type AppWithError,
|
|
200
199
|
type DownloadableApp,
|
|
201
200
|
type InstalledDownloadableApp,
|
|
202
201
|
type LaunchableApp,
|
|
203
202
|
type LocalApp,
|
|
204
|
-
type SourceWithError,
|
|
205
203
|
type UninstalledDownloadableApp,
|
|
206
204
|
type WithdrawnApp,
|
|
207
205
|
} from '../ipc/apps';
|