2024-07-17 17:23:46 +03:00
|
|
|
import { expect, test } from 'playwright/test'
|
|
|
|
import * as actions from './actions'
|
2024-08-07 17:49:24 +03:00
|
|
|
import { mockMethodCallInfo } from './expressionUpdates'
|
2024-07-17 17:23:46 +03:00
|
|
|
import { CONTROL_KEY } from './keyboard'
|
|
|
|
import * as locate from './locate'
|
|
|
|
|
|
|
|
test('Main method documentation', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
|
|
|
|
// Documentation panel hotkey opens right-dock.
|
|
|
|
await expect(locate.rightDock(page)).toBeHidden()
|
|
|
|
await page.keyboard.press(`${CONTROL_KEY}+D`)
|
|
|
|
await expect(locate.rightDock(page)).toBeVisible()
|
|
|
|
|
|
|
|
// Right-dock displays main method documentation.
|
|
|
|
await expect(locate.lexicalContent(locate.rightDock(page))).toHaveText('The main method')
|
|
|
|
|
|
|
|
// Documentation hotkey closes right-dock.p
|
|
|
|
await page.keyboard.press(`${CONTROL_KEY}+D`)
|
|
|
|
await expect(locate.rightDock(page)).toBeHidden()
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Doc panel focus (regression #10471)', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
|
|
|
|
await page.keyboard.press(`${CONTROL_KEY}+D`)
|
|
|
|
await page.keyboard.press(`${CONTROL_KEY}+\``)
|
|
|
|
await expect(locate.rightDock(page)).toBeVisible()
|
|
|
|
await expect(locate.bottomDock(page)).toBeVisible()
|
|
|
|
|
|
|
|
// Focus code editor.
|
|
|
|
await locate.bottomDock(page).click()
|
|
|
|
|
|
|
|
await page.evaluate(() => {
|
2024-10-11 21:23:02 +03:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2024-07-17 17:23:46 +03:00
|
|
|
const codeEditor = (window as any).__codeEditorApi
|
|
|
|
const docStart = codeEditor.indexOf('The main method')
|
|
|
|
codeEditor.placeCursor(docStart + 8)
|
|
|
|
})
|
|
|
|
await page.keyboard.press('Space')
|
|
|
|
await page.keyboard.press('T')
|
|
|
|
await page.keyboard.press('E')
|
|
|
|
await page.keyboard.press('S')
|
|
|
|
await page.keyboard.press('T')
|
|
|
|
|
|
|
|
const content = await page.evaluate(() => {
|
2024-10-11 21:23:02 +03:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2024-07-17 17:23:46 +03:00
|
|
|
const codeEditor = (window as any).__codeEditorApi
|
|
|
|
return codeEditor.textContent()
|
|
|
|
})
|
|
|
|
expect(content.includes('The main TEST method')).toBe(true)
|
|
|
|
await expect(locate.rightDock(page)).toContainText('The main TEST method')
|
|
|
|
})
|
2024-08-07 17:49:24 +03:00
|
|
|
|
|
|
|
test('Component help', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page, false)
|
|
|
|
await locate.rightDock(page).getByRole('button', { name: 'Help' }).click()
|
|
|
|
await expect(locate.rightDock(page)).toHaveText(/Select a single component/)
|
|
|
|
|
|
|
|
await locate.graphNodeByBinding(page, 'final').click()
|
|
|
|
await expect(locate.rightDock(page)).toHaveText(/No documentation available/)
|
|
|
|
|
|
|
|
await mockMethodCallInfo(page, 'data', {
|
|
|
|
methodPointer: {
|
|
|
|
module: 'Standard.Base.Data',
|
|
|
|
definedOnType: 'Standard.Base.Data',
|
|
|
|
name: 'read',
|
|
|
|
},
|
|
|
|
notAppliedArguments: [0, 1, 2],
|
|
|
|
})
|
|
|
|
await locate.graphNodeByBinding(page, 'data').click()
|
|
|
|
await expect(locate.rightDock(page)).toHaveText(/Reads a file into Enso/)
|
|
|
|
})
|