mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-10-30 00:27:43 +09:00
We are moving away from binding system to variables and instead gonna have one global variable. Here moved system values into separate store coupled to pages instead of variables. Also fixed suggestions in address bar, probably broke while design system refactorings. Testing - submit form with one named input - check system value is rendered - check system value can be inspected
83 lines
2.0 KiB
TypeScript
83 lines
2.0 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
import type { Page, Pages } from "@webstudio-is/sdk";
|
|
import { $pages } from "~/shared/nano-states";
|
|
import { registerContainers } from "~/shared/sync";
|
|
import { updateCurrentSystem } from "./system";
|
|
import { selectPage } from "./awareness";
|
|
|
|
registerContainers();
|
|
|
|
const getInitialPages = (page: Page): Pages => ({
|
|
folders: [
|
|
{
|
|
id: "rootId",
|
|
name: "",
|
|
slug: "",
|
|
children: ["homeId", "dynamicId"],
|
|
},
|
|
],
|
|
homePage: {
|
|
id: "homeId",
|
|
path: "",
|
|
name: "",
|
|
title: "",
|
|
meta: {},
|
|
rootInstanceId: "",
|
|
},
|
|
pages: [page],
|
|
});
|
|
|
|
describe("history", () => {
|
|
test("add new path at the start", () => {
|
|
$pages.set(
|
|
getInitialPages({
|
|
id: "dynamicId",
|
|
path: "/blog/:date/post/:slug",
|
|
name: "",
|
|
title: "",
|
|
meta: {},
|
|
rootInstanceId: "",
|
|
})
|
|
);
|
|
selectPage("dynamicId");
|
|
updateCurrentSystem({
|
|
params: { date: "my-date", slug: "my-slug" },
|
|
});
|
|
expect($pages.get()?.pages[0].history).toEqual([
|
|
"/blog/my-date/post/my-slug",
|
|
]);
|
|
updateCurrentSystem({
|
|
params: { date: "another-date", slug: "another-slug" },
|
|
});
|
|
expect($pages.get()?.pages[0].history).toEqual([
|
|
"/blog/another-date/post/another-slug",
|
|
"/blog/my-date/post/my-slug",
|
|
]);
|
|
});
|
|
|
|
test("move existing path to the start", () => {
|
|
$pages.set(
|
|
getInitialPages({
|
|
id: "dynamicId",
|
|
path: "/blog/:date/post/:slug",
|
|
name: "",
|
|
title: "",
|
|
meta: {},
|
|
rootInstanceId: "",
|
|
history: [
|
|
"/blog/another-date/post/another-slug",
|
|
"/blog/my-date/post/my-slug",
|
|
],
|
|
})
|
|
);
|
|
selectPage("dynamicId");
|
|
updateCurrentSystem({
|
|
params: { date: "my-date", slug: "my-slug" },
|
|
});
|
|
expect($pages.get()?.pages[0].history).toEqual([
|
|
"/blog/my-date/post/my-slug",
|
|
"/blog/another-date/post/another-slug",
|
|
]);
|
|
});
|
|
});
|