mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 20:43:36 +00:00
simplify the e2e tests
This commit is contained in:
67
apps/ui/tests/context/context-file-management.spec.ts
Normal file
67
apps/ui/tests/context/context-file-management.spec.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Context File Management E2E Test
|
||||
*
|
||||
* Happy path: Create a markdown context file
|
||||
*/
|
||||
|
||||
import { test, expect } from '@playwright/test';
|
||||
import {
|
||||
resetContextDirectory,
|
||||
setupProjectWithFixture,
|
||||
getFixturePath,
|
||||
navigateToContext,
|
||||
waitForFileContentToLoad,
|
||||
switchToEditMode,
|
||||
waitForContextFile,
|
||||
clickElement,
|
||||
fillInput,
|
||||
getByTestId,
|
||||
waitForNetworkIdle,
|
||||
getContextEditorContent,
|
||||
} from '../utils';
|
||||
|
||||
test.describe('Context File Management', () => {
|
||||
test.beforeEach(async () => {
|
||||
resetContextDirectory();
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
resetContextDirectory();
|
||||
});
|
||||
|
||||
test('should create a new markdown context file', async ({ page }) => {
|
||||
await setupProjectWithFixture(page, getFixturePath());
|
||||
await page.goto('/');
|
||||
await waitForNetworkIdle(page);
|
||||
|
||||
await navigateToContext(page);
|
||||
|
||||
await clickElement(page, 'create-markdown-button');
|
||||
await page.waitForSelector('[data-testid="create-markdown-dialog"]', { timeout: 5000 });
|
||||
|
||||
await fillInput(page, 'new-markdown-name', 'test-context.md');
|
||||
const testContent = '# Test Context\n\nThis is test content';
|
||||
await fillInput(page, 'new-markdown-content', testContent);
|
||||
|
||||
await clickElement(page, 'confirm-create-markdown');
|
||||
|
||||
await page.waitForFunction(
|
||||
() => !document.querySelector('[data-testid="create-markdown-dialog"]'),
|
||||
{ timeout: 5000 }
|
||||
);
|
||||
|
||||
await waitForContextFile(page, 'test-context.md', 10000);
|
||||
|
||||
const fileButton = await getByTestId(page, 'context-file-test-context.md');
|
||||
await expect(fileButton).toBeVisible();
|
||||
|
||||
await fileButton.click();
|
||||
await waitForFileContentToLoad(page);
|
||||
await switchToEditMode(page);
|
||||
|
||||
await page.waitForSelector('[data-testid="context-editor"]', { timeout: 5000 });
|
||||
|
||||
const editorContent = await getContextEditorContent(page);
|
||||
expect(editorContent).toBe(testContent);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user