Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

2.2 KB
Raw Blame
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { openPanel } from './panels';

/**
 * The panels share one empty card: a bordered box with a circular icon, a title
 * and a line of explanation. The prompts panel drew its own copy of it, a shade
 * off on the border, so an empty prompts list did not look like an empty
 * bookmarks or memories list.
 */

type CardStyle = {
  borderColor: string;
  borderWidth: string;
  borderRadius: string;
  padding: string;
  textAlign: string;
  iconBackground: string;
};

test.describe('empty panel cards', () => {
  test('the empty prompts panel is drawn like the other panels @scenario:empty-prompts-panel-matches-other-panels', async ({
    page,
  }) => {
    await page.route('**/api/tags', (route) => route.fulfill({ json: [] }));
    await page.route('**/api/prompts/groups?**', (route) =>
      route.fulfill({
        json: { promptGroups: [], pageNumber: '1', pageSize: '10', pages: 0, has_more: false },
      }),
    );
    await page.goto('/c/new', { timeout: 10000 });

    const prompts = await openPanelCard(page, 'Prompts', 'No prompts yet');
    const bookmarks = await openPanelCard(page, 'Bookmarks', 'No bookmarks yet');

    expect(prompts).toEqual(bookmarks);
  });
});

/** Open a side panel from the rail and measure the empty card it renders. */
async function openPanelCard(page: Page, panel: string, title: string): Promise<CardStyle> {
  await openPanel(page, panel.toLowerCase(), panel);
  await expect(page.getByText(title, { exact: true }).first()).toBeVisible({ timeout: 20000 });

  return page.evaluate((heading) => {
    const label = Array.from(document.querySelectorAll('p')).find(
      (node) => node.textContent?.trim() === heading,
    );
    const card = label?.parentElement;
    const icon = card?.firstElementChild;
    if (!card || !icon) {
      throw new Error(`the ${heading} card is not rendered`);
    }
    const style = getComputedStyle(card);
    return {
      borderColor: style.borderColor,
      borderWidth: style.borderWidth,
      borderRadius: style.borderRadius,
      padding: style.padding,
      textAlign: style.textAlign,
      iconBackground: getComputedStyle(icon).backgroundColor,
    };
  }, title);
}