mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-22 15:06:32 +00:00
style: format server and shared with prettier
A mechanical prettier --write over server/src, server/tests, server/scripts and shared/src with the workspaces' .prettierrc; nothing but layout and import order changes, and every file keeps the same set of imports. shared is formatted throughout and its format baseline is empty. The server baseline keeps the 35 files that Prettier would grow past their lint:size limit (they need a split first, which is not a formatting change), and the generated entity files stay as their generator writes them.
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
* (runtime off / no user / inactive plugin) and that the callback always redirects to
|
||||
* an in-app path with the right status, never leaking an error.
|
||||
*/
|
||||
import type { PluginsRepository } from '../../../src/db/repositories/Plugins.repository';
|
||||
import { PluginOAuthController } from '../../../src/nest/plugins/oauth/plugin-oauth.controller';
|
||||
import type { PluginOAuthService } from '../../../src/nest/plugins/oauth/plugin-oauth.service';
|
||||
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
const { pluginsEnabled, getMock } = vi.hoisted(() => ({
|
||||
@@ -12,14 +16,16 @@ const { pluginsEnabled, getMock } = vi.hoisted(() => ({
|
||||
}));
|
||||
vi.mock('../../../src/nest/plugins/kill-switch', () => ({ pluginsEnabled }));
|
||||
|
||||
import { PluginOAuthController } from '../../../src/nest/plugins/oauth/plugin-oauth.controller';
|
||||
import type { PluginOAuthService } from '../../../src/nest/plugins/oauth/plugin-oauth.service';
|
||||
import type { PluginsRepository } from '../../../src/db/repositories/Plugins.repository';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const req = (id?: number) => ({ user: id === undefined ? undefined : { id } }) as any;
|
||||
function fakeRes() {
|
||||
const res = { redirectedTo: '' as string, redirect(loc: string) { res.redirectedTo = loc; return res; } };
|
||||
const res = {
|
||||
redirectedTo: '' as string,
|
||||
redirect(loc: string) {
|
||||
res.redirectedTo = loc;
|
||||
return res;
|
||||
},
|
||||
};
|
||||
return res;
|
||||
}
|
||||
function ctrl(over: Partial<PluginOAuthService> = {}) {
|
||||
@@ -36,7 +42,10 @@ function ctrl(over: Partial<PluginOAuthService> = {}) {
|
||||
}
|
||||
|
||||
describe('PluginOAuthController', () => {
|
||||
beforeEach(() => { pluginsEnabled.mockReturnValue(true); getMock.mockReturnValue({ 1: 1 }); });
|
||||
beforeEach(() => {
|
||||
pluginsEnabled.mockReturnValue(true);
|
||||
getMock.mockReturnValue({ 1: 1 });
|
||||
});
|
||||
|
||||
it('status is gated: runtime off / no user / inactive → not configured', async () => {
|
||||
expect(await ctrl().c.status('p', req(5))).toEqual({ configured: true, connected: false });
|
||||
@@ -60,7 +69,11 @@ describe('PluginOAuthController', () => {
|
||||
expect(okRes.redirectedTo).toBe('/settings?oauth=p:connected');
|
||||
|
||||
const failRes = fakeRes();
|
||||
await ctrl({ completeCallback: vi.fn(async () => { throw new Error('boom'); }) }).c.callback('p', 'code', 'state', undefined, req(5), failRes as never);
|
||||
await ctrl({
|
||||
completeCallback: vi.fn(async () => {
|
||||
throw new Error('boom');
|
||||
}),
|
||||
}).c.callback('p', 'code', 'state', undefined, req(5), failRes as never);
|
||||
expect(failRes.redirectedTo).toBe('/settings?oauth=p:failed'); // never leaks the error
|
||||
|
||||
const denyRes = fakeRes();
|
||||
|
||||
Reference in New Issue
Block a user