Skip to content

Commit cdf00be

Browse files
authored
Tests: Improve test isolation and cleanup in vitest suites (photoprism#5387)
* Tests: Improve test isolation and cleanup in vitest suites * Tests: Add component tests for navigation, photo toolbar, and file editing * Tests: Remove unused notification spies from batch edit component tests * Tests: update Vitest `$notify` mock to use `vi.fn()` and include `info` method.
1 parent 1b09c2b commit cdf00be

File tree

14 files changed

+1377
-79
lines changed

14 files changed

+1377
-79
lines changed

frontend/tests/vitest/common/config.test.js

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect } from "vitest";
1+
import { describe, it, expect, beforeEach, afterEach } from "vitest";
22
import "../fixtures";
33
import Config from "common/config";
44
import StorageShim from "node-storage-shim";
@@ -11,7 +11,31 @@ const createTestConfig = () => {
1111
return new Config(new StorageShim(), values);
1212
};
1313

14+
const resetThemesToDefault = () => {
15+
themes.SetOptions([
16+
{
17+
text: "Default",
18+
value: "default",
19+
disabled: false,
20+
},
21+
]);
22+
23+
themes.Set("default", {
24+
name: "default",
25+
title: "Default",
26+
colors: {},
27+
variables: {},
28+
});
29+
};
30+
1431
describe("common/config", () => {
32+
beforeEach(() => {
33+
resetThemesToDefault();
34+
});
35+
36+
afterEach(() => {
37+
resetThemesToDefault();
38+
});
1539
it("should get all config values", () => {
1640
const storage = new StorageShim();
1741
const values = { siteTitle: "Foo", name: "testConfig", year: "2300" };
@@ -116,42 +140,12 @@ describe("common/config", () => {
116140
variables: {},
117141
};
118142

119-
themes.SetOptions([
120-
{
121-
text: "Default",
122-
value: "default",
123-
disabled: false,
124-
},
125-
]);
126-
127-
themes.Set("default", {
128-
name: "default",
129-
title: "Default",
130-
colors: {},
131-
variables: {},
132-
});
133-
134143
themes.Assign([forcedTheme]);
135144

136145
cfg.setTheme("default");
137146

138147
expect(cfg.themeName).toBe("portal-forced");
139148
expect(cfg.theme.colors.background).toBe("#111111");
140-
141-
themes.Remove("portal-forced");
142-
themes.SetOptions([
143-
{
144-
text: "Default",
145-
value: "default",
146-
disabled: false,
147-
},
148-
]);
149-
themes.Set("default", {
150-
name: "default",
151-
title: "Default",
152-
colors: {},
153-
variables: {},
154-
});
155149
});
156150

157151
it("should return app edition", () => {

0 commit comments

Comments
 (0)