From d26ca4944f0bd700e24a29ffaf40fa0fd5c27a6b Mon Sep 17 00:00:00 2001 From: christian-byrne Date: Mon, 6 Jan 2025 12:42:33 -0700 Subject: [PATCH] Add browser test --- browser_tests/dialog.spec.ts | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/browser_tests/dialog.spec.ts b/browser_tests/dialog.spec.ts index d7dcfda2e..ea856091d 100644 --- a/browser_tests/dialog.spec.ts +++ b/browser_tests/dialog.spec.ts @@ -1,5 +1,6 @@ import { expect } from '@playwright/test' +import { Keybinding } from '../src/types/keyBindingTypes' import { comfyPageFixture as test } from './fixtures/ComfyPage' test.describe('Load workflow warning', () => { @@ -103,4 +104,52 @@ test.describe('Settings', () => { expect(await comfyPage.getSetting('Comfy.Graph.ZoomSpeed')).toBe(maxSpeed) }) }) + + test('Should persist keybinding setting', async ({ comfyPage }) => { + // Open the settings dialog + await comfyPage.page.keyboard.press('Control+,') + await comfyPage.page.waitForSelector('.settings-container') + + // Open the keybinding tab + await comfyPage.page.getByLabel('Keybinding').click() + await comfyPage.page.waitForSelector( + '[placeholder="Search Keybindings..."]' + ) + + // Focus the 'New Blank Workflow' row + const newBlankWorkflowRow = comfyPage.page.locator('tr', { + has: comfyPage.page.getByRole('cell', { name: 'New Blank Workflow' }) + }) + await newBlankWorkflowRow.click() + + // Click edit button + const editKeybindingButton = newBlankWorkflowRow.locator('.pi-pencil') + await editKeybindingButton.click() + + // Set new keybinding + const input = comfyPage.page.getByPlaceholder('Press keys for new binding') + await input.press('Alt+n') + + const requestPromise = comfyPage.page.waitForRequest( + '**/api/settings/Comfy.Keybinding.NewBindings' + ) + + // Save keybinding + const saveButton = comfyPage.page + .getByLabel('Comfy.NewBlankWorkflow') + .getByLabel('Save') + await saveButton.click() + + const request = await requestPromise + const expectedSetting: Keybinding = { + commandId: 'Comfy.NewBlankWorkflow', + combo: { + key: 'n', + ctrl: false, + alt: true, + shift: false + } + } + expect(request.postData()).toContain(JSON.stringify(expectedSetting)) + }) })