|
|
@@ -3,6 +3,7 @@ import { createRoot, getOwner, onCleanup } from "solid-js"
|
|
|
import { createTabMemory } from "./tab-memory"
|
|
|
import { nextTabAfterClose, pushClosedTab, removeClosedTabs, takeClosedTab, type ClosedTab } from "./closed-tabs"
|
|
|
import type { SessionTab, Tab } from "./tabs"
|
|
|
+import { migrateTabs } from "./tab-migration"
|
|
|
import type { ServerConnection } from "./server"
|
|
|
|
|
|
const server = "local\nhttp://localhost:4096" as ServerConnection.Key
|
|
|
@@ -11,6 +12,28 @@ function sessionTab(sessionId: string): SessionTab {
|
|
|
return { type: "session", server, sessionId }
|
|
|
}
|
|
|
|
|
|
+describe("tab migration", () => {
|
|
|
+ test("drops null and malformed persisted tabs", () => {
|
|
|
+ expect(
|
|
|
+ migrateTabs(
|
|
|
+ [null, sessionTab("a"), { type: "session", server }, { type: "unknown", server }, "invalid"],
|
|
|
+ server,
|
|
|
+ ),
|
|
|
+ ).toEqual([sessionTab("a")])
|
|
|
+ })
|
|
|
+
|
|
|
+ test("adds the fallback server to valid legacy tabs", () => {
|
|
|
+ expect(migrateTabs([{ type: "session", sessionId: "a", dirBase64: "legacy" }], server)).toEqual([
|
|
|
+ sessionTab("a"),
|
|
|
+ ])
|
|
|
+ })
|
|
|
+
|
|
|
+ test("replaces invalid top-level persisted data", () => {
|
|
|
+ expect(migrateTabs(null, server)).toEqual([])
|
|
|
+ expect(migrateTabs({}, server)).toEqual([])
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
describe("tab memory", () => {
|
|
|
test("keeps state until its tab is removed", () => {
|
|
|
createRoot((dispose) => {
|