Change sik.party addresses to sahkoinsinoorikilta.fi

This commit is contained in:
Aarni Halinen
2021-01-18 21:34:20 +02:00
parent 92616f9cd4
commit 68c7c6d7ae
16 changed files with 77 additions and 58 deletions
+58 -38
View File
@@ -1,7 +1,7 @@
import { Selector, ClientFunction, RequestLogger } from "testcafe";
import axios from "axios";
const API_URL = "https://api.dev.sik.party/api"
const API_URL = "https://api.sahkoinsinoorikilta.fi/api";
export const getSiteRoot = (): string => process.env.SITE_URL || "http://localhost:3000";
export const getPageUrl = ClientFunction(() => window.location.pathname);
@@ -9,7 +9,7 @@ export const getPageUrl = ClientFunction(() => window.location.pathname);
export const getPostRequestLogger = (url: string) => RequestLogger({ url: `${API_URL}/${url}`, method: "post" }, {
// logResponseHeaders: true,
logResponseBody: true,
stringifyResponseBody: true
stringifyResponseBody: true,
});
const openTime = new Date("1994-01-14T22:51:00+02:00");
@@ -23,7 +23,7 @@ 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"));
}
};
export async function generateToken(): Promise<string> {
const tokenUrl = `${API_URL}/api-token-auth/`;
@@ -31,28 +31,48 @@ export async function generateToken(): Promise<string> {
try {
const resp = await axios.post(tokenUrl, {
username: USERNAME,
password: PASSWORD
password: PASSWORD,
});
return resp.data["token"];
return resp.data.token;
} catch (err) {
console.error(err);
throw err;
}
}
export const generateTestForm = async (jwt: string) => (
await createForm({
"title_fi": "Testi Ilmo",
"title_en": "Test Signup",
"visible": true,
"quota": 0,
"start_time": openTime,
"end_time": tomorrow,
"email_content": "E2E Test",
"questions": [{ "id": "XS_Ox5Rry", "name": "Nimi", "type": "name", "options": [], "required": true }, { "id": "Ve02XSEEx", "name": "S-Posti", "type": "email", "options": [], "required": true }, { "id": "luMqnz5y9", "name": "Olen", "type": "radiobutton", "options": ["Nuori", "Vanha", "Testaaja"] }], "id": 14, "isOpen": true, "schema": { "type": "object", "required": ["XS_Ox5Rry", "Ve02XSEEx"], "properties": { "XS_Ox5Rry": { "type": "string", "title": "Nimi" }, "Ve02XSEEx": { "type": ["string"], "title": "S-Posti", "format": "email", "pattern": "^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$", "default": null }, "luMqnz5y9": { "type": "string", "title": "Olen", "pattern": "^Nuori$|^Vanha$|^Testaaja$", "enum": ["Nuori", "Vanha", "Testaaja"] } } }
createForm({
title_fi: "Testi Ilmo",
title_en: "Test Signup",
visible: true,
quota: 0,
start_time: openTime,
end_time: tomorrow,
email_content: "E2E Test",
questions: [{
id: "XS_Ox5Rry", name: "Nimi", type: "name", options: [], required: true,
}, {
id: "Ve02XSEEx", name: "S-Posti", type: "email", options: [], required: true,
}, {
id: "luMqnz5y9", name: "Olen", type: "radiobutton", options: ["Nuori", "Vanha", "Testaaja"],
}],
id: 14,
isOpen: true,
schema: {
type: "object",
required: ["XS_Ox5Rry", "Ve02XSEEx"],
properties: {
XS_Ox5Rry: { type: "string", title: "Nimi" },
Ve02XSEEx: {
type: ["string"], title: "S-Posti", format: "email", pattern: "^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$", default: null,
},
luMqnz5y9: {
type: "string", title: "Olen", pattern: "^Nuori$|^Vanha$|^Testaaja$", enum: ["Nuori", "Vanha", "Testaaja"],
},
},
},
}, jwt)
)
);
const formURL = `${API_URL}/signupForm/`;
@@ -60,7 +80,7 @@ export async function createForm(data, jwt: string) {
try {
const resp = await axios.post(formURL, data, {
headers: {
"Authorization": `JWT ${jwt}`,
Authorization: `JWT ${jwt}`,
},
});
return resp.data;
@@ -74,7 +94,7 @@ export async function deleteForm(id: string, jwt: string) {
try {
const resp = await axios.delete(`${formURL}${id}/`, {
headers: {
"Authorization": `JWT ${jwt}`
Authorization: `JWT ${jwt}`,
},
});
return resp.data;
@@ -85,25 +105,25 @@ export async function deleteForm(id: string, jwt: string) {
}
export const generateTestEvent = async (formIds = [], jwt: string) => (
await createEvent({
"tags":[1],
"visible":true,
"start_time": openTime,
"end_time": tomorrow,
"title_fi":"title_fi",
"description_fi":"desc_fi",
"content_fi":"content_fi",
"location_fi":"location_fi",
"title_en":"title_en",
"description_en":"desc_en",
"content_en":"content_en",
"location_en":"location_en",
"image":null,
"signupForm": formIds,
"signup_id": formIds,
"tag_id":[1]
createEvent({
tags: [1],
visible: true,
start_time: openTime,
end_time: tomorrow,
title_fi: "title_fi",
description_fi: "desc_fi",
content_fi: "content_fi",
location_fi: "location_fi",
title_en: "title_en",
description_en: "desc_en",
content_en: "content_en",
location_en: "location_en",
image: null,
signupForm: formIds,
signup_id: formIds,
tag_id: [1],
}, jwt)
)
);
const eventURL = `${API_URL}/events/`;
@@ -111,7 +131,7 @@ export async function createEvent(data, jwt: string) {
try {
const resp = await axios.post(eventURL, data, {
headers: {
"Authorization": `JWT ${jwt}`,
Authorization: `JWT ${jwt}`,
},
});
return resp.data;
@@ -125,7 +145,7 @@ export async function deleteEvent(id: string, jwt: string) {
try {
const resp = await axios.delete(`${eventURL}${id}/`, {
headers: {
"Authorization": `JWT ${jwt}`
Authorization: `JWT ${jwt}`,
},
});
return resp.data;