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 { getSiteRoot } from "./utils";
|
||||
import { doLogin } from "./admin/common/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.
|
||||
*/
|
||||
const USERNAME = "admin";
|
||||
const PASSWORD = "password123";
|
||||
|
||||
await t.typeText(Selector("#login-username"), USERNAME);
|
||||
await t.typeText(Selector("#login-password"), PASSWORD);
|
||||
await t.click(Selector("#login-submit"));
|
||||
await doLogin(t);
|
||||
|
||||
const frontPage = Selector("[data-e2e=\"admin-front-page\"]");
|
||||
await t.expect(frontPage.exists).ok();
|
||||
|
||||
+1
-1
@@ -60,6 +60,6 @@
|
||||
"include": [
|
||||
"./src/**/*",
|
||||
"./types/**/*",
|
||||
"./tests/testcafe"
|
||||
"./tests/testcafe/**/*"
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user