Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+69
@@ -0,0 +1,69 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { toSessionListModel, type SessionListData } from "./session-list.vm.js";
|
||||
|
||||
const I18N_KEY = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;
|
||||
|
||||
function data(overrides: Partial<SessionListData> = {}): SessionListData {
|
||||
return {
|
||||
devices: [
|
||||
{
|
||||
id: "s-current",
|
||||
isCurrent: true,
|
||||
trusted: true,
|
||||
deviceLabel: "Chrome",
|
||||
approxLocation: "Berlin, DE",
|
||||
lastSeenIso: "2026-07-06T09:00:00.000Z",
|
||||
lastSeenBucket: "justNow",
|
||||
canRevoke: false,
|
||||
},
|
||||
{
|
||||
id: "s-other",
|
||||
isCurrent: false,
|
||||
trusted: false,
|
||||
deviceLabelFallbackKey: "settings.security.sessions.unknownDevice",
|
||||
lastSeenIso: "2026-07-06T07:00:00.000Z",
|
||||
lastSeenBucket: "hours",
|
||||
lastSeenCount: 2,
|
||||
canRevoke: true,
|
||||
},
|
||||
],
|
||||
currentDeviceId: "s-current",
|
||||
otherActiveCount: 1,
|
||||
canRevokeOthers: true,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe("toSessionListModel (M015 hot-swap mapper)", () => {
|
||||
it("maps the domain data to the normalized model with i18n keys", () => {
|
||||
const model = toSessionListModel(data());
|
||||
expect(model.titleKey).toMatch(I18N_KEY);
|
||||
expect(model.emptyHeadlineKey).toMatch(I18N_KEY);
|
||||
expect(model.rowCount).toBe(2);
|
||||
expect(model.currentDeviceId).toBe("s-current");
|
||||
expect(model.otherActiveCount).toBe(1);
|
||||
expect(model.canRevokeOthers).toBe(true);
|
||||
});
|
||||
|
||||
it("carries the raw device label as data and the fallback key when missing", () => {
|
||||
const model = toSessionListModel(data());
|
||||
expect(model.rows[0]?.deviceLabel).toBe("Chrome");
|
||||
expect(model.rows[0]?.deviceLabelFallbackKey).toBeNull();
|
||||
expect(model.rows[1]?.deviceLabel).toBeNull();
|
||||
expect(model.rows[1]?.deviceLabelFallbackKey).toBe("settings.security.sessions.unknownDevice");
|
||||
});
|
||||
|
||||
it("passes the bucketed last-seen through without pre-formatting", () => {
|
||||
const model = toSessionListModel(data());
|
||||
expect(model.rows[0]?.lastSeenBucket).toBe("justNow");
|
||||
expect(model.rows[0]?.lastSeenCount).toBeNull();
|
||||
expect(model.rows[1]?.lastSeenBucket).toBe("hours");
|
||||
expect(model.rows[1]?.lastSeenCount).toBe(2);
|
||||
});
|
||||
|
||||
it("maps an empty device list to a zero-row model", () => {
|
||||
const model = toSessionListModel(data({ devices: [], otherActiveCount: 0, canRevokeOthers: false }));
|
||||
expect(model.rowCount).toBe(0);
|
||||
expect(model.rows).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user