mirror of https://github.com/buster-so/buster.git
update unit tests
This commit is contained in:
parent
1ef0d18c61
commit
9b7921c38a
|
@ -1,5 +1,6 @@
|
|||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
/**
|
||||
|
@ -38,8 +39,16 @@ export default defineConfig({
|
|||
/* Run tests in headed mode (non-headless) */
|
||||
headless: true,
|
||||
/* Use stored auth state only if it exists */
|
||||
storageState: fs.existsSync(path.join(__dirname, 'playwright-tests/auth-utils/auth.json'))
|
||||
? path.join(__dirname, 'playwright-tests/auth-utils/auth.json')
|
||||
storageState: fs.existsSync(
|
||||
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
|
||||
},
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ describe('Chat API Requests', () => {
|
|||
const mockChats: ChatListItem[] = [
|
||||
{
|
||||
id: 'test-chat-1',
|
||||
title: 'Test Chat 1',
|
||||
name: 'Test Chat 1',
|
||||
created_at: '2024-03-20T00:00:00Z',
|
||||
updated_at: '2024-03-20T00:00:00Z',
|
||||
is_favorited: false,
|
||||
|
|
|
@ -8,6 +8,26 @@ interface ThemeWrapperProps extends React.ComponentProps<'div'> {
|
|||
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 };
|
||||
|
||||
export function ThemeWrapper({ children, className, defaultTheme }: ThemeWrapperProps) {
|
||||
|
|
|
@ -4,9 +4,11 @@ import type { ChatURLParsed } from './parsePathnameSegments';
|
|||
|
||||
describe('createSelectedFile', () => {
|
||||
it('returns a metric file when metricId is provided', () => {
|
||||
const params: ChatURLParsed = {
|
||||
metricId: 'metric-123'
|
||||
};
|
||||
const params = {
|
||||
metricId: 'metric-123',
|
||||
collectionId: 'collection-123',
|
||||
datasetId: 'dataset-123'
|
||||
} as Parameters<typeof createSelectedFile>[0];
|
||||
|
||||
const result = createSelectedFile(params);
|
||||
|
||||
|
@ -17,9 +19,9 @@ describe('createSelectedFile', () => {
|
|||
});
|
||||
|
||||
it('returns a dashboard file when dashboardId is provided', () => {
|
||||
const params: ChatURLParsed = {
|
||||
const params = {
|
||||
dashboardId: 'dashboard-456'
|
||||
};
|
||||
} as Parameters<typeof createSelectedFile>[0];
|
||||
|
||||
const result = createSelectedFile(params);
|
||||
|
||||
|
@ -30,9 +32,9 @@ describe('createSelectedFile', () => {
|
|||
});
|
||||
|
||||
it('returns a reasoning file when messageId is provided', () => {
|
||||
const params: ChatURLParsed = {
|
||||
const params = {
|
||||
messageId: 'message-789'
|
||||
};
|
||||
} as Parameters<typeof createSelectedFile>[0];
|
||||
|
||||
const result = createSelectedFile(params);
|
||||
|
||||
|
@ -43,11 +45,11 @@ describe('createSelectedFile', () => {
|
|||
});
|
||||
|
||||
it('returns null when no relevant id is provided', () => {
|
||||
const params: ChatURLParsed = {
|
||||
const params = {
|
||||
chatId: 'chat-123',
|
||||
collectionId: 'collection-123',
|
||||
datasetId: 'dataset-123'
|
||||
};
|
||||
} as Parameters<typeof createSelectedFile>[0];
|
||||
|
||||
const result = createSelectedFile(params);
|
||||
|
||||
|
@ -55,7 +57,7 @@ describe('createSelectedFile', () => {
|
|||
});
|
||||
|
||||
it('returns null when params object is empty', () => {
|
||||
const params: ChatURLParsed = {};
|
||||
const params = {} as Parameters<typeof createSelectedFile>[0];
|
||||
|
||||
const result = createSelectedFile(params);
|
||||
|
||||
|
@ -63,11 +65,11 @@ describe('createSelectedFile', () => {
|
|||
});
|
||||
|
||||
it('prioritizes metricId over other ids', () => {
|
||||
const params: ChatURLParsed = {
|
||||
const params = {
|
||||
metricId: 'metric-123',
|
||||
dashboardId: 'dashboard-456',
|
||||
messageId: 'message-789'
|
||||
};
|
||||
} as Parameters<typeof createSelectedFile>[0];
|
||||
|
||||
const result = createSelectedFile(params);
|
||||
|
||||
|
@ -78,10 +80,10 @@ describe('createSelectedFile', () => {
|
|||
});
|
||||
|
||||
it('prioritizes dashboardId over messageId when metricId is not provided', () => {
|
||||
const params: ChatURLParsed = {
|
||||
const params = {
|
||||
dashboardId: 'dashboard-456',
|
||||
messageId: 'message-789'
|
||||
};
|
||||
} as Parameters<typeof createSelectedFile>[0];
|
||||
|
||||
const result = createSelectedFile(params);
|
||||
|
||||
|
|
|
@ -41,8 +41,10 @@ describe('useSelectedFile', () => {
|
|||
currentRoute: BusterRoutes.APP_CHAT_ID,
|
||||
secondaryView: undefined as FileViewSecondary | undefined,
|
||||
metricVersionNumber: undefined,
|
||||
dashboardVersionNumber: undefined
|
||||
};
|
||||
dashboardVersionNumber: undefined,
|
||||
reportId: undefined,
|
||||
reportVersionNumber: undefined
|
||||
} satisfies Parameters<typeof useSelectedFile>[0]['chatParams'];
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
|
Loading…
Reference in New Issue