Extract test login to own function
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
import { Selector } from "testcafe";
|
||||||
|
|
||||||
|
const USERNAME = "admin";
|
||||||
|
const PASSWORD = "password123";
|
||||||
|
|
||||||
|
export const doLogin = async (t: TestController) => {
|
||||||
|
await t.typeText(Selector("#login-username"), USERNAME);
|
||||||
|
await t.typeText(Selector("#login-password"), PASSWORD);
|
||||||
|
await t.click(Selector("#login-submit"));
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Selector, ClientFunction } from "testcafe";
|
import { Selector, ClientFunction } from "testcafe";
|
||||||
import { getSiteRoot } from "./utils";
|
import { getSiteRoot } from "./utils";
|
||||||
|
import { doLogin } from "./admin/common/login";
|
||||||
|
|
||||||
fixture`Admin login page functions correctly`.page(`${getSiteRoot}/admin/login`);
|
fixture`Admin login page functions correctly`.page(`${getSiteRoot}/admin/login`);
|
||||||
|
|
||||||
@@ -15,12 +16,7 @@ test("User can log in with default credentials", async t => {
|
|||||||
/**
|
/**
|
||||||
* Test if the user can log in with default credentials.
|
* Test if the user can log in with default credentials.
|
||||||
*/
|
*/
|
||||||
const USERNAME = "admin";
|
await doLogin(t);
|
||||||
const PASSWORD = "password123";
|
|
||||||
|
|
||||||
await t.typeText(Selector("#login-username"), USERNAME);
|
|
||||||
await t.typeText(Selector("#login-password"), PASSWORD);
|
|
||||||
await t.click(Selector("#login-submit"));
|
|
||||||
|
|
||||||
const frontPage = Selector("[data-e2e=\"admin-front-page\"]");
|
const frontPage = Selector("[data-e2e=\"admin-front-page\"]");
|
||||||
await t.expect(frontPage.exists).ok();
|
await t.expect(frontPage.exists).ok();
|
||||||
|
|||||||
+1
-1
@@ -60,6 +60,6 @@
|
|||||||
"include": [
|
"include": [
|
||||||
"./src/**/*",
|
"./src/**/*",
|
||||||
"./types/**/*",
|
"./types/**/*",
|
||||||
"./tests/testcafe"
|
"./tests/testcafe/**/*"
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user