mirror of
https://github.com/enso-org/enso.git
synced 2024-12-25 22:12:01 +03:00
de406c69fa
Fixes #8520 If the websocket is closed not by us, we automatically try to reconnect with it, and initialize the protocol again. **Restoring state (execution contexts, attached visualizations) is not part of this PR**. It's a part of making IDE work after hibernation (or LS crash). # Important Notes It required somewhat heavy refactoring: 1. I decided to use an existing implementation of reconnecting websocket. Replaced (later discovered by me) our implementation. 2. The LanguageServer class now handles both reconnecting and re-initializing - that make usage of it simpler (no more `Promise<LanguageServer>` - each method will just wait for (re)connection and initialization. 3. The stuff in `net` src's module was partially moved to shared's counterpart (with tests). Merged `exponentialBackoff` implementations, which also brought me to 4. Rewriting LS client, so it returns Result instead of throwing, what is closer our desired state, and allows us using exponentialBackoff method without any wrappers.
49 lines
2.2 KiB
TypeScript
49 lines
2.2 KiB
TypeScript
import { test } from '@playwright/test'
|
|
import assert from 'assert'
|
|
import * as actions from './actions'
|
|
import { computedContent } from './css'
|
|
import { expect } from './customExpect'
|
|
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 } })
|
|
await expect(locate.circularMenu(page)).toExist()
|
|
await locate.toggleVisualizationButton(page).click()
|
|
await expect(locate.anyVisualization(page)).toExist()
|
|
await expect(locate.loadingVisualization(page)).toHaveCount(0)
|
|
await locate.showVisualizationSelectorButton(page).click()
|
|
await page.getByText('JSON').click()
|
|
const vis = locate.jsonVisualization(page)
|
|
await expect(vis).toExist()
|
|
// The default JSON viz data contains an object.
|
|
const element = await vis.elementHandle()
|
|
assert(element != null)
|
|
const textContent = await computedContent(element)
|
|
const jsonContent = JSON.parse(textContent)
|
|
expect(typeof jsonContent).toBe('object')
|
|
})
|
|
|
|
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 expect(locate.loadingVisualization(page)).toHaveCount(0)
|
|
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)
|
|
})
|