Skip to content

Commit 3c401be

Browse files
committed
chore: minor test cleanup
1 parent 7b73737 commit 3c401be

File tree

3 files changed

+7
-117
lines changed

3 files changed

+7
-117
lines changed

api/src/__test__/store/modules/__snapshots__/paths.test.ts.snap

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -40,47 +40,3 @@ exports[`Returns paths 1`] = `
4040
"partnerBannerTarget",
4141
]
4242
`;
43-
44-
exports[`Returns paths 2`] = `
45-
[
46-
StringContaining "api/api/src/store/modules",
47-
"/usr/local/unraid-api/",
48-
StringContaining "api/api/dev/data",
49-
"/var/lib/docker/unraid-autostart",
50-
"/var/run/docker.sock",
51-
StringContaining "api/api/dev/states/parity-checks.log",
52-
"/etc/nginx/htpasswd",
53-
"/var/run/emhttpd.socket",
54-
StringContaining "api/api/dev/states",
55-
StringContaining "api/api/dev/dynamix",
56-
"/boot/config/plugins/dynamix/case-model.cfg",
57-
[
58-
StringContaining "api/api/dev/dynamix/default.cfg",
59-
StringContaining "api/api/dev/dynamix/dynamix.cfg",
60-
],
61-
"/boot/config/plugins/dynamix.my.servers/",
62-
StringContaining "api/api/dev/Unraid.net/myservers.cfg",
63-
StringContaining "api/api/dev/states/myservers.cfg",
64-
"/boot/config/plugins/dynamix.my.servers/env",
65-
"./dev/Unraid.net/fb_keepalive",
66-
StringContaining "api/api/dev/Unraid.net",
67-
StringContaining "api/api/dev/data/machine-id",
68-
"/var/log/unraid-api",
69-
"/var/log",
70-
"/var/run",
71-
"./dev/sessions",
72-
StringContaining "api/api/dev/keys",
73-
StringContaining "api/api/dev/passwd",
74-
"/var/run/libvirt/libvirtd.pid",
75-
StringContaining "api/api/dev/activation",
76-
"/usr/local/emhttp/webGui/images",
77-
"/boot/config/ident.cfg",
78-
StringContaining "api/api/dev/activation/assets",
79-
StringContaining "api/api/dev/activation/assets/logo.svg",
80-
"/usr/local/emhttp/webGui/images/partner-logo.svg",
81-
StringContaining "api/api/dev/activation/assets/case-model.png",
82-
"/usr/local/emhttp/webGui/images/case-model.png",
83-
StringContaining "api/api/dev/activation/assets/banner.png",
84-
"/usr/local/emhttp/webGui/images/banner.png",
85-
]
86-
`;

api/src/unraid-api/graph/resolvers/customization/__snapshots__/customization.service.spec.ts.snap

Lines changed: 0 additions & 46 deletions
This file was deleted.

api/src/unraid-api/graph/resolvers/customization/customization.service.spec.ts

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -143,41 +143,21 @@ describe('CustomizationService', () => {
143143
});
144144

145145
describe('onModuleInit', () => {
146-
it('should initialize paths from store', async () => {
147-
await service.onModuleInit();
148-
expect((service as any).activationDir).toBe(activationDir);
149-
expect((service as any).configFile).toBe(userDynamixCfg);
150-
expect(loggerLogSpy).toHaveBeenCalledWith(
151-
'CustomizationService initialized with paths from store.'
152-
);
153-
});
154-
155146
it('should log error if dynamix user config path is missing', async () => {
156-
// This test case is difficult to implement correctly without complex mock setup manipulation
157-
// before module creation. We rely on the default mock setup providing valid paths.
158-
// If the path were missing, the service would log an error and potentially fail later.
159-
// We assume the mechanism works but cannot easily isolate this specific error log trigger
160-
// in this setup without modifying the core mocking strategy.
161-
// Skipping direct assertion for now.
162-
163-
// --- NEW IMPLEMENTATION ---
164-
// Mock getters to return paths without dynamix-config[1]
165-
const { getters: originalGetters } = await import('@app/store/index.js');
166-
const originalPaths = originalGetters.paths(); // Get the full mock paths object
167-
const pathsWithoutDynamixUser = {
168-
...originalPaths,
169-
'dynamix-config': [originalPaths['dynamix-config'][0]],
170-
}; // Modify it
171-
vi.mocked(originalGetters.paths).mockReturnValueOnce(pathsWithoutDynamixUser); // Mock the return value
172-
173-
// Re-create service instance to pick up mocked paths during constructor/init phase if applicable
147+
// Temporarily modify mockPaths to simulate missing user config path
148+
const originalPaths = { ...mockPaths };
149+
mockPaths['dynamix-config'] = [mockPaths['dynamix-config'][0]]; // Only keep default config
150+
174151
await service.onModuleInit();
175152

176153
expect(loggerErrorSpy).toHaveBeenCalledWith(
177154
"Could not resolve user dynamix config path (paths['dynamix-config'][1]) from store."
178155
);
179156
// Expect subsequent operations that rely on configFile to potentially fail or not run
180157
expect(fs.writeFile).not.toHaveBeenCalledWith(doneFlag, 'true'); // Setup should bail early
158+
159+
// Restore original paths
160+
mockPaths['dynamix-config'] = originalPaths['dynamix-config'];
181161
});
182162

183163
it('should log error and rethrow non-ENOENT errors during activation dir access', async () => {

0 commit comments

Comments
 (0)