| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import { describe, it, before, after } from 'mocha'
- import { expect } from 'chai'
- import { By, until } from 'selenium-webdriver'
- import {
- getRootAndWait,
- takeScreenshotOnFailure,
- } from '../../lib/elements.js'
- describe('config: authRequireGuestsToLogin', function () {
- this.timeout(30000)
- before(async function () {
- await runner.start('authRequireGuestsToLogin')
- })
- after(async () => {
- await runner.stop()
- })
- afterEach(function () {
- takeScreenshotOnFailure(this.currentTest, webdriver);
- });
- it('Guest is redirected to login', async function () {
- // Don't use getRootAndWait here because we want to test the redirect, and getRootAndWait waits for the dashboard to load
- await webdriver.get(runner.baseUrl())
- await webdriver.wait(async () => {
- const loginRequired = await webdriver.executeScript(
- 'return !!(window.initResponse && window.initResponse.loginRequired)'
- )
- const url = await webdriver.getCurrentUrl()
- return loginRequired && url.includes('/login')
- }, 15000, 'Guest should be redirected to login after Init')
- // Verify login UI elements are present
- const loginElements = await webdriver.findElements(By.css('form.local-login-form, .login-oauth2, .login-disabled'))
- expect(loginElements.length).to.be.greaterThan(0)
- console.log('✓ Login page loaded correctly')
- })
- })
|