datetime.mjs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. getActionButton,
  7. takeScreenshotOnFailure,
  8. } from '../../lib/elements.js'
  9. describe('config: datetime', function () {
  10. before(async function () {
  11. await runner.start('datetime')
  12. })
  13. after(async () => {
  14. await runner.stop()
  15. })
  16. afterEach(function () {
  17. takeScreenshotOnFailure(this.currentTest, webdriver)
  18. })
  19. it('Datetime argument uses datetime-local input type', async function () {
  20. await getRootAndWait()
  21. const btn = await getActionButton(webdriver, 'Test datetime argument')
  22. await btn.click()
  23. // Wait for navigation to argument form page
  24. await webdriver.wait(
  25. new Condition('wait for argument form page', async () => {
  26. const url = await webdriver.getCurrentUrl()
  27. return url.includes('/actionBinding/') && url.includes('/argumentForm')
  28. }),
  29. 8000
  30. )
  31. // Find the datetime input field
  32. const datetimeInput = await webdriver.findElement(By.id('datetime'))
  33. // Verify it's a datetime-local input type
  34. const inputType = await datetimeInput.getAttribute('type')
  35. expect(inputType).to.equal('datetime-local', 'Input type should be datetime-local')
  36. // Verify it has the step attribute set to 1 (for seconds precision)
  37. const step = await datetimeInput.getAttribute('step')
  38. expect(step).to.equal('1', 'Step attribute should be 1')
  39. // Verify the label is present
  40. const label = await webdriver.findElement(By.css('label[for="datetime"]'))
  41. expect(await label.getText()).to.contain('Select a date and time')
  42. })
  43. it('Datetime argument can be filled and submitted', async function () {
  44. await getRootAndWait()
  45. const btn = await getActionButton(webdriver, 'Test datetime argument')
  46. await btn.click()
  47. // Wait for navigation to argument form page
  48. await webdriver.wait(
  49. new Condition('wait for argument form page', async () => {
  50. const url = await webdriver.getCurrentUrl()
  51. return url.includes('/actionBinding/') && url.includes('/argumentForm')
  52. }),
  53. 8000
  54. )
  55. // Find the datetime input field
  56. const datetimeInput = await webdriver.findElement(By.id('datetime'))
  57. // Set a datetime value (format: YYYY-MM-DDTHH:mm)
  58. // datetime-local returns values without seconds, backend will add :00
  59. const testDateTime = '2023-12-25T15:30'
  60. // Use JavaScript to set the value directly (more reliable for datetime-local inputs)
  61. await webdriver.executeScript(
  62. 'arguments[0].value = arguments[1]',
  63. datetimeInput,
  64. testDateTime
  65. )
  66. // Trigger input event to ensure Vue reactivity
  67. await webdriver.executeScript(
  68. 'arguments[0].dispatchEvent(new Event("input", { bubbles: true }))',
  69. datetimeInput
  70. )
  71. // Small wait for Vue to process the change
  72. await webdriver.sleep(100)
  73. // Verify the value was set
  74. const value = await datetimeInput.getAttribute('value')
  75. expect(value).to.equal(testDateTime)
  76. // Find and click the submit button
  77. const submitButton = await webdriver.findElement(
  78. By.css('button[name="start"]')
  79. )
  80. await submitButton.click()
  81. // Wait for navigation to logs page
  82. await webdriver.wait(
  83. new Condition('wait for logs page', async () => {
  84. const url = await webdriver.getCurrentUrl()
  85. return url.includes('/logs/')
  86. }),
  87. 8000
  88. )
  89. // Verify we're on the logs page (action was executed)
  90. const url = await webdriver.getCurrentUrl()
  91. expect(url).to.include('/logs/')
  92. })
  93. })