From e88d8d8756e0728553176d48f7592fba332e1eba Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Tue, 6 Feb 2024 10:43:38 +0100 Subject: [PATCH] Fix vector widget in non-argument literal (#8972) Fix vector widget not appearing in non-argument list literals. Added tests for showing widgets for various literals. --- app/gui2/e2e/collapsingAndEntering.spec.ts | 4 ++-- app/gui2/e2e/widgets.spec.ts | 17 +++++++++++++++++ app/gui2/mock/engine.ts | 1 + app/gui2/playwright.config.ts | 2 +- .../GraphEditor/widgets/WidgetVector.vue | 8 +++++--- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/gui2/e2e/collapsingAndEntering.spec.ts b/app/gui2/e2e/collapsingAndEntering.spec.ts index 4da218f00d..bb831c617f 100644 --- a/app/gui2/e2e/collapsingAndEntering.spec.ts +++ b/app/gui2/e2e/collapsingAndEntering.spec.ts @@ -86,13 +86,13 @@ test('Collapsing nodes', async ({ page }) => { const secondCollapsedNode = locate.graphNodeByBinding(page, 'ten') await expect(secondCollapsedNode.locator('.WidgetToken')).toHaveText(['Main', '.', 'collapsed1']) await mockCollapsedFunctionInfo(page, 'ten', 'collapsed1') - secondCollapsedNode.dblclick() + await secondCollapsedNode.dblclick() await expect(locate.graphNode(page)).toHaveCount(2) await customExpect.toExist(locate.graphNodeByBinding(page, 'ten')) }) async function expectInsideMain(page: Page) { - await expect(locate.graphNode(page)).toHaveCount(9) + await expect(locate.graphNode(page)).toHaveCount(10) await customExpect.toExist(locate.graphNodeByBinding(page, 'five')) await customExpect.toExist(locate.graphNodeByBinding(page, 'ten')) await customExpect.toExist(locate.graphNodeByBinding(page, 'sum')) diff --git a/app/gui2/e2e/widgets.spec.ts b/app/gui2/e2e/widgets.spec.ts index 325f220e95..4e5fe95db3 100644 --- a/app/gui2/e2e/widgets.spec.ts +++ b/app/gui2/e2e/widgets.spec.ts @@ -27,6 +27,23 @@ class DropDownLocator { } } +test('Widget in plain AST', async ({ page }) => { + await actions.goToGraph(page) + const numberNode = locate.graphNodeByBinding(page, 'five') + const numberWidget = numberNode.locator('.WidgetNumber') + await expect(numberWidget).toBeVisible() + await expect(numberWidget.locator('.value')).toHaveValue('5') + + const listNode = locate.graphNodeByBinding(page, 'list') + const listWidget = listNode.locator('.WidgetVector') + await expect(listWidget).toBeVisible() + + const textNode = locate.graphNodeByBinding(page, 'text') + const textWidget = textNode.locator('.WidgetText') + await expect(textWidget).toBeVisible() + await expect(textWidget.locator('.value')).toHaveValue("'test'") +}) + test('Selection widgets in Data.read node', async ({ page }) => { await actions.goToGraph(page) await mockMethodCallInfo(page, 'data', { diff --git a/app/gui2/mock/engine.ts b/app/gui2/mock/engine.ts index eb111c4683..56a4ec06d6 100644 --- a/app/gui2/mock/engine.ts +++ b/app/gui2/mock/engine.ts @@ -58,6 +58,7 @@ main = prod = sum * 3 final = Main.func1 prod list = [] + text = 'test' # Widget tests data = Data.read diff --git a/app/gui2/playwright.config.ts b/app/gui2/playwright.config.ts index 34ac1008dc..0f422173a2 100644 --- a/app/gui2/playwright.config.ts +++ b/app/gui2/playwright.config.ts @@ -46,7 +46,7 @@ export default defineConfig({ use: { headless: !DEBUG, trace: 'on-first-retry', - viewport: { width: 1920, height: 1200 }, + viewport: { width: 1920, height: 1600 }, ...(DEBUG ? {} : { diff --git a/app/gui2/src/components/GraphEditor/widgets/WidgetVector.vue b/app/gui2/src/components/GraphEditor/widgets/WidgetVector.vue index 50e9cc6e87..c8a56a4e2a 100644 --- a/app/gui2/src/components/GraphEditor/widgets/WidgetVector.vue +++ b/app/gui2/src/components/GraphEditor/widgets/WidgetVector.vue @@ -54,9 +54,11 @@ export const widgetDefinition = defineWidget(WidgetInput.isAstOrPlaceholder, { if (props.input.dynamicConfig?.kind === 'Vector_Editor') return Score.Perfect else if (props.input.expectedType?.startsWith('Standard.Base.Data.Vector.Vector')) return Score.Good - else if (props.input.value instanceof Ast.Ast) - return props.input.value.children().next().value.code === '[' ? Score.Perfect : Score.Mismatch - else return Score.Mismatch + else if (props.input.value instanceof Ast.Ast) { + return props.input.value.children().next().value.code() === '[' + ? Score.Perfect + : Score.Mismatch + } else return Score.Mismatch }, })