GF-6, #8 Added auth.
Some checks failed
Production PR / QA Tests (pull_request) Failing after 13s
Some checks failed
Production PR / QA Tests (pull_request) Failing after 13s
This commit is contained in:
parent
e8818d6eaa
commit
10e4363cbd
60 changed files with 4855 additions and 160 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { afterEach, describe, expect, it, vi, beforeAll, afterAll } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import DefaultLayout from "~/layouts/Default.vue";
|
||||
|
||||
vi.mock("#app", () => ({
|
||||
|
|
@ -10,35 +10,78 @@ vi.mock("#app", () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock("~/stores/auth", () => ({
|
||||
useAuthStore: () => ({
|
||||
init: vi.fn(),
|
||||
user: null,
|
||||
}),
|
||||
}));
|
||||
|
||||
describe("Default.vue", () => {
|
||||
beforeAll(() => {
|
||||
const shouldSuppress = (args: string[]) => {
|
||||
const msg = args.join(" ");
|
||||
return msg.includes("<Suspense> is an experimental feature");
|
||||
};
|
||||
|
||||
const spyMethods = ["warn", "error", "log", "info"] as const;
|
||||
for (const method of spyMethods) {
|
||||
const original = console[method];
|
||||
vi.spyOn(console, method).mockImplementation((...args) => {
|
||||
if (shouldSuppress(args)) return;
|
||||
original(...args);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("loads without crashing", () => {
|
||||
const wrapper = mount(DefaultLayout);
|
||||
it("loads without crashing", async () => {
|
||||
const wrapper = mount({
|
||||
components: { DefaultLayout },
|
||||
template: "<Suspense><DefaultLayout /></Suspense>",
|
||||
});
|
||||
await flushPromises(); // Wait for async setup
|
||||
expect(wrapper.exists()).toBe(true);
|
||||
});
|
||||
|
||||
describe("Footer", () => {
|
||||
it("footer is displayed", () => {
|
||||
const wrapper = mount(DefaultLayout);
|
||||
it("footer is displayed", async () => {
|
||||
const wrapper = mount({
|
||||
components: { DefaultLayout },
|
||||
template: "<Suspense><DefaultLayout /></Suspense>",
|
||||
});
|
||||
await flushPromises();
|
||||
const footer = wrapper.find("[data-testid='footer']");
|
||||
expect(footer.exists()).toBe(true);
|
||||
});
|
||||
|
||||
it("footer shows only 2025 when current year is 2025", () => {
|
||||
it("footer shows only 2025 when current year is 2025", async () => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date(2025, 0, 1));
|
||||
const wrapper = mount(DefaultLayout);
|
||||
const wrapper = mount({
|
||||
components: { DefaultLayout },
|
||||
template: "<Suspense><DefaultLayout /></Suspense>",
|
||||
});
|
||||
await flushPromises();
|
||||
const footer = wrapper.find("[data-testid='footer']");
|
||||
expect(footer.text()).toBe("Glowing Fiesta 2025 (1.0.1)");
|
||||
});
|
||||
|
||||
it("footer shows range when current year is not 2025", () => {
|
||||
it("footer shows range when current year is not 2025", async () => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date(2069, 0, 1));
|
||||
const wrapper = mount(DefaultLayout);
|
||||
const wrapper = mount({
|
||||
components: { DefaultLayout },
|
||||
template: "<Suspense><DefaultLayout /></Suspense>",
|
||||
});
|
||||
await flushPromises();
|
||||
const footer = wrapper.find("[data-testid='footer']");
|
||||
expect(footer.text()).toBe("Glowing Fiesta 2025 - 2069 (1.0.1)");
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue