mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-07 16:40:05 +00:00
* Add playwright * Add test:browser command * Remove test examples * Add basic node tests * Add drag node test * Merge workflows * nit * Localize jest * Add local config * Change working dir * Use consistent fonts * Fix emoji fonts * Update github action to save expectation * update on test failure * push to head * Update test expectations [skip ci] --------- Co-authored-by: github-actions <github-actions@github.com>
56 lines
2.2 KiB
TypeScript
56 lines
2.2 KiB
TypeScript
import { test as base, expect } from '@playwright/test';
|
|
import { ComfyPage } from './ComfyPage';
|
|
|
|
const test = base.extend<{ comfyPage: ComfyPage }>({
|
|
comfyPage: async ({ page }, use) => {
|
|
const comfyPage = new ComfyPage(page);
|
|
await comfyPage.goto();
|
|
// Unify font for consistent screenshots.
|
|
await page.addStyleTag({
|
|
url: "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
|
|
});
|
|
await page.addStyleTag({
|
|
url: "https://fonts.googleapis.com/css2?family=Noto+Color+Emoji&family=Roboto+Mono:ital,wght@0,100..700;1,100..700&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
|
|
});
|
|
await page.addStyleTag({
|
|
content: `
|
|
* {
|
|
font-family: 'Roboto Mono', 'Noto Color Emoji';
|
|
}`
|
|
});
|
|
|
|
await page.waitForFunction(() => document.fonts.ready);
|
|
await page.waitForFunction(() => window['app'] != undefined);
|
|
await page.evaluate(() => { window['app']['canvas'].show_info = false; });
|
|
await comfyPage.nextFrame();
|
|
// Reset view to force re-rendering of canvas. So that info fields like fps
|
|
// become hidden.
|
|
await comfyPage.resetView();
|
|
await use(comfyPage);
|
|
},
|
|
});
|
|
|
|
test.describe('Node Interaction', () => {
|
|
test('Can enter prompt', async ({ comfyPage }) => {
|
|
const textBox = comfyPage.widgetTextBox;
|
|
await textBox.click();
|
|
await textBox.fill('Hello World');
|
|
await expect(textBox).toHaveValue('Hello World');
|
|
await textBox.fill('Hello World 2');
|
|
await expect(textBox).toHaveValue('Hello World 2');
|
|
});
|
|
|
|
test('Can highlight selected', async ({ comfyPage }) => {
|
|
await expect(comfyPage.canvas).toHaveScreenshot('deselected-node.png');
|
|
await comfyPage.clickTextEncodeNode1();
|
|
await expect(comfyPage.canvas).toHaveScreenshot('selected-node1.png');
|
|
await comfyPage.clickTextEncodeNode2();
|
|
await expect(comfyPage.canvas).toHaveScreenshot('selected-node2.png');
|
|
});
|
|
|
|
test('Can drag node', async ({ comfyPage }) => {
|
|
await comfyPage.dragNode2();
|
|
await expect(comfyPage.canvas).toHaveScreenshot('dragged-node1.png');
|
|
});
|
|
});
|