| import { Page, Locator } from '@playwright/test'; |
| import { clickElement } from '../core/interactions'; |
| import { navigateToSpec } from '../navigation/views'; |
|
|
| |
| |
| |
| export async function getSpecEditor(page: Page): Promise<Locator> { |
| return page.locator('[data-testid="spec-editor"]'); |
| } |
|
|
| |
| |
| |
| export async function getSpecEditorContent(page: Page): Promise<string> { |
| const editor = await getSpecEditor(page); |
| return await editor.inputValue(); |
| } |
|
|
| |
| |
| |
| export async function setSpecEditorContent(page: Page, content: string): Promise<void> { |
| const editor = await getSpecEditor(page); |
| await editor.fill(content); |
| } |
|
|
| |
| |
| |
| export async function clickSaveSpec(page: Page): Promise<void> { |
| await clickElement(page, 'save-spec'); |
| } |
|
|
| |
| |
| |
| export async function clickReloadSpec(page: Page): Promise<void> { |
| await clickElement(page, 'reload-spec'); |
| } |
|
|
| |
| |
| |
| export async function getDisplayedSpecPath(page: Page): Promise<string | null> { |
| const specView = page.locator('[data-testid="spec-view"]'); |
| const pathElement = specView.locator('p.text-muted-foreground').first(); |
| return await pathElement.textContent(); |
| } |
|
|
| |
| |
| |
| export async function navigateToSpecEditor(page: Page): Promise<void> { |
| await navigateToSpec(page); |
| } |
|
|
| |
| |
| |
| |
| export async function getEditorContent(page: Page): Promise<string> { |
| |
| |
| const contentElement = page.locator('[data-testid="spec-editor"] .cm-content'); |
| await contentElement.waitFor({ state: 'visible', timeout: 10000 }); |
|
|
| |
| const content = await contentElement.textContent(); |
| return content || ''; |
| } |
|
|
| |
| |
| |
| export async function setEditorContent(page: Page, content: string): Promise<void> { |
| |
| const editor = page.locator('[data-testid="spec-editor"] .cm-content'); |
| await editor.click(); |
|
|
| |
| await page.waitForTimeout(200); |
|
|
| |
| const isMac = process.platform === 'darwin'; |
| await page.keyboard.press(isMac ? 'Meta+a' : 'Control+a'); |
|
|
| |
| await page.waitForTimeout(100); |
|
|
| |
| await page.keyboard.press('Backspace'); |
|
|
| |
| await page.waitForTimeout(100); |
|
|
| |
| await page.keyboard.type(content, { delay: 10 }); |
|
|
| |
| await page.waitForTimeout(200); |
| } |
|
|
| |
| |
| |
| export async function clickSaveButton(page: Page): Promise<void> { |
| const saveButton = page.locator('[data-testid="save-spec"]'); |
| await saveButton.click(); |
|
|
| |
| await page.waitForFunction( |
| () => { |
| const btn = document.querySelector('[data-testid="save-spec"]'); |
| return btn?.textContent?.includes('Saved'); |
| }, |
| { timeout: 5000 } |
| ); |
| } |
|
|