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.
This commit is contained in:
Adam Obuchowicz 2024-02-06 10:43:38 +01:00 committed by GitHub
parent 427f5b0410
commit e88d8d8756
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 26 additions and 6 deletions

View File

@ -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'))

View File

@ -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', {

View File

@ -58,6 +58,7 @@ main =
prod = sum * 3
final = Main.func1 prod
list = []
text = 'test'
# Widget tests
data = Data.read

View File

@ -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
? {}
: {

View File

@ -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
},
})
</script>