xtermLinkHandling.mjs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { describe, it, before, after } from 'mocha'
  2. import { expect } from 'chai'
  3. import { By, Condition } from 'selenium-webdriver'
  4. import {
  5. DEFAULT_UI_WAIT_MS,
  6. getRootAndWait,
  7. takeScreenshotOnFailure,
  8. getTerminalBuffer,
  9. waitForLogsPage,
  10. waitForExecutionComplete,
  11. } from '../../lib/elements.js'
  12. describe('config: xtermLinkHandling', function () {
  13. before(async function () {
  14. await runner.start('xtermLinkHandling')
  15. })
  16. after(async () => {
  17. await runner.stop()
  18. })
  19. afterEach(function () {
  20. takeScreenshotOnFailure(this.currentTest, webdriver)
  21. })
  22. it('xterm output shows URL and link handling is configured', async function () {
  23. await getRootAndWait()
  24. await webdriver.wait(new Condition('wait for Echo URL button', async () => {
  25. const btns = await webdriver.findElements(By.css('[title="Echo URL"]'))
  26. return btns.length === 1
  27. }), DEFAULT_UI_WAIT_MS)
  28. const echoUrlButton = await webdriver.findElement(By.css('[title="Echo URL"]'))
  29. await echoUrlButton.click()
  30. await waitForLogsPage()
  31. await waitForExecutionComplete()
  32. const bufferText = await getTerminalBuffer()
  33. expect(bufferText).to.not.be.null
  34. expect(bufferText).to.include('https://example.com')
  35. const linkHandlerSet = await webdriver.executeScript(`
  36. try {
  37. return !!(window.terminal && window.terminal.linkHandlerConfigured === true)
  38. } catch (e) {
  39. return false
  40. }
  41. `)
  42. expect(linkHandlerSet).to.equal(true)
  43. })
  44. })