This commit is contained in:
@@ -12,12 +12,20 @@ import { test, expect, type Page } from '@playwright/test';
|
||||
// create a custom piece from the sidebar, then edit + save it through the editor.
|
||||
//
|
||||
// Selector grounding (read from the real components):
|
||||
// - PiecesPage.tsx: the "+" button next to the "Custom Pieces" section opens an
|
||||
// inline input with placeholder="piece-name"; Enter creates the piece via
|
||||
// POST /api/pieces and selects it.
|
||||
// - PieceEditor.tsx: a Visual/YAML mode toggle ("Visual" / "YAML" literal
|
||||
// buttons), a <textarea> for the YAML, and a footer "Save" button (enabled
|
||||
// only when dirty). These are English literals, not i18n keys.
|
||||
// - PiecesPage.tsx: the "+" button next to the custom-workflows section opens
|
||||
// an inline input with placeholder="piece-name"; Enter creates the piece via
|
||||
// POST /api/pieces and selects it. The two section headings USED to be
|
||||
// hardcoded English ("Default Workflows" / "Custom Workflows"); issue #1430
|
||||
// moved them behind i18n (pieces.json sidebar.defaultSection/customSection).
|
||||
// This runner's locale is ja-JP, so every assertion on those headings has to
|
||||
// accept both languages -- the same shape as spaces.spec.ts uses for the
|
||||
// Default/Custom section labels. An English-only literal here does not fail
|
||||
// loudly: getByText simply never matches, and a toHaveCount(0) assertion
|
||||
// passes for the wrong reason.
|
||||
// - PieceEditor.tsx: a Visual/YAML mode toggle, a <textarea> for the YAML, and
|
||||
// a footer "Save" button (enabled only when dirty). "YAML" and "Save" are
|
||||
// still literals; "Visual", "Delete" and the read-only badge are i18n
|
||||
// (settings.json pieceEditor.*, common.json delete), so match both languages.
|
||||
// Backend state is verified through GET /api/pieces?source=custom — the same
|
||||
// endpoint the page reads.
|
||||
|
||||
@@ -56,9 +64,9 @@ test('create a custom piece from the sidebar, then edit + save it via the editor
|
||||
await page.goto('/ui?page=pieces');
|
||||
await expect(page).toHaveURL(/[?&]page=pieces(&|$)/);
|
||||
|
||||
// The "Custom Pieces" section + its "+" create affordance render. The "+" is
|
||||
// The custom-workflows section + its "+" create affordance render. The "+" is
|
||||
// the only button in that section header (title=newPieceTitle).
|
||||
await expect(page.getByText('Custom Pieces', { exact: true })).toBeVisible({ timeout: 15_000 });
|
||||
await expect(page.getByText(/^(Custom Workflows|カスタムワークフロー)$/)).toBeVisible({ timeout: 15_000 });
|
||||
const createToggle = page.locator('button[title]').filter({ hasText: '+' }).first();
|
||||
await createToggle.click();
|
||||
|
||||
@@ -139,17 +147,17 @@ test('a built-in piece opens editable for admin (no Delete, Save appears once di
|
||||
const fatalErrors = trackFatalErrors(page);
|
||||
|
||||
await page.goto('/ui?page=pieces');
|
||||
await expect(page.getByText('Default Pieces', { exact: false })).toBeVisible({ timeout: 15_000 });
|
||||
await expect(page.getByText(/^(Default Workflows|標準ワークフロー)$/)).toBeVisible({ timeout: 15_000 });
|
||||
|
||||
// Open the built-in 'chat' piece from the Default Pieces section.
|
||||
// Open the built-in 'chat' piece from the default-workflows section.
|
||||
await page.getByRole('button', { name: /chat/i }).first().click();
|
||||
|
||||
// No readonly badge (this session is admin) and no Delete (built-ins are
|
||||
// never deletable), but the editable footer with Save is present.
|
||||
const saveBtn = page.getByRole('button', { name: 'Save' });
|
||||
await expect(saveBtn).toBeVisible({ timeout: 15_000 });
|
||||
await expect(page.getByText(/read-?only/i)).toHaveCount(0);
|
||||
await expect(page.getByRole('button', { name: 'Delete' })).toHaveCount(0);
|
||||
await expect(page.getByText(/read-?only|読み取り専用/i)).toHaveCount(0);
|
||||
await expect(page.getByRole('button', { name: /^(Delete|削除)$/ })).toHaveCount(0);
|
||||
await expect(saveBtn).toBeDisabled();
|
||||
|
||||
expect(fatalErrors, `fatal errors:\n${fatalErrors.join('\n')}`).toEqual([]);
|
||||
|
||||
Reference in New Issue
Block a user