Commit bf7d5b7c authored by axelkjonsberg's avatar axelkjonsberg
Browse files

Clean up frontend test folder

Extract testcafe roles to own folder and clean up
parent 5547c569
Pipeline #117307 passed with stage
in 1 minute and 4 seconds
import { Selector, t } from "testcafe";
import { Alice } from "../roles";
const registerTestUsers = async () => {
await t
.navigateTo(`http://localhost:3000/register.html`)
.typeText("#register-username", "alice")
.typeText("#register-password", "aliceisok")
.typeText("#register-email", "tester@testing.com")
.click("#btn-create-account");
}
fixture `Register`
.page`http://localhost:3000/register.html`;
test('Can register', async t => {
await registerTestUsers();
})
fixture`Login`
.page`http://localhost:3000/login.html`
.beforeEach(async (t) => {
await registerTestUsers();
await t.useRole(Alice);
});
test("Can view profile", async (t) => {
const username = Selector("#username", { timeout: 1000 });
const textContent = username.textContent;
await t
.navigateTo("/profile.html")
.expect(username.exists).ok()
// .expect(textContent).eql("alice");
});
import { Role } from "testcafe";
const Alice = Role(`http://localhost:3000/login.html`, async (t) => {
await t
.typeText("#login-username", "alice")
.typeText("#login-password", "aliceisok")
.click("#rememberMe")
.click("#btn-login");
});
export { Alice }
\ No newline at end of file
import { Selector, Role } from "testcafe";
// fixture `Register`
// .page `http://localhost:3000/register.html`;
// test('Can register', async t => {
// await t
// .typeText()
// })
const alice = Role("http://localhost:3000/login.html", async (t) => {
await t
.typeText("#login-username", "alice")
.typeText("#login-password", "aliceisok")
.click("#rememberMe")
.click("#btn-login");
});
fixture`Login`.page`http://localhost:3000/index.html`;
test("Can view profile", async (t) => {
const username = Selector("#username");
await t
.useRole(alice)
.navigateTo("/profile.html")
.expect(username.exists)
.ok()
.expect(username.textContent)
.eql("alice");
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment