Signup creation and submit tests

This commit is contained in:
Aarni Halinen
2021-01-14 20:44:37 +02:00
parent 957aeb75f2
commit 88f445ef9b
8 changed files with 142 additions and 39 deletions
+10 -10
View File
@@ -2,13 +2,12 @@ import { Selector } from "testcafe";
import { getSiteRoot, getPageUrl } from "../utils";
import { doLogin } from "./common/login";
fixture`Admin can create events`.page(`${getSiteRoot()}/admin/events`);
fixture`Admin events`.page(`${getSiteRoot()}/admin/events`);
test("Logged in user can create event", async t => {
const loginForm = Selector("form.admin-login-form");
await t.expect(loginForm.exists).ok();
await doLogin(t);
await t.expect(await getPageUrl() === "/admin/events").ok();
const newButton = Selector("[data-e2e=\"create-event\"]");
@@ -50,14 +49,15 @@ test("Logged in user can create event", async t => {
// .click(signupOption, { modifiers: { ctrl: true } });
await t.typeText(titleFi, "title_fi");
await t.typeText(descFi, "desc_fi");
await t.typeText(contentFi, "content_fi");
await t.typeText(locationFi, "location_fi");
await t.typeText(titleEn, "title_en");
await t.typeText(descEn, "desc_en");
await t.typeText(contentEn, "content_en");
await t.typeText(locationEn, "location_en");
await t
.typeText(titleFi, "title_fi")
.typeText(descFi, "desc_fi")
.typeText(contentFi, "content_fi")
.typeText(locationFi, "location_fi")
.typeText(titleEn, "title_en")
.typeText(descEn, "desc_en")
.typeText(contentEn, "content_en")
.typeText(locationEn, "location_en");
const submit = Selector("button[type=\"submit\"]");
@@ -0,0 +1,81 @@
import { Selector } from "testcafe";
import { getSiteRoot, getPageUrl } from "../utils";
import { doLogin } from "./common/login";
fixture`Admin events`.page(`${getSiteRoot()}/admin/signups`);
test("Logged in user can create signup", async t => {
const loginForm = Selector("form.admin-login-form");
await t.expect(loginForm.exists).ok();
await doLogin(t);
await t.expect(await getPageUrl() === "/admin/signups").ok();
const newButton = Selector("[data-e2e=\"create-signup\"]");
await t.click(newButton);
await t.expect(await getPageUrl() === "/admin/signups/create").ok();
const titleFi = Selector("#rjsf_title_fi");
const titleEn = Selector("#rjsf_title_en");
const visible = Selector("#rjsf_visible");
await t
.typeText(titleFi, "Testi Ilmo")
.typeText(titleEn, "Test Signup")
.click(visible);
const newQuestionButton = Selector("[data-e2e=\"admin-signup-new-question\"]");
const lastQuestion = () => Selector("[data-e2e=\"admin-signup-question\"]").child("div").child("div").nth(-1);
await t.click(newQuestionButton);
let question = lastQuestion();
let questionName = question.child("input");
let questionTypeSelect = question.child("select");
let requiredBox = question.child("label")
await t
.selectText(questionName)
.pressKey("delete")
.typeText(questionName, "Nimi")
.click(questionTypeSelect)
.click(questionTypeSelect.find("option").withExactText("name"))
.click(requiredBox);
await t.click(newQuestionButton);
question = lastQuestion();
questionName = question.child("input");
questionTypeSelect = question.child("select");
requiredBox = question.child("label");
await t
.selectText(questionName)
.pressKey("delete")
.typeText(questionName, "S-Posti")
.click(questionTypeSelect)
.click(questionTypeSelect.find("option").withExactText("email"))
.click(requiredBox);
await t.click(newQuestionButton);
question = lastQuestion();
questionName = question.child("input");
questionTypeSelect = question.child("select");
const radioOptions = question.child("input").nth(-1);
await t
.selectText(questionName)
.pressKey("delete")
.typeText(questionName, "Olen")
.click(questionTypeSelect)
.click(questionTypeSelect.find("option").withExactText("radiobutton"))
.typeText(radioOptions, "Nuori,Vanha,Testaaja");
const submit = Selector("button[type=\"submit\"]");
await t.click(submit);
const statusMessage = Selector("[data-e2e=\"admin-form-status-message\"]");
await t
.hover(statusMessage)
.expect(
statusMessage.innerText
).eql("Sign-up created successfully");
})