Skip to content
Snippets Groups Projects
LoginAsNoAdminUser.test.js 1.36 KiB
Newer Older
Orlando Piñero's avatar
Orlando Piñero committed
const { Builder, By, until } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

const webdriver = process.env.Chrome_DRIVER
const service = new chrome.ServiceBuilder(webdriver);
const login = require("./helperSimulations/simulateNoAdminLogin")
const adminLogin = require("./helperSimulations/simulateAdminLogin")

describe("logout and login as user test123", () => {
    let driver

    beforeAll(async () => {
        driver = new Builder().forBrowser('chrome').setChromeService(service).build();
    })

    afterAll(async () => {
        await driver.quit();
    })

    it("should be able to logout and find landing page again", async () => {
        await adminLogin(driver)
        const logoutButton = await driver.wait(until.elementLocated(By.id("LogoutButton")), 5000)
        expect(logoutButton).toBeDefined()
        await logoutButton.click()
        const startPage = await driver.wait(until.elementLocated(By.id("LandingPage")), 5000)
        expect(startPage).toBeDefined()
    })

    it("should be possible to login as user test123 again", async () => {
        await login(driver)
    })

    it("should not show the User-Management-Button", async () => {
        await login(driver);
        const notFoundButton = await driver.findElements(By.id('OpenUserManagementPageButton'));
        expect(notFoundButton.length).toBe(0);
    });
})