From 7b86611f358dcc4af55e63332cade62e91c135f1 Mon Sep 17 00:00:00 2001 From: cameronapak Date: Tue, 22 Jul 2025 08:58:30 -0500 Subject: [PATCH] bun run format --- .../ui/client/utils/AppReduced.spec.ts | 234 +++++++++--------- app/src/ui/client/BkndProvider.tsx | 7 +- app/src/ui/client/utils/AppReduced.ts | 14 +- app/src/ui/main.css | 2 +- app/tsconfig.build.json | 18 +- 5 files changed, 139 insertions(+), 136 deletions(-) diff --git a/app/__test__/ui/client/utils/AppReduced.spec.ts b/app/__test__/ui/client/utils/AppReduced.spec.ts index 355170e..ca80c2e 100644 --- a/app/__test__/ui/client/utils/AppReduced.spec.ts +++ b/app/__test__/ui/client/utils/AppReduced.spec.ts @@ -1,11 +1,11 @@ -import { describe, it, expect, beforeEach } from 'vitest'; -import { AppReduced, type AppType } from 'ui/client/utils/AppReduced'; -import type { BkndAdminOptions } from 'ui/client/BkndProvider'; +import { describe, it, expect, beforeEach } from "vitest"; +import { AppReduced, type AppType } from "ui/client/utils/AppReduced"; +import type { BkndAdminOptions } from "ui/client/BkndProvider"; // Import the normalizeAdminPath function for testing // Note: This assumes the function is exported or we need to test it indirectly through public methods -describe('AppReduced', () => { +describe("AppReduced", () => { let mockAppJson: AppType; let appReduced: AppReduced; @@ -13,219 +13,219 @@ describe('AppReduced', () => { mockAppJson = { data: { entities: {}, - relations: {} + relations: {}, }, flows: { - flows: {} + flows: {}, }, - auth: {} + auth: {}, } as AppType; }); - describe('getSettingsPath', () => { - it('should return settings path with admin_basepath', () => { + describe("getSettingsPath", () => { + it("should return settings path with admin_basepath", () => { const options: BkndAdminOptions = { - admin_basepath: '/admin', - logo_return_path: '/' + admin_basepath: "/admin", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); const result = appReduced.getSettingsPath(); - - expect(result).toBe('~/admin/settings'); + + expect(result).toBe("~/admin/settings"); }); - it('should return settings path with empty admin_basepath', () => { + it("should return settings path with empty admin_basepath", () => { const options: BkndAdminOptions = { - admin_basepath: '', - logo_return_path: '/' + admin_basepath: "", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); const result = appReduced.getSettingsPath(); - - expect(result).toBe('~/settings'); + + expect(result).toBe("~/settings"); }); - it('should append additional path segments', () => { + it("should append additional path segments", () => { const options: BkndAdminOptions = { - admin_basepath: '/admin', - logo_return_path: '/' + admin_basepath: "/admin", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); - const result = appReduced.getSettingsPath(['user', 'profile']); - - expect(result).toBe('~/admin/settings/user/profile'); + const result = appReduced.getSettingsPath(["user", "profile"]); + + expect(result).toBe("~/admin/settings/user/profile"); }); - it('should normalize multiple slashes', () => { + it("should normalize multiple slashes", () => { const options: BkndAdminOptions = { - admin_basepath: '//admin//', - logo_return_path: '/' + admin_basepath: "//admin//", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); - const result = appReduced.getSettingsPath(['//user//']); - - expect(result).toBe('~/admin/settings/user'); + const result = appReduced.getSettingsPath(["//user//"]); + + expect(result).toBe("~/admin/settings/user"); }); - it('should handle admin_basepath without leading slash', () => { + it("should handle admin_basepath without leading slash", () => { const options: BkndAdminOptions = { - admin_basepath: 'admin', - logo_return_path: '/' + admin_basepath: "admin", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); const result = appReduced.getSettingsPath(); - - expect(result).toBe('~/admin/settings'); + + expect(result).toBe("~/admin/settings"); }); }); - describe('getAbsolutePath', () => { - it('should return absolute path with admin_basepath', () => { + describe("getAbsolutePath", () => { + it("should return absolute path with admin_basepath", () => { const options: BkndAdminOptions = { - admin_basepath: '/admin', - logo_return_path: '/' + admin_basepath: "/admin", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); - const result = appReduced.getAbsolutePath('dashboard'); - - expect(result).toBe('~/admin/dashboard'); + const result = appReduced.getAbsolutePath("dashboard"); + + expect(result).toBe("~/admin/dashboard"); }); - it('should return base path when no path provided', () => { + it("should return base path when no path provided", () => { const options: BkndAdminOptions = { - admin_basepath: '/admin', - logo_return_path: '/' + admin_basepath: "/admin", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); const result = appReduced.getAbsolutePath(); - - expect(result).toBe('~/admin'); + + expect(result).toBe("~/admin"); }); - it('should normalize paths correctly', () => { + it("should normalize paths correctly", () => { const options: BkndAdminOptions = { - admin_basepath: '//admin//', - logo_return_path: '/' + admin_basepath: "//admin//", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); - const result = appReduced.getAbsolutePath('//dashboard//'); - - expect(result).toBe('~/admin/dashboard'); + const result = appReduced.getAbsolutePath("//dashboard//"); + + expect(result).toBe("~/admin/dashboard"); }); }); - describe('options getter', () => { - it('should return merged options with defaults', () => { + describe("options getter", () => { + it("should return merged options with defaults", () => { const customOptions: BkndAdminOptions = { - admin_basepath: '/custom-admin', - logo_return_path: '/custom-home' + admin_basepath: "/custom-admin", + logo_return_path: "/custom-home", }; - + appReduced = new AppReduced(mockAppJson, customOptions); const options = appReduced.options; - + expect(options).toEqual({ - logo_return_path: '/custom-home', - admin_basepath: '/custom-admin' + logo_return_path: "/custom-home", + admin_basepath: "/custom-admin", }); }); - it('should use default logo_return_path when not provided', () => { + it("should use default logo_return_path when not provided", () => { const customOptions: BkndAdminOptions = { - admin_basepath: '/admin' + admin_basepath: "/admin", }; - + appReduced = new AppReduced(mockAppJson, customOptions); const options = appReduced.options; - - expect(options.logo_return_path).toBe('/'); - expect(options.admin_basepath).toBe('/admin'); + + expect(options.logo_return_path).toBe("/"); + expect(options.admin_basepath).toBe("/admin"); }); }); - describe('path normalization behavior', () => { - it('should normalize duplicate slashes in settings path', () => { + describe("path normalization behavior", () => { + it("should normalize duplicate slashes in settings path", () => { const options: BkndAdminOptions = { - admin_basepath: '/admin', - logo_return_path: '/' + admin_basepath: "/admin", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); - const result = appReduced.getSettingsPath(['//nested//path//']); - - expect(result).toBe('~/admin/settings/nested/path'); + const result = appReduced.getSettingsPath(["//nested//path//"]); + + expect(result).toBe("~/admin/settings/nested/path"); }); - it('should handle root path normalization', () => { + it("should handle root path normalization", () => { const options: BkndAdminOptions = { - admin_basepath: '/', - logo_return_path: '/' + admin_basepath: "/", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); const result = appReduced.getAbsolutePath(); - + // The normalizeAdminPath function removes trailing slashes except for root "/" // When admin_basepath is "/", the result is "~/" which becomes "~" after normalization - expect(result).toBe('~'); + expect(result).toBe("~"); }); - it('should preserve entity paths ending with slash', () => { + it("should preserve entity paths ending with slash", () => { const options: BkndAdminOptions = { - admin_basepath: '/admin', - logo_return_path: '/' + admin_basepath: "/admin", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); - const result = appReduced.getAbsolutePath('entity/'); - - expect(result).toBe('~/admin/entity/'); + const result = appReduced.getAbsolutePath("entity/"); + + expect(result).toBe("~/admin/entity/"); }); - it('should remove trailing slashes from non-entity paths', () => { + it("should remove trailing slashes from non-entity paths", () => { const options: BkndAdminOptions = { - admin_basepath: '/admin', - logo_return_path: '/' + admin_basepath: "/admin", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); - const result = appReduced.getAbsolutePath('dashboard/'); - - expect(result).toBe('~/admin/dashboard'); + const result = appReduced.getAbsolutePath("dashboard/"); + + expect(result).toBe("~/admin/dashboard"); }); }); - describe('edge cases', () => { - it('should handle undefined admin_basepath', () => { + describe("edge cases", () => { + it("should handle undefined admin_basepath", () => { const options: BkndAdminOptions = { - logo_return_path: '/' + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); const result = appReduced.getSettingsPath(); - + // When admin_basepath is undefined, it defaults to empty string - expect(result).toBe('~/settings'); + expect(result).toBe("~/settings"); }); - it('should handle null path segments', () => { + it("should handle null path segments", () => { const options: BkndAdminOptions = { - admin_basepath: '/admin', - logo_return_path: '/' + admin_basepath: "/admin", + logo_return_path: "/", }; - + appReduced = new AppReduced(mockAppJson, options); - const result = appReduced.getSettingsPath(['', 'valid', '']); - - expect(result).toBe('~/admin/settings/valid'); + const result = appReduced.getSettingsPath(["", "valid", ""]); + + expect(result).toBe("~/admin/settings/valid"); }); }); -}); \ No newline at end of file +}); diff --git a/app/src/ui/client/BkndProvider.tsx b/app/src/ui/client/BkndProvider.tsx index a6e09ff..ad0e154 100644 --- a/app/src/ui/client/BkndProvider.tsx +++ b/app/src/ui/client/BkndProvider.tsx @@ -8,9 +8,12 @@ import { Message } from "ui/components/display/Message"; import { useNavigate } from "ui/lib/routes"; import type { AdminBkndWindowContext } from "modules/server/AdminController"; -export type BkndAdminOptions = Omit & { +export type BkndAdminOptions = Omit< + AdminBkndWindowContext, + "user" | "logout_route" | "admin_basepath" +> & { admin_basepath?: string; -} +}; type BkndContext = { version: number; schema: ModuleSchemas; diff --git a/app/src/ui/client/utils/AppReduced.ts b/app/src/ui/client/utils/AppReduced.ts index 2b703d2..11ead1b 100644 --- a/app/src/ui/client/utils/AppReduced.ts +++ b/app/src/ui/client/utils/AppReduced.ts @@ -36,8 +36,8 @@ export class AppReduced { constructor( protected appJson: AppType, protected _options: BkndAdminOptions = { - admin_basepath: '', - logo_return_path: '/' + admin_basepath: "", + logo_return_path: "/", }, ) { //console.log("received appjson", appJson); @@ -88,20 +88,20 @@ export class AppReduced { get options() { return { - admin_basepath: '', - logo_return_path: '/', + admin_basepath: "", + logo_return_path: "/", ...this._options, }; } getSettingsPath(path: string[] = []): string { - const basePath = this.options.admin_basepath ? `~/${this.options.admin_basepath}` : '~'; - const base = `${basePath}/settings` + const basePath = this.options.admin_basepath ? `~/${this.options.admin_basepath}` : "~"; + const base = `${basePath}/settings`; return normalizeAdminPath([base, ...path].join("/")); } getAbsolutePath(path?: string): string { - const basePath = this.options.admin_basepath ? `~/${this.options.admin_basepath}` : '~'; + const basePath = this.options.admin_basepath ? `~/${this.options.admin_basepath}` : "~"; return normalizeAdminPath(path ? `${basePath}/${path}` : basePath); } diff --git a/app/src/ui/main.css b/app/src/ui/main.css index 280e49d..28cca2d 100644 --- a/app/src/ui/main.css +++ b/app/src/ui/main.css @@ -18,7 +18,7 @@ --color-success-foreground: var(--color-green-800); --color-info: var(--color-blue-100); --color-info-foreground: var(--color-blue-800); - + --color-resize: var(--color-blue-300); @mixin light { diff --git a/app/tsconfig.build.json b/app/tsconfig.build.json index 31ea592..4d813b1 100644 --- a/app/tsconfig.build.json +++ b/app/tsconfig.build.json @@ -1,11 +1,11 @@ { - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./dist/types", - "rootDir": "./src", - "baseUrl": ".", - "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" - }, - "include": ["./src/**/*.ts", "./src/**/*.tsx"], - "exclude": ["./node_modules", "./__test__", "./e2e"] + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./dist/types", + "rootDir": "./src", + "baseUrl": ".", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" + }, + "include": ["./src/**/*.ts", "./src/**/*.tsx"], + "exclude": ["./node_modules", "./__test__", "./e2e"] }