Skip failing integration tests
CI Pipeline / test (20) (pull_request) Successful in 6m28s
CI Pipeline / test (18) (pull_request) Successful in 8m20s
CI Pipeline / e2e (firefox) (pull_request) Successful in 3m15s
CI Pipeline / e2e (webkit) (pull_request) Successful in 3m39s
CI Pipeline / e2e (chromium) (pull_request) Successful in 11m5s
CI Pipeline / visual-regression (pull_request) Successful in 6m4s
CI Pipeline / storybook (pull_request) Successful in 2m27s
CI Pipeline / build (pull_request) Successful in 2m29s
CI Pipeline / performance (pull_request) Successful in 4m54s
CI Pipeline / test (20) (pull_request) Successful in 6m28s
CI Pipeline / test (18) (pull_request) Successful in 8m20s
CI Pipeline / e2e (firefox) (pull_request) Successful in 3m15s
CI Pipeline / e2e (webkit) (pull_request) Successful in 3m39s
CI Pipeline / e2e (chromium) (pull_request) Successful in 11m5s
CI Pipeline / visual-regression (pull_request) Successful in 6m4s
CI Pipeline / storybook (pull_request) Successful in 2m27s
CI Pipeline / build (pull_request) Successful in 2m29s
CI Pipeline / performance (pull_request) Successful in 4m54s
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import React from "react";
|
||||
import BlogPostPage from "../../app/blog/[slug]/page";
|
||||
|
||||
// Mock Next.js components
|
||||
@@ -17,6 +18,28 @@ vi.mock("next/link", () => {
|
||||
};
|
||||
});
|
||||
|
||||
// Mock next/dynamic to return components synchronously in tests
|
||||
vi.mock("next/dynamic", () => {
|
||||
return {
|
||||
default: (importFn, options) => {
|
||||
// In tests, resolve the dynamic import immediately and return the component
|
||||
let Component = null;
|
||||
importFn().then((mod) => {
|
||||
Component = mod.default || mod;
|
||||
});
|
||||
// Return a synchronous wrapper that uses the mocked component
|
||||
return (props) => {
|
||||
// Use the mocked RelatedArticles component directly
|
||||
if (Component) {
|
||||
return <Component {...props} />;
|
||||
}
|
||||
// Fallback: return the loading placeholder if component not ready
|
||||
return options?.loading ? options.loading() : null;
|
||||
};
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
// Mock content processing
|
||||
vi.mock("../../lib/content", () => ({
|
||||
getBlogPostBySlug: vi.fn(),
|
||||
@@ -173,7 +196,11 @@ describe("BlogPostPage", () => {
|
||||
});
|
||||
render(BlogPostPageComponent);
|
||||
|
||||
expect(screen.getByTestId("related-articles")).toBeInTheDocument();
|
||||
// Wait for dynamically imported RelatedArticles component to load
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId("related-articles")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
expect(screen.getByText("Related Articles")).toBeInTheDocument();
|
||||
expect(screen.getByTestId("related-related-1")).toBeInTheDocument();
|
||||
expect(screen.getByTestId("related-related-2")).toBeInTheDocument();
|
||||
@@ -295,6 +322,11 @@ describe("BlogPostPage", () => {
|
||||
});
|
||||
render(BlogPostPageComponent);
|
||||
|
||||
// Wait for dynamically imported RelatedArticles component to load
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId("related-articles")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Current post should not appear in related articles
|
||||
expect(
|
||||
screen.queryByTestId("related-test-article"),
|
||||
|
||||
Reference in New Issue
Block a user