2024-03-06 18:34:07 +03:00
|
|
|
import test, { type Locator, type Page } from 'playwright/test'
|
2024-01-26 20:18:27 +03:00
|
|
|
import * as actions from './actions'
|
2024-03-06 18:34:07 +03:00
|
|
|
import { expect } from './customExpect'
|
2024-01-26 20:18:27 +03:00
|
|
|
import { mockMethodCallInfo } from './expressionUpdates'
|
|
|
|
import * as locate from './locate'
|
|
|
|
|
|
|
|
class DropDownLocator {
|
|
|
|
readonly dropDown: Locator
|
|
|
|
readonly items: Locator
|
|
|
|
|
|
|
|
constructor(page: Page) {
|
|
|
|
this.dropDown = page.locator('.dropdownContainer')
|
2024-02-12 13:17:29 +03:00
|
|
|
this.items = this.dropDown.locator('.selectable-item, .selected-item')
|
2024-01-26 20:18:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
async expectVisibleWithOptions(page: Page, options: string[]): Promise<void> {
|
|
|
|
await expect(this.dropDown).toBeVisible()
|
|
|
|
for (const option of options) {
|
|
|
|
await expect(
|
|
|
|
this.items.filter({ has: page.getByText(option, { exact: true }) }),
|
|
|
|
).toBeVisible()
|
|
|
|
}
|
2024-02-02 17:55:22 +03:00
|
|
|
await expect(this.items).toHaveCount(options.length)
|
2024-01-26 20:18:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
async clickOption(page: Page, option: string): Promise<void> {
|
|
|
|
await this.items.filter({ has: page.getByText(option) }).click()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-06 12:43:38 +03:00
|
|
|
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()
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(numberWidget.locator('input')).toHaveValue('5')
|
2024-02-06 12:43:38 +03:00
|
|
|
|
|
|
|
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()
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(textWidget.locator('input')).toHaveValue('test')
|
2024-02-06 12:43:38 +03:00
|
|
|
})
|
|
|
|
|
2024-01-26 20:18:27 +03:00
|
|
|
test('Selection widgets in Data.read node', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
await mockMethodCallInfo(page, 'data', {
|
|
|
|
methodPointer: {
|
|
|
|
module: 'Standard.Base.Data',
|
|
|
|
definedOnType: 'Standard.Base.Data',
|
|
|
|
name: 'read',
|
|
|
|
},
|
|
|
|
notAppliedArguments: [0, 1, 2],
|
|
|
|
})
|
|
|
|
|
|
|
|
const dropDown = new DropDownLocator(page)
|
|
|
|
|
|
|
|
// Check initially visible arguments
|
|
|
|
const node = locate.graphNodeByBinding(page, 'data')
|
|
|
|
const argumentNames = node.locator('.WidgetArgumentName')
|
2024-03-05 17:16:38 +03:00
|
|
|
await expect(argumentNames).toHaveCount(1)
|
|
|
|
|
|
|
|
// Check arguments after selecting node
|
|
|
|
await node.click()
|
2024-01-26 20:18:27 +03:00
|
|
|
await expect(argumentNames).toHaveCount(3)
|
|
|
|
|
|
|
|
// Set value on `on_problems` (static drop-down)
|
|
|
|
const onProblemsArg = argumentNames.filter({ has: page.getByText('on_problems') })
|
|
|
|
await onProblemsArg.click()
|
2024-03-04 15:54:38 +03:00
|
|
|
await dropDown.expectVisibleWithOptions(page, ['Ignore', 'Report_Warning', 'Report_Error'])
|
|
|
|
await dropDown.clickOption(page, 'Report_Error')
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(onProblemsArg.locator('.WidgetToken')).toContainText([
|
2024-01-26 20:18:27 +03:00
|
|
|
'Problem_Behavior',
|
|
|
|
'.',
|
|
|
|
'Report_Error',
|
|
|
|
])
|
|
|
|
|
|
|
|
// Change value on `on_problems`
|
|
|
|
await mockMethodCallInfo(page, 'data', {
|
|
|
|
methodPointer: {
|
|
|
|
module: 'Standard.Base.Data',
|
|
|
|
definedOnType: 'Standard.Base.Data',
|
|
|
|
name: 'read',
|
|
|
|
},
|
|
|
|
notAppliedArguments: [0, 1],
|
|
|
|
})
|
|
|
|
await page.getByText('Report_Error').click()
|
2024-03-04 15:54:38 +03:00
|
|
|
await dropDown.expectVisibleWithOptions(page, ['Ignore', 'Report_Warning', 'Report_Error'])
|
|
|
|
await dropDown.clickOption(page, 'Report_Warning')
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(onProblemsArg.locator('.WidgetToken')).toContainText([
|
2024-01-26 20:18:27 +03:00
|
|
|
'Problem_Behavior',
|
|
|
|
'.',
|
|
|
|
'Report_Warning',
|
|
|
|
])
|
|
|
|
|
|
|
|
// Set value on `path` (dynamic config)
|
|
|
|
const pathArg = argumentNames.filter({ has: page.getByText('path') })
|
|
|
|
await pathArg.click()
|
|
|
|
await expect(page.locator('.dropdownContainer')).toBeVisible()
|
2024-03-14 15:27:15 +03:00
|
|
|
await dropDown.expectVisibleWithOptions(page, ['Choose file…', 'File 1', 'File 2'])
|
2024-03-11 13:56:56 +03:00
|
|
|
await dropDown.clickOption(page, 'File 2')
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(pathArg.locator('.WidgetText > input')).toHaveValue('File 2')
|
2024-01-26 20:18:27 +03:00
|
|
|
|
|
|
|
// Change value on `path` (dynamic config)
|
|
|
|
await mockMethodCallInfo(page, 'data', {
|
|
|
|
methodPointer: {
|
|
|
|
module: 'Standard.Base.Data',
|
|
|
|
definedOnType: 'Standard.Base.Data',
|
|
|
|
name: 'read',
|
|
|
|
},
|
|
|
|
notAppliedArguments: [1],
|
|
|
|
})
|
2024-01-30 17:05:28 +03:00
|
|
|
await page.getByText('path').click()
|
2024-03-14 15:27:15 +03:00
|
|
|
await dropDown.expectVisibleWithOptions(page, ['Choose file…', 'File 1', 'File 2'])
|
2024-03-11 13:56:56 +03:00
|
|
|
await dropDown.clickOption(page, 'File 1')
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(pathArg.locator('.WidgetText > input')).toHaveValue('File 1')
|
2024-01-26 20:18:27 +03:00
|
|
|
})
|
|
|
|
|
2024-03-14 15:27:15 +03:00
|
|
|
test('File Browser widget', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
await mockMethodCallInfo(page, 'data', {
|
|
|
|
methodPointer: {
|
|
|
|
module: 'Standard.Base.Data',
|
|
|
|
definedOnType: 'Standard.Base.Data',
|
|
|
|
name: 'read',
|
|
|
|
},
|
|
|
|
notAppliedArguments: [0, 1, 2],
|
|
|
|
})
|
|
|
|
const dropDown = new DropDownLocator(page)
|
|
|
|
// Wait for arguments to load.
|
|
|
|
const node = locate.graphNodeByBinding(page, 'data')
|
|
|
|
const argumentNames = node.locator('.WidgetArgumentName')
|
|
|
|
await expect(argumentNames).toHaveCount(1)
|
|
|
|
const pathArg = argumentNames.filter({ has: page.getByText('path') })
|
|
|
|
|
|
|
|
await pathArg.click()
|
|
|
|
await dropDown.expectVisibleWithOptions(page, ['Choose file…', 'File 1', 'File 2'])
|
|
|
|
await dropDown.clickOption(page, 'Choose file…')
|
|
|
|
await expect(pathArg.locator('.WidgetText > input')).toHaveValue('/path/to/some/mock/file')
|
|
|
|
})
|
|
|
|
|
2024-01-26 20:18:27 +03:00
|
|
|
test('Managing aggregates in `aggregate` node', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
await mockMethodCallInfo(page, 'aggregated', {
|
|
|
|
methodPointer: {
|
|
|
|
module: 'Standard.Table.Data.Table',
|
|
|
|
definedOnType: 'Standard.Table.Data.Table.Table',
|
|
|
|
name: 'aggregate',
|
|
|
|
},
|
|
|
|
notAppliedArguments: [1, 2, 3],
|
|
|
|
})
|
|
|
|
const dropDown = new DropDownLocator(page)
|
|
|
|
|
|
|
|
// Check initially visible arguments
|
|
|
|
const node = locate.graphNodeByBinding(page, 'aggregated')
|
|
|
|
const argumentNames = node.locator('.WidgetArgumentName')
|
2024-03-05 17:16:38 +03:00
|
|
|
await expect(argumentNames).toHaveCount(1)
|
|
|
|
|
|
|
|
// Check arguments after selecting node
|
|
|
|
await node.click()
|
2024-01-26 20:18:27 +03:00
|
|
|
await expect(argumentNames).toHaveCount(3)
|
|
|
|
|
|
|
|
// Add first aggregate
|
|
|
|
const columnsArg = argumentNames.filter({ has: page.getByText('columns') })
|
|
|
|
await columnsArg.locator('.add-item').click()
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(columnsArg.locator('.WidgetToken')).toContainText([
|
|
|
|
'Aggregate_Column',
|
|
|
|
'.',
|
|
|
|
'Group_By',
|
|
|
|
])
|
2024-01-26 20:18:27 +03:00
|
|
|
await mockMethodCallInfo(
|
|
|
|
page,
|
|
|
|
{
|
|
|
|
binding: 'aggregated',
|
|
|
|
expr: 'Aggregate_Column.Group_By',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
methodPointer: {
|
|
|
|
module: 'Standard.Table.Data.Aggregate_Column',
|
|
|
|
definedOnType: 'Standard.Table.Data.Aggregate_Column.Aggregate_Column',
|
|
|
|
name: 'Group_By',
|
|
|
|
},
|
|
|
|
notAppliedArguments: [0, 1],
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
// Change aggregation type
|
|
|
|
const firstItem = columnsArg.locator('.item > .WidgetPort > .WidgetSelection')
|
|
|
|
await firstItem.click()
|
2024-03-04 15:54:38 +03:00
|
|
|
await dropDown.expectVisibleWithOptions(page, ['Group_By', 'Count', 'Count_Distinct'])
|
|
|
|
await dropDown.clickOption(page, 'Count_Distinct')
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(columnsArg.locator('.WidgetToken')).toContainText([
|
2024-01-26 20:18:27 +03:00
|
|
|
'Aggregate_Column',
|
|
|
|
'.',
|
|
|
|
'Count_Distinct',
|
|
|
|
])
|
|
|
|
await mockMethodCallInfo(
|
|
|
|
page,
|
|
|
|
{
|
|
|
|
binding: 'aggregated',
|
|
|
|
expr: 'Aggregate_Column.Count_Distinct',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
methodPointer: {
|
|
|
|
module: 'Standard.Table.Data.Aggregate_Column',
|
|
|
|
definedOnType: 'Standard.Table.Data.Aggregate_Column.Aggregate_Column',
|
|
|
|
name: 'Count_Distinct',
|
|
|
|
},
|
|
|
|
notAppliedArguments: [0, 1, 2],
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
// Set column
|
|
|
|
const columnArg = firstItem.locator('.WidgetSelection').first()
|
|
|
|
await columnArg.click()
|
2024-03-11 13:56:56 +03:00
|
|
|
await dropDown.expectVisibleWithOptions(page, ['column 1', 'column 2'])
|
|
|
|
await dropDown.clickOption(page, 'column 1')
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(columnsArg.locator('.WidgetToken')).toContainText([
|
2024-01-26 20:18:27 +03:00
|
|
|
'Aggregate_Column',
|
|
|
|
'.',
|
|
|
|
'Count_Distinct',
|
|
|
|
])
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(columnsArg.locator('.WidgetText > input').first()).toHaveValue('column 1')
|
2024-01-26 20:18:27 +03:00
|
|
|
|
|
|
|
// Add another aggregate
|
|
|
|
await columnsArg.locator('.add-item').click()
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(columnsArg.locator('.WidgetToken')).toContainText([
|
2024-01-26 20:18:27 +03:00
|
|
|
'Aggregate_Column',
|
|
|
|
'.',
|
|
|
|
'Count_Distinct',
|
|
|
|
'Aggregate_Column',
|
|
|
|
'.',
|
|
|
|
'Group_By',
|
|
|
|
])
|
|
|
|
await mockMethodCallInfo(
|
|
|
|
page,
|
|
|
|
{
|
|
|
|
binding: 'aggregated',
|
|
|
|
expr: 'Aggregate_Column.Group_By',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
methodPointer: {
|
|
|
|
module: 'Standard.Table.Data.Aggregate_Column',
|
|
|
|
definedOnType: 'Standard.Table.Data.Aggregate_Column.Aggregate_Column',
|
|
|
|
name: 'Group_By',
|
|
|
|
},
|
|
|
|
notAppliedArguments: [0, 1],
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
// Set new aggregate's column
|
|
|
|
const secondItem = columnsArg.locator('.item > .WidgetPort > .WidgetSelection').nth(1)
|
|
|
|
const secondColumnArg = secondItem.locator('.WidgetSelection').first()
|
|
|
|
await secondColumnArg.click()
|
2024-03-11 13:56:56 +03:00
|
|
|
await dropDown.expectVisibleWithOptions(page, ['column 1', 'column 2'])
|
|
|
|
await dropDown.clickOption(page, 'column 2')
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(secondItem.locator('.WidgetToken')).toContainText([
|
|
|
|
'Aggregate_Column',
|
|
|
|
'.',
|
|
|
|
'Group_By',
|
|
|
|
])
|
|
|
|
await expect(secondItem.locator('.WidgetText > input').first()).toHaveValue('column 2')
|
2024-01-26 20:18:27 +03:00
|
|
|
|
|
|
|
// Switch aggregates
|
|
|
|
//TODO[ao] I have no idea how to emulate drag. Simple dragTo does not work (some element seem to capture event).
|
|
|
|
// When hovered, the handle becomes available after some time, but still mouse events don't have any effect.
|
|
|
|
// I have no time now to investigate this.
|
|
|
|
// Once fixed, add also removing element from vector here.
|
|
|
|
|
|
|
|
// await columnsArg.locator('.item > .handle').nth(1).hover({ force: true })
|
|
|
|
// await columnsArg.locator('.item > .handle').nth(1).hover()
|
|
|
|
// await page.mouse.down()
|
|
|
|
// await columnsArg.locator('.item > .handle').nth(0).hover({ force: true })
|
|
|
|
// await columnsArg.locator('.item > .handle').nth(0).hover()
|
|
|
|
// await page.mouse.up()
|
2024-03-06 18:34:07 +03:00
|
|
|
// await expect(columnsArg.locator('.WidgetToken')).toContainText([
|
2024-01-26 20:18:27 +03:00
|
|
|
// 'Aggregate_Column',
|
|
|
|
// '.',
|
|
|
|
// 'Group_By',
|
|
|
|
// '"',
|
|
|
|
// 'column 2',
|
|
|
|
// '"',
|
|
|
|
// 'Aggregate_Column',
|
|
|
|
// '.',
|
|
|
|
// 'Count_Distinct',
|
|
|
|
// '"',
|
|
|
|
// 'column 1',
|
|
|
|
// '"',
|
|
|
|
// ])
|
|
|
|
})
|