enso/app/gui2/e2e/rightPanel.spec.ts
Kaz Wesley 3a4b942aae
Help tab (#10771)
Add context sensitive help to right side panel; implements #10582.

https://github.com/user-attachments/assets/0d6bce44-735a-4deb-86c9-72a088ab1d59

# Important Notes
- The rightmost (i.e. current) breadcrumb is no longer clickable.
2024-08-07 14:49:24 +00:00

72 lines
2.5 KiB
TypeScript

import { expect, test } from 'playwright/test'
import * as actions from './actions'
import { mockMethodCallInfo } from './expressionUpdates'
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(() => {
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(() => {
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')
})
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/)
})