authRequireGuestsToLogin.mjs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { describe, it, before, after } from 'mocha'
  2. import { expect } from 'chai'
  3. import { By, until } from 'selenium-webdriver'
  4. import {
  5. getRootAndWait,
  6. takeScreenshotOnFailure,
  7. } from '../../lib/elements.js'
  8. describe('config: authRequireGuestsToLogin', function () {
  9. this.timeout(30000)
  10. before(async function () {
  11. await runner.start('authRequireGuestsToLogin')
  12. })
  13. after(async () => {
  14. await runner.stop()
  15. })
  16. afterEach(function () {
  17. takeScreenshotOnFailure(this.currentTest, webdriver);
  18. });
  19. it('Guest is redirected to login', async function () {
  20. // Don't use getRootAndWait here because we want to test the redirect, and getRootAndWait waits for the dashboard to load
  21. await webdriver.get(runner.baseUrl())
  22. await webdriver.wait(until.urlContains('/login'), 10000)
  23. // Verify login UI elements are present
  24. const loginElements = await webdriver.findElements(By.css('form.local-login-form, .login-oauth2, .login-disabled'))
  25. expect(loginElements.length).to.be.greaterThan(0)
  26. console.log('✓ Login page loaded correctly')
  27. })
  28. })