-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Clickable external links to docs from dev console #242026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
7e6cac1
0a1da76
8ba2336
a694a38
9956b79
6b63c51
4105824
6b98c1c
7187942
34f594f
b48ebe8
d44ddd6
97af2d3
55fb519
a1a5042
53df6b8
5afa5cc
510df50
c0a847e
d2f8c73
ffdc7d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { | |
| const retry = getService('retry'); | ||
| const browser = getService('browser'); | ||
| const PageObjects = getPageObjects(['common', 'console', 'header']); | ||
| const testSubjects = getService('testSubjects'); | ||
| const toasts = getService('toasts'); | ||
|
|
||
| describe('misc console behavior', function testMiscConsoleBehavior() { | ||
|
|
@@ -261,6 +262,90 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { | |
| }); | ||
| }); | ||
|
|
||
| describe('clickable links', () => { | ||
| let initialWindowHandles: string[]; | ||
|
|
||
| beforeEach(async () => { | ||
| initialWindowHandles = await browser.getAllWindowHandles(); | ||
| }); | ||
|
|
||
| afterEach(async () => { | ||
| // Close any new tabs that were opened | ||
| const currentHandles = await browser.getAllWindowHandles(); | ||
| if (currentHandles.length > initialWindowHandles.length) { | ||
| // Close all new tabs | ||
| for (let i = initialWindowHandles.length; i < currentHandles.length; i++) { | ||
| await browser.switchToWindow(currentHandles[i]); | ||
| await browser.closeCurrentWindow(); | ||
| } | ||
| // Switch back to the original tab | ||
| await browser.switchToWindow(initialWindowHandles[0]); | ||
| } | ||
| }); | ||
|
|
||
| it('should open URL in new tab when clicking on a link in the input editor', async () => { | ||
| await PageObjects.console.clearEditorText(); | ||
|
|
||
| // Enter a URL that will be detected as a link | ||
| await PageObjects.console.enterText('# https://www.elastic.co'); | ||
|
|
||
| // Wait for Monaco to detect and decorate the link | ||
| await retry.waitFor('link to be detected by Monaco', async () => { | ||
| const inputEditor = await testSubjects.find('consoleMonacoEditor'); | ||
| const detectedLinks = await inputEditor.findAllByCssSelector('.detected-link'); | ||
| return detectedLinks.length > 0; | ||
| }); | ||
|
|
||
| // Get the input editor container | ||
| const inputEditor = await testSubjects.find('consoleMonacoEditor'); | ||
|
|
||
| // Find the detected link element that Monaco created | ||
| const detectedLink = await inputEditor.findByCssSelector('.detected-link'); | ||
|
|
||
| // Perform Cmd/Ctrl+Click on the detected link | ||
| // Following the pattern from ES|QL tests where we hover to show tooltip, then click the option | ||
| const modifierKey = browser.keys[process.platform === 'darwin' ? 'COMMAND' : 'CONTROL']; | ||
|
|
||
| await browser.getActions().keyDown(modifierKey).perform(); | ||
|
||
|
|
||
| // Hover over the detected link to show the tooltip | ||
| await detectedLink.moveMouseTo(); | ||
|
|
||
| // Wait for Monaco hover tooltip to appear | ||
| // Monaco shows a tooltip with "Follow link" when hovering over a URL with Cmd/Ctrl held | ||
| await retry.waitFor('Monaco hover tooltip to appear', async () => { | ||
| const links = await inputEditor.findAllByCssSelector( | ||
| '.monaco-hover .rendered-markdown a' | ||
| ); | ||
| return links.length > 0; | ||
| }); | ||
|
|
||
| // Click the "Follow link" anchor in the hover tooltip | ||
| // The HTML structure is: .monaco-hover > .hover-contents > .rendered-markdown > a | ||
| const followLinkElement = await inputEditor.findByCssSelector( | ||
| '.monaco-hover .rendered-markdown a' | ||
| ); | ||
| await followLinkElement.click(); | ||
|
|
||
| await browser.getActions().keyUp(modifierKey).perform(); | ||
|
|
||
| // Wait for a new tab to open | ||
| await retry.waitFor('new tab to open after clicking link', async () => { | ||
| const handles = await browser.getAllWindowHandles(); | ||
| return handles.length > initialWindowHandles.length; | ||
| }); | ||
|
|
||
| // Verify a new tab was opened | ||
| const windowHandles = await browser.getAllWindowHandles(); | ||
| expect(windowHandles.length).to.be.greaterThan(initialWindowHandles.length); | ||
|
|
||
| // Switch to the new tab and verify the URL | ||
| await browser.switchToWindow(windowHandles[windowHandles.length - 1]); | ||
| const currentUrl = await browser.getCurrentUrl(); | ||
| expect(currentUrl).to.contain('elastic.co'); | ||
| }); | ||
| }); | ||
|
|
||
| it('should work fine with a large content', async () => { | ||
| await PageObjects.console.clearEditorText(); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.