diff --git a/tests/testcafe/404.test.ts b/tests/testcafe/404.test.ts index a555ec3..8cd5ef7 100644 --- a/tests/testcafe/404.test.ts +++ b/tests/testcafe/404.test.ts @@ -1,11 +1,8 @@ -/** - * TestCafé test fixtures. - * This file is used by TestCafé to run end-to-end tests with chrome against the site. - * Tests are grouped into fixtures and fixtures into files. - */ -import { Selector } from "testcafe"; -fixture`404 page renders and functions correctly`.page("http://localhost:3000/404"); +import { Selector } from "testcafe"; +import { getSiteRoot } from "./utils"; + +fixture`404 page renders and functions correctly`.page(`${getSiteRoot}/404`); test("Page contains the text 404", async t => { /** diff --git a/tests/testcafe/admin.test.ts b/tests/testcafe/admin.test.ts index 177ce5b..6500a11 100644 --- a/tests/testcafe/admin.test.ts +++ b/tests/testcafe/admin.test.ts @@ -1,11 +1,7 @@ -/** - * TestCafé test fixtures. - * This file is used by TestCafé to run end-to-end tests with chrome against the site. - * Tests are grouped into fixtures and fixtures into files. - */ import { Selector, ClientFunction } from "testcafe"; +import { getSiteRoot } from "./utils"; -fixture`Admin login page functions correctly`.page("http://localhost:3000/admin/login"); +fixture`Admin login page functions correctly`.page(`${getSiteRoot}/admin/login`); test("Login form exists", async t => { /** @@ -26,7 +22,7 @@ test("User can log in with default credentials", async t => { 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(); }); diff --git a/tests/testcafe/index.test.ts b/tests/testcafe/index.test.ts index 104f3c8..8ce72c9 100644 --- a/tests/testcafe/index.test.ts +++ b/tests/testcafe/index.test.ts @@ -1,11 +1,7 @@ -/** - * TestCafé test fixtures. - * This file is used by TestCafé to run end-to-end tests with chrome against the site. - * Tests are grouped into fixtures and fixtures into files. - */ import { Selector } from "testcafe"; +import { getSiteRoot } from "./utils"; -fixture`Front page renders and functions correctly`.page("http://localhost:3000"); +fixture`Front page renders and functions correctly`.page(`${getSiteRoot}`); test("Favicon exists", async t => { /** @@ -21,5 +17,5 @@ test("Header contains text \"Aalto-yliopiston Sähköinsinöörikilta\"", async */ const header = Selector("h1"); await t.expect(header.textContent) - .contains("Aalto-yliopiston Sähköinsinöörikilta"); + .contains("Aalto-yliopiston Sähköinsinöörikilta"); }); diff --git a/tests/testcafe/utils.ts b/tests/testcafe/utils.ts new file mode 100644 index 0000000..da4d989 --- /dev/null +++ b/tests/testcafe/utils.ts @@ -0,0 +1,3 @@ +export const getSiteRoot = () => { + return process.env.SITE_URL || "http://localhost:3000"; +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 1012a57..b5ba85b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -59,6 +59,7 @@ }, "include": [ "./src/**/*", - "./types/**/*" + "./types/**/*", + "./tests/testcafe" ], } \ No newline at end of file