update unit tests

This commit is contained in:
Nate Kelley 2025-08-05 10:22:53 -06:00
parent 1ef0d18c61
commit 9b7921c38a
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
5 changed files with 52 additions and 19 deletions

View File

@ -1,5 +1,6 @@
import fs from 'node:fs'; import fs from 'node:fs';
import path from 'node:path'; import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig, devices } from '@playwright/test'; import { defineConfig, devices } from '@playwright/test';
/** /**
@ -38,8 +39,16 @@ export default defineConfig({
/* Run tests in headed mode (non-headless) */ /* Run tests in headed mode (non-headless) */
headless: true, headless: true,
/* Use stored auth state only if it exists */ /* Use stored auth state only if it exists */
storageState: fs.existsSync(path.join(__dirname, 'playwright-tests/auth-utils/auth.json')) storageState: fs.existsSync(
? path.join(__dirname, 'playwright-tests/auth-utils/auth.json') path.join(
path.dirname(fileURLToPath(import.meta.url)),
'playwright-tests/auth-utils/auth.json'
)
)
? path.join(
path.dirname(fileURLToPath(import.meta.url)),
'playwright-tests/auth-utils/auth.json'
)
: undefined : undefined
}, },

View File

@ -20,7 +20,7 @@ describe('Chat API Requests', () => {
const mockChats: ChatListItem[] = [ const mockChats: ChatListItem[] = [
{ {
id: 'test-chat-1', id: 'test-chat-1',
title: 'Test Chat 1', name: 'Test Chat 1',
created_at: '2024-03-20T00:00:00Z', created_at: '2024-03-20T00:00:00Z',
updated_at: '2024-03-20T00:00:00Z', updated_at: '2024-03-20T00:00:00Z',
is_favorited: false, is_favorited: false,

View File

@ -8,6 +8,26 @@ interface ThemeWrapperProps extends React.ComponentProps<'div'> {
defaultTheme?: string; defaultTheme?: string;
} }
/**
* Theme overrides for the report editor
*
* We need to override the default theme for the report editor because:
*
* 1. **Consistent Styling**: The report editor needs to maintain consistent
* appearance regardless of the parent application's theme (light/dark mode)
*
* 2. **Design System Isolation**: Reports should render with their own design
* system to ensure they look the same when shared, exported, or embedded
*
* 3. **Theme Reset**: We reset CSS variables and styles to prevent inheritance
* from parent components that might interfere with report rendering
*
* 4. **Cross-Environment Consistency**: Reports need to look identical whether
* viewed in the editor, shared via link, or exported as PDF/image
*
* The EDITOR_THEME combines light theme colors with reset styles to create
* a clean, controlled environment for report content.
*/
const EDITOR_THEME = { ...THEME_RESET_COLORS.light, ...THEME_RESET_STYLE }; const EDITOR_THEME = { ...THEME_RESET_COLORS.light, ...THEME_RESET_STYLE };
export function ThemeWrapper({ children, className, defaultTheme }: ThemeWrapperProps) { export function ThemeWrapper({ children, className, defaultTheme }: ThemeWrapperProps) {

View File

@ -4,9 +4,11 @@ import type { ChatURLParsed } from './parsePathnameSegments';
describe('createSelectedFile', () => { describe('createSelectedFile', () => {
it('returns a metric file when metricId is provided', () => { it('returns a metric file when metricId is provided', () => {
const params: ChatURLParsed = { const params = {
metricId: 'metric-123' metricId: 'metric-123',
}; collectionId: 'collection-123',
datasetId: 'dataset-123'
} as Parameters<typeof createSelectedFile>[0];
const result = createSelectedFile(params); const result = createSelectedFile(params);
@ -17,9 +19,9 @@ describe('createSelectedFile', () => {
}); });
it('returns a dashboard file when dashboardId is provided', () => { it('returns a dashboard file when dashboardId is provided', () => {
const params: ChatURLParsed = { const params = {
dashboardId: 'dashboard-456' dashboardId: 'dashboard-456'
}; } as Parameters<typeof createSelectedFile>[0];
const result = createSelectedFile(params); const result = createSelectedFile(params);
@ -30,9 +32,9 @@ describe('createSelectedFile', () => {
}); });
it('returns a reasoning file when messageId is provided', () => { it('returns a reasoning file when messageId is provided', () => {
const params: ChatURLParsed = { const params = {
messageId: 'message-789' messageId: 'message-789'
}; } as Parameters<typeof createSelectedFile>[0];
const result = createSelectedFile(params); const result = createSelectedFile(params);
@ -43,11 +45,11 @@ describe('createSelectedFile', () => {
}); });
it('returns null when no relevant id is provided', () => { it('returns null when no relevant id is provided', () => {
const params: ChatURLParsed = { const params = {
chatId: 'chat-123', chatId: 'chat-123',
collectionId: 'collection-123', collectionId: 'collection-123',
datasetId: 'dataset-123' datasetId: 'dataset-123'
}; } as Parameters<typeof createSelectedFile>[0];
const result = createSelectedFile(params); const result = createSelectedFile(params);
@ -55,7 +57,7 @@ describe('createSelectedFile', () => {
}); });
it('returns null when params object is empty', () => { it('returns null when params object is empty', () => {
const params: ChatURLParsed = {}; const params = {} as Parameters<typeof createSelectedFile>[0];
const result = createSelectedFile(params); const result = createSelectedFile(params);
@ -63,11 +65,11 @@ describe('createSelectedFile', () => {
}); });
it('prioritizes metricId over other ids', () => { it('prioritizes metricId over other ids', () => {
const params: ChatURLParsed = { const params = {
metricId: 'metric-123', metricId: 'metric-123',
dashboardId: 'dashboard-456', dashboardId: 'dashboard-456',
messageId: 'message-789' messageId: 'message-789'
}; } as Parameters<typeof createSelectedFile>[0];
const result = createSelectedFile(params); const result = createSelectedFile(params);
@ -78,10 +80,10 @@ describe('createSelectedFile', () => {
}); });
it('prioritizes dashboardId over messageId when metricId is not provided', () => { it('prioritizes dashboardId over messageId when metricId is not provided', () => {
const params: ChatURLParsed = { const params = {
dashboardId: 'dashboard-456', dashboardId: 'dashboard-456',
messageId: 'message-789' messageId: 'message-789'
}; } as Parameters<typeof createSelectedFile>[0];
const result = createSelectedFile(params); const result = createSelectedFile(params);

View File

@ -41,8 +41,10 @@ describe('useSelectedFile', () => {
currentRoute: BusterRoutes.APP_CHAT_ID, currentRoute: BusterRoutes.APP_CHAT_ID,
secondaryView: undefined as FileViewSecondary | undefined, secondaryView: undefined as FileViewSecondary | undefined,
metricVersionNumber: undefined, metricVersionNumber: undefined,
dashboardVersionNumber: undefined dashboardVersionNumber: undefined,
}; reportId: undefined,
reportVersionNumber: undefined
} satisfies Parameters<typeof useSelectedFile>[0]['chatParams'];
beforeEach(() => { beforeEach(() => {
vi.clearAllMocks(); vi.clearAllMocks();