@jskit-ai/users-web 0.2.64 → 0.2.66

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.
@@ -101,6 +101,8 @@ function record(name) {
101
101
  window.accountFixture = {
102
102
  reports: [],
103
103
  events: [],
104
+ // Component updates since load, so a test can see the page re-rendering whatever the machine's load.
105
+ updates: 0,
104
106
  profileProps,
105
107
  profileState,
106
108
  placeSection() {
@@ -159,6 +161,11 @@ const app = createApp({
159
161
  default: () => h(ShellLayout, { surfaceLabel: "Fixture" }, { default: () => h(RouterView) })
160
162
  })
161
163
  });
164
+ app.mixin({
165
+ updated() {
166
+ window.accountFixture.updates += 1;
167
+ }
168
+ });
162
169
  app.provide(SHELL_WEB_PLACEMENT_RUNTIME_KEY, placement);
163
170
  app.provide(SHELL_NAVIGATION_RUNTIME_KEY, navigation);
164
171
  app.provide(SHELL_WEB_ERROR_RUNTIME_KEY, errorRuntime);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/users-web",
3
- "version": "0.2.64",
3
+ "version": "0.2.66",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -14,14 +14,14 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@jskit-ai/uploads-image-web": "0.2.27",
17
- "@jskit-ai/users-core": "0.2.51"
17
+ "@jskit-ai/users-core": "0.2.53"
18
18
  },
19
19
  "peerDependencies": {
20
- "@jskit-ai/auth-web": "0.2.46",
20
+ "@jskit-ai/auth-web": "0.2.47",
21
21
  "@jskit-ai/http-runtime": "0.2.27",
22
- "@jskit-ai/http-web": "0.2.47",
22
+ "@jskit-ai/http-web": "0.2.49",
23
23
  "@jskit-ai/kernel": "0.2.27",
24
- "@jskit-ai/shell-web": "0.2.40",
24
+ "@jskit-ai/shell-web": "0.2.41",
25
25
  "@tanstack/vue-query": "^5.90.5",
26
26
  "vue": "^3.5.13",
27
27
  "vue-router": "^5.0.4",
@@ -87,17 +87,25 @@ async function finish(api) {
87
87
  await api.page.close();
88
88
  }
89
89
 
90
- /** Seconds the page's main thread works during one idle second: an update loop keeps it near 1. */
91
- async function busySeconds(page) {
90
+ /**
91
+ * What the page does during one idle second, in measures the machine's load cannot inflate: the component updates
92
+ * (a re-render loop) and the main thread's CPU seconds (a busy loop keeps them near 1). A page at rest has neither.
93
+ */
94
+ async function idleSecond(page) {
92
95
  const session = await page.context().newCDPSession(page);
93
- await session.send("Performance.enable");
94
- async function taskSeconds() {
96
+ // Thread time, not wall time: on a loaded machine a task waits longer for the CPU but still uses only what it needs.
97
+ await session.send("Performance.enable", { timeDomain: "threadTicks" });
98
+ async function reading() {
95
99
  const { metrics } = await session.send("Performance.getMetrics");
96
- return metrics.find((metric) => metric.name === "TaskDuration").value;
100
+ return {
101
+ updates: await page.evaluate(() => window.accountFixture.updates),
102
+ cpu: metrics.find((metric) => metric.name === "TaskDuration").value
103
+ };
97
104
  }
98
- const before = await taskSeconds();
105
+ const start = await reading();
99
106
  await page.waitForTimeout(1000);
100
- return (await taskSeconds()) - before;
107
+ const end = await reading();
108
+ return { updates: end.updates - start.updates, busy: end.cpu - start.cpu };
101
109
  }
102
110
 
103
111
  function lastReport(page) {
@@ -248,8 +256,9 @@ test("a refused preference shows its message", options, async () => {
248
256
  await page.getByRole("button", { name: /Save preferences/u }).click();
249
257
  await expect(page.getByText("Theme is not allowed.")).toBeVisible();
250
258
  // The old error array looped here for seconds before Vue gave up, so the page must also stay idle.
251
- const busy = await busySeconds(page);
252
- assert.ok(busy < 0.5, `the page worked for ${busy} s of an idle second`);
259
+ const idle = await idleSecond(page);
260
+ assert.equal(idle.updates, 0, `the page updated components ${idle.updates} times in an idle second`);
261
+ assert.ok(idle.busy < 0.5, `the page worked for ${idle.busy} CPU s of an idle second`);
253
262
  await finish(api);
254
263
  });
255
264