4
0

xtermLinkHandling.mjs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { describe, it, before, after } from 'mocha'
  2. import { expect } from 'chai'
  3. import { By, Condition } from 'selenium-webdriver'
  4. import {
  5. getRootAndWait,
  6. takeScreenshotOnFailure,
  7. getTerminalBuffer,
  8. } from '../../lib/elements.js'
  9. describe('config: xtermLinkHandling', function () {
  10. before(async function () {
  11. await runner.start('xtermLinkHandling')
  12. })
  13. after(async () => {
  14. await runner.stop()
  15. })
  16. afterEach(function () {
  17. takeScreenshotOnFailure(this.currentTest, webdriver)
  18. })
  19. it('xterm output shows URL and link handling is configured', async function () {
  20. await getRootAndWait()
  21. await webdriver.wait(new Condition('wait for Echo URL button', async () => {
  22. const btns = await webdriver.findElements(By.css('[title="Echo URL"]'))
  23. return btns.length === 1
  24. }), 10000)
  25. const echoUrlButton = await webdriver.findElement(By.css('[title="Echo URL"]'))
  26. await echoUrlButton.click()
  27. await webdriver.wait(new Condition('wait for execution view', async () => {
  28. const url = await webdriver.getCurrentUrl()
  29. return url.includes('/logs/') && !url.endsWith('/logs')
  30. }), 10000)
  31. await webdriver.wait(new Condition('wait for execution status', async () => {
  32. const statusElements = await webdriver.findElements(By.id('execution-dialog-status'))
  33. return statusElements.length > 0
  34. }), 5000)
  35. await webdriver.wait(new Condition('wait for execution to finish', async () => {
  36. try {
  37. const statusElement = await webdriver.findElement(By.id('execution-dialog-status'))
  38. const statusText = await statusElement.getText()
  39. return !statusText.includes('Executing')
  40. } catch (e) {
  41. return false
  42. }
  43. }), 5000)
  44. await webdriver.sleep(500)
  45. const bufferText = await getTerminalBuffer()
  46. expect(bufferText).to.not.be.null
  47. expect(bufferText).to.include('https://example.com')
  48. const linkHandlerSet = await webdriver.executeScript(`
  49. try {
  50. return !!(window.terminal && window.terminal.linkHandlerConfigured === true)
  51. } catch (e) {
  52. return false
  53. }
  54. `)
  55. expect(linkHandlerSet).to.equal(true)
  56. })
  57. })