2024-07-17 17:23:46 +03:00
|
|
|
import { expect, test } from 'playwright/test'
|
|
|
|
import * as actions from './actions'
|
2024-11-06 19:54:32 +03:00
|
|
|
import { mockCollapsedFunctionInfo, 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)
|
|
|
|
|
2024-11-19 18:47:46 +03:00
|
|
|
const rightDock = locate.rightDock(page)
|
2024-07-17 17:23:46 +03:00
|
|
|
// Documentation panel hotkey opens right-dock.
|
2024-11-19 18:47:46 +03:00
|
|
|
await expect(rightDock).toBeHidden()
|
2024-07-17 17:23:46 +03:00
|
|
|
await page.keyboard.press(`${CONTROL_KEY}+D`)
|
2024-11-19 18:47:46 +03:00
|
|
|
await expect(rightDock).toBeVisible()
|
2024-07-17 17:23:46 +03:00
|
|
|
|
|
|
|
// Right-dock displays main method documentation.
|
2024-11-19 18:47:46 +03:00
|
|
|
await expect(locate.editorRoot(rightDock)).toContainText('The main method')
|
|
|
|
// All three images are loaded properly
|
|
|
|
await expect(rightDock.getByAltText('Image')).toHaveCount(3)
|
|
|
|
for (const img of await rightDock.getByAltText('Image').all())
|
|
|
|
await expect(img).toHaveJSProperty('naturalWidth', 3)
|
2024-07-17 17:23:46 +03:00
|
|
|
|
|
|
|
// 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()
|
2024-10-25 15:26:21 +03:00
|
|
|
const codeEditor = page.locator('.CodeEditor')
|
|
|
|
await expect(codeEditor).toBeVisible()
|
2024-07-17 17:23:46 +03:00
|
|
|
|
|
|
|
// Focus code editor.
|
2024-10-25 15:26:21 +03:00
|
|
|
await codeEditor.click()
|
2024-07-17 17:23:46 +03:00
|
|
|
|
|
|
|
await page.evaluate(() => {
|
2024-10-25 15:26:21 +03:00
|
|
|
const codeEditorApi = (window as any).__codeEditorApi
|
|
|
|
const docStart = codeEditorApi.indexOf('The main method')
|
|
|
|
codeEditorApi.placeCursor(docStart + 8)
|
2024-07-17 17:23:46 +03:00
|
|
|
})
|
|
|
|
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')
|
|
|
|
})
|
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/)
|
|
|
|
})
|
2024-11-06 19:54:32 +03:00
|
|
|
|
|
|
|
test('Documentation reflects entered function', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
|
|
|
|
// Open the panel
|
|
|
|
await expect(locate.rightDock(page)).toBeHidden()
|
|
|
|
await page.keyboard.press(`${CONTROL_KEY}+D`)
|
|
|
|
await expect(locate.rightDock(page)).toBeVisible()
|
|
|
|
|
|
|
|
// Enter the collapsed function
|
|
|
|
await mockCollapsedFunctionInfo(page, 'final', 'func1')
|
|
|
|
await locate.graphNodeByBinding(page, 'final').dblclick()
|
|
|
|
await expect(locate.navBreadcrumb(page)).toHaveText(['Mock Project', 'func1'])
|
|
|
|
|
|
|
|
// Editor should contain collapsed function's docs
|
|
|
|
await expect(locate.editorRoot(locate.rightDock(page))).toHaveText('A collapsed function')
|
|
|
|
})
|