dsh-panel-control 0.3.14 → 0.3.15
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/index.js +804 -706
- package/package.json +1 -1
- package/scripts/host-smoke.mjs +49 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-panel-control",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Manage the global panel navigation at the top of the DSH sidebar: reorder, hide and group every entry, with the layout persisted per installation.",
|
|
6
6
|
"keywords": [
|
package/scripts/host-smoke.mjs
CHANGED
|
@@ -10,9 +10,17 @@
|
|
|
10
10
|
* node .scratch/host-smoke.mjs
|
|
11
11
|
*/
|
|
12
12
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
13
|
+
import fs from 'node:fs/promises';
|
|
13
14
|
import path from 'node:path';
|
|
14
15
|
|
|
15
16
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
|
|
18
|
+
// Keep the harness out of the real preferences and the real host.log: the
|
|
19
|
+
// module resolves its state directory at import time, so this must be set first.
|
|
20
|
+
const STATE = path.join(here, '..', '.scratch', 'smoke-state');
|
|
21
|
+
process.env.DPC_STATE_DIR = STATE;
|
|
22
|
+
await fs.mkdir(STATE, { recursive: true });
|
|
23
|
+
|
|
16
24
|
// `npm run smoke -- <file>` points the harness at another copy, which is how
|
|
17
25
|
// a regression (or the broken revision that shipped once) gets reproduced.
|
|
18
26
|
const override = process.argv[2];
|
|
@@ -43,6 +51,27 @@ function check(name, ok, detail) {
|
|
|
43
51
|
}
|
|
44
52
|
}
|
|
45
53
|
|
|
54
|
+
// The registry currently holds revision "rev-now" for this package; the page
|
|
55
|
+
// below asks for "rev-old", which is the 404 that silently drops a plugin.
|
|
56
|
+
const clientModulesStub = {
|
|
57
|
+
served: [],
|
|
58
|
+
graph: () => ({
|
|
59
|
+
rev: 'rev-test',
|
|
60
|
+
release: 'rel',
|
|
61
|
+
entries: [
|
|
62
|
+
{ id: 'a' },
|
|
63
|
+
{ id: 'b' },
|
|
64
|
+
{ id: 'dsh-panel-control', rev: 'rev-now', url: 'plugins/??dsh-panel-control/client.js&rev=rev-now' },
|
|
65
|
+
],
|
|
66
|
+
batches: [],
|
|
67
|
+
}),
|
|
68
|
+
async bundleResource(method, url) {
|
|
69
|
+
clientModulesStub.served.push(String(url));
|
|
70
|
+
if (String(url).includes('rev-now')) return { status: 200, headers: {}, body: 'current' };
|
|
71
|
+
return { status: 404 };
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
46
75
|
const registrations = [];
|
|
47
76
|
const scope = {
|
|
48
77
|
get(key) {
|
|
@@ -58,7 +87,7 @@ const scope = {
|
|
|
58
87
|
};
|
|
59
88
|
}
|
|
60
89
|
if (key === 'clientModules') {
|
|
61
|
-
return
|
|
90
|
+
return clientModulesStub;
|
|
62
91
|
}
|
|
63
92
|
return undefined;
|
|
64
93
|
},
|
|
@@ -158,7 +187,25 @@ if (route) {
|
|
|
158
187
|
const body = await response.json();
|
|
159
188
|
check('inventory answers', body && body.result && body.result.ok === true, JSON.stringify(body).slice(0, 160));
|
|
160
189
|
check('inventory rev matches graph', body.result.value.rev === 'rev-test', body.result.value && body.result.value.rev);
|
|
161
|
-
|
|
190
|
+
|
|
191
|
+
const stale = await clientModulesStub.bundleResource(
|
|
192
|
+
'GET',
|
|
193
|
+
'/plugins/??dsh-panel-control/client.js&rev=rev-old',
|
|
194
|
+
);
|
|
195
|
+
check('stale revision is served at the current one', stale.status === 200, `status ${stale.status}`);
|
|
196
|
+
const fresh = await clientModulesStub.bundleResource(
|
|
197
|
+
'GET',
|
|
198
|
+
'/plugins/??dsh-panel-control/client.js&rev=rev-now',
|
|
199
|
+
);
|
|
200
|
+
check('current revision passes straight through', fresh.status === 200, `status ${fresh.status}`);
|
|
201
|
+
const other = await clientModulesStub.bundleResource('GET', '/plugins/??someone-else/client.js&rev=old');
|
|
202
|
+
check('other packages keep their 404', other.status === 404, `status ${other.status}`);
|
|
203
|
+
check(
|
|
204
|
+
'inventory ids',
|
|
205
|
+
Array.isArray(body.result.value.ids) &&
|
|
206
|
+
body.result.value.ids.join() === 'a,b,dsh-panel-control',
|
|
207
|
+
body.result.value && body.result.value.ids.join(),
|
|
208
|
+
);
|
|
162
209
|
} catch (error) {
|
|
163
210
|
check('inventory answers', false, error.message);
|
|
164
211
|
}
|