BS-007 Implement accepted Contact page and independent enquiry service
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { fireEvent, render, screen, within } from "@testing-library/react";
|
||||
import { fireEvent, render, screen, within, waitFor } from "@testing-library/react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import App from "../App";
|
||||
|
||||
@@ -7,15 +7,19 @@ describe("public marketing routes", () => {
|
||||
it.each([
|
||||
["/services", "Services"], ["/projects", "Projects"],
|
||||
["/projects/example", "Project details"], ["/about", "About BortStack"],
|
||||
["/contact", "Contact"], ["/privacy", "Privacy policy"],
|
||||
["/contact", "Have a project in mind?"], ["/privacy", "Privacy policy"],
|
||||
["/login", "Page not found"], ["/register", "Page not found"], ["/dashboard", "Page not found"],
|
||||
])("loads %s without account infrastructure", (path, heading) => {
|
||||
const fetchMock = vi.fn();
|
||||
])("loads %s without account infrastructure", async (path, heading) => {
|
||||
const fetchMock = vi.fn().mockResolvedValue({ ok: true, json: async () => ({ email: null, available: false }) });
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
window.history.replaceState({}, "", path);
|
||||
render(<App />);
|
||||
expect(screen.getByRole("heading", { level: 1, name: heading })).toBeInTheDocument();
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
if (path === "/contact") {
|
||||
expect(fetchMock).toHaveBeenCalledWith("/api/contact/config");
|
||||
await waitFor(() => expect(screen.getByText(/Enquiries are temporarily unavailable/)).toBeInTheDocument());
|
||||
}
|
||||
else expect(fetchMock).not.toHaveBeenCalled();
|
||||
expect(screen.queryByRole("link", { name: /login|register|dashboard/i })).not.toBeInTheDocument();
|
||||
});
|
||||
it("exposes the four marketing links and closes navigation on selection", async () => {
|
||||
|
||||
Reference in New Issue
Block a user