mirror of
https://github.com/traberph/short.git
synced 2026-11-22 22:55:12 +00:00
Save imported palettes per user and assign single palette colors
- imported coolors.co palettes are stored per user (new palettes table, GET/POST/DELETE /palettes, duplicates ignored, max 50) and listed under "Your palettes" with a remove button - clicking a single color of any palette opens a menu to use it as background, text, buttons or button text; the name row still applies the whole palette - theme picker moved into its own component Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -318,6 +318,38 @@ describe("redirects and stats", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("saved palettes", () => {
|
||||
it("saves palettes per user without duplicates", async () => {
|
||||
const { user } = setup();
|
||||
const alice = user("alice");
|
||||
const bob = user("bob");
|
||||
const colors = ["#264653", "#2A9D8F", "#e9c46a"];
|
||||
|
||||
const created = await alice.api("POST", "/palettes", { colors });
|
||||
expect(created.status).toBe(201);
|
||||
const palette = await created.json();
|
||||
expect(palette.colors).toEqual(["#264653", "#2a9d8f", "#e9c46a"]);
|
||||
|
||||
const again = await alice.api("POST", "/palettes", { colors: ["#264653", "#2a9d8f", "#E9C46A"] });
|
||||
expect(again.status).toBe(200);
|
||||
expect((await again.json()).id).toBe(palette.id);
|
||||
|
||||
expect(await (await alice.api("GET", "/palettes")).json()).toHaveLength(1);
|
||||
expect(await (await bob.api("GET", "/palettes")).json()).toEqual([]);
|
||||
expect((await bob.api("DELETE", `/palettes/${palette.id}`)).status).toBe(404);
|
||||
expect((await alice.api("DELETE", `/palettes/${palette.id}`)).status).toBe(204);
|
||||
expect(await (await alice.api("GET", "/palettes")).json()).toEqual([]);
|
||||
});
|
||||
|
||||
it("rejects invalid palettes", async () => {
|
||||
const { user } = setup();
|
||||
const alice = user("alice");
|
||||
expect((await alice.api("POST", "/palettes", { colors: ["#264653"] })).status).toBe(400);
|
||||
expect((await alice.api("POST", "/palettes", { colors: ["#264653", "red"] })).status).toBe(400);
|
||||
expect((await alice.api("POST", "/palettes", { colors: Array(11).fill("#264653") })).status).toBe(400);
|
||||
});
|
||||
});
|
||||
|
||||
describe("api tokens", () => {
|
||||
it("creates, lists and revokes the caller's tokens only", async () => {
|
||||
const { app, user } = setup();
|
||||
|
||||
Reference in New Issue
Block a user