Add folder for admin tests
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { Selector, ClientFunction } from "testcafe";
|
||||
import { getSiteRoot } from "../utils";
|
||||
import { doLogin } from "./common/login";
|
||||
|
||||
fixture`Admin login page functions correctly`.page(`${getSiteRoot}/admin/login`);
|
||||
|
||||
test("Login form exists", async t => {
|
||||
/**
|
||||
* Test if the page contains a form.
|
||||
*/
|
||||
const form = Selector("form.admin-login-form");
|
||||
await t.expect(form.exists).ok();
|
||||
});
|
||||
|
||||
test("User can log in with default credentials", async t => {
|
||||
/**
|
||||
* Test if the user can log in with default credentials.
|
||||
*/
|
||||
await doLogin(t);
|
||||
|
||||
const frontPage = Selector("[data-e2e=\"admin-front-page\"]");
|
||||
await t.expect(frontPage.exists).ok();
|
||||
});
|
||||
|
||||
test("User can log out and is redirected to login", async t => {
|
||||
/**
|
||||
* Test if the user can log out.
|
||||
*/
|
||||
await t.click(Selector("#login-submit"));
|
||||
|
||||
const logout = Selector("#admin-sidebar-logout");
|
||||
await t.click(logout);
|
||||
|
||||
const loginForm = Selector("form.admin-login-form");
|
||||
await t.expect(loginForm.exists).ok();
|
||||
});
|
||||
|
||||
test.skip("User is redirected to login when JWT token is invalid", async t => {
|
||||
/**
|
||||
* Test if the user is redirected to login when JWT token is invalid.
|
||||
*/
|
||||
const setCookie = ClientFunction(() => {
|
||||
document.cookie = "jwt=FOOBAR";
|
||||
});
|
||||
await setCookie();
|
||||
await t.navigateTo("/admin/events");
|
||||
|
||||
const loginForm = Selector("form.admin-login-form");
|
||||
await t.expect(loginForm.exists).ok();
|
||||
});
|
||||
Reference in New Issue
Block a user