Restore settings preferences and simplify services editor

This commit is contained in:
2026-04-02 01:25:38 +03:00
parent 91856beec9
commit f5ae311a82
16 changed files with 934 additions and 333 deletions

View File

@@ -69,13 +69,13 @@ describe('panel api', () => {
expect(typeof response.body.expiresAt).toBe('string');
});
it('rejects user creation against a non-assignable service', async () => {
it('rejects user creation against a disabled service', async () => {
const app = await createTestApp();
const token = await authorize(app);
const response = await request(app).post('/api/users').set('Authorization', `Bearer ${token}`).send({
username: 'bad-admin-user',
username: 'bad-proxy-user',
password: 'secret123',
serviceId: 'admin',
serviceId: 'proxy',
quotaMb: 100,
});
@@ -132,6 +132,26 @@ describe('panel api', () => {
expect(response.body.error).toMatch(/night-shift/i);
});
it('removes linked users when a service is deleted from settings', async () => {
const app = await createTestApp();
const token = await authorize(app);
const initial = await request(app).get('/api/state').set('Authorization', `Bearer ${token}`);
const system = createSystemPayload(initial.body);
system.services = system.services.filter((service) => service.id !== 'socks-main');
const response = await request(app).put('/api/system').set('Authorization', `Bearer ${token}`).send(system);
expect(response.status).toBe(200);
expect(response.body.userRecords.some((entry: { username: string }) => entry.username === 'night-shift')).toBe(
false,
);
expect(response.body.userRecords.some((entry: { username: string }) => entry.username === 'ops-east')).toBe(
false,
);
expect(response.body.service.lastEvent).toMatch(/removed 2 linked users/i);
});
it('updates system settings and regenerates the rendered config', async () => {
const app = await createTestApp();
const token = await authorize(app);