2024-03-06 18:34:07 +03:00
|
|
|
import { test } from '@playwright/test'
|
2024-03-25 19:03:18 +03:00
|
|
|
import assert from 'assert'
|
2023-11-27 18:48:37 +03:00
|
|
|
import * as actions from './actions'
|
2024-03-25 19:03:18 +03:00
|
|
|
import { computedContent } from './css'
|
2024-03-06 18:34:07 +03:00
|
|
|
import { expect } from './customExpect'
|
2023-11-27 18:48:37 +03:00
|
|
|
import * as locate from './locate'
|
|
|
|
|
|
|
|
test('node can open and load visualization', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
const node = locate.graphNode(page).last()
|
|
|
|
await node.click({ position: { x: 8, y: 8 } })
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(locate.circularMenu(page)).toExist()
|
2023-11-27 18:48:37 +03:00
|
|
|
await locate.toggleVisualizationButton(page).click()
|
2024-03-06 18:34:07 +03:00
|
|
|
await expect(locate.anyVisualization(page)).toExist()
|
2023-11-27 18:48:37 +03:00
|
|
|
await locate.showVisualizationSelectorButton(page).click()
|
|
|
|
await page.getByText('JSON').click()
|
2024-03-25 19:03:18 +03:00
|
|
|
const vis = locate.jsonVisualization(page)
|
|
|
|
await expect(vis).toExist()
|
2023-11-27 18:48:37 +03:00
|
|
|
// The default JSON viz data contains an object.
|
2024-03-25 19:03:18 +03:00
|
|
|
const element = await vis.elementHandle()
|
|
|
|
assert(element != null)
|
|
|
|
const textContent = await computedContent(element)
|
|
|
|
const jsonContent = JSON.parse(textContent)
|
|
|
|
expect(typeof jsonContent).toBe('object')
|
2023-11-27 18:48:37 +03:00
|
|
|
})
|
2024-03-17 19:29:56 +03:00
|
|
|
|
|
|
|
test('Warnings visualization', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
|
|
|
|
// Create a node, attach a warning, open the warnings-visualization.
|
|
|
|
await locate.addNewNodeButton(page).click()
|
|
|
|
const input = locate.componentBrowserInput(page).locator('input')
|
|
|
|
await input.fill('Warning.attach "Uh oh" 42')
|
|
|
|
await page.keyboard.press('Enter')
|
|
|
|
await expect(locate.componentBrowser(page)).not.toBeVisible()
|
|
|
|
await expect(locate.circularMenu(page)).toExist()
|
|
|
|
await locate.toggleVisualizationButton(page).click()
|
|
|
|
await expect(locate.anyVisualization(page)).toExist()
|
|
|
|
await locate.showVisualizationSelectorButton(page).click()
|
|
|
|
await page.locator('.VisualizationSelector').getByRole('button', { name: 'Warnings' }).click()
|
|
|
|
await expect(locate.warningsVisualization(page)).toExist()
|
|
|
|
// Click the remove-warnings button, and ensure a node is created.
|
|
|
|
const nodeCount = await locate.graphNode(page).count()
|
|
|
|
await page.getByTestId('remove-warnings-button').click()
|
|
|
|
await expect(locate.graphNode(page)).toHaveCount(nodeCount + 1)
|
|
|
|
})
|