authChangeEventStream.mjs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { By, until } from 'selenium-webdriver'
  2. import {
  3. getRootAndWait,
  4. takeScreenshotOnFailure,
  5. } from '../../lib/elements.js'
  6. const UI_WAIT_MS = 5000
  7. function actionButtonLocator (title) {
  8. return By.xpath(`//*[contains(@class, 'action-button')]//button[contains(., '${title}')]`)
  9. }
  10. async function clickActionAndWaitForSuccess (title) {
  11. const button = await webdriver.wait(until.elementLocated(actionButtonLocator(title)), UI_WAIT_MS)
  12. await button.click()
  13. await webdriver.wait(async () => {
  14. const classes = await button.getAttribute('class')
  15. return classes.includes('action-success')
  16. }, UI_WAIT_MS)
  17. }
  18. describe('config: authChangeEventStream', function () {
  19. before(async function () {
  20. await runner.start('authChangeEventStream')
  21. })
  22. after(async () => {
  23. await runner.stop()
  24. })
  25. afterEach(function () {
  26. takeScreenshotOnFailure(this.currentTest, webdriver)
  27. })
  28. it('delivers execution events for the new user after logging in without a page refresh', async () => {
  29. await getRootAndWait()
  30. await clickActionAndWaitForSuccess('Guest action')
  31. const loginLink = await webdriver.wait(until.elementLocated(By.css('a.login-link')), UI_WAIT_MS)
  32. await loginLink.click()
  33. const username = await webdriver.wait(until.elementLocated(By.id('username')), UI_WAIT_MS)
  34. await username.sendKeys('alice')
  35. await webdriver.findElement(By.id('password')).sendKeys('password')
  36. await webdriver.findElement(By.css('button.login-button')).click()
  37. await clickActionAndWaitForSuccess('Admin action')
  38. })
  39. })