Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
194 changes: 100 additions & 94 deletions __tests__/app/about/mission/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,166 +1,172 @@
import React from 'react';
/* eslint-disable react/display-name */
import { render, screen } from '@testing-library/react';
import MissionPage from '@/app/about/mission/page';
import MissionPage from "@/app/about/mission/page";
import { render, screen } from "@testing-library/react";

// Mock the Header component since it's dynamically imported
jest.mock('@/components/header/Header', () => {
jest.mock("@/components/header/Header", () => {
return function MockHeader() {
return <div data-testid="header">Header</div>;
};
});

// Mock HeaderPlaceholder
jest.mock('@/components/header/HeaderPlaceholder', () => {
jest.mock("@/components/header/HeaderPlaceholder", () => {
return function MockHeaderPlaceholder() {
return <div data-testid="header-placeholder">Header Placeholder</div>;
};
});

describe('MissionPage', () => {
describe("MissionPage", () => {
const renderComponent = () => {
return render(<MissionPage />);
};

it('renders the page title in the title bar', () => {
it("renders the page title in the title bar", () => {
renderComponent();
const titles = screen.getAllByText('6529 MISSION');

const titles = screen.getAllByText("6529 MISSION");
expect(titles.length).toBeGreaterThan(0);
expect(titles[0]).toBeInTheDocument();
});

it('renders the main mission statement', () => {
it("renders the main mission statement", () => {
renderComponent();

expect(screen.getByText(/THE 6529 MISSION IS TO ACCELERATE THE DEVELOPMENT OF AN OPEN METAVERSE/)).toBeInTheDocument();

expect(
screen.getByText(
/THE 6529 MISSION IS TO ACCELERATE THE DEVELOPMENT OF AN OPEN METAVERSE/
)
).toBeInTheDocument();
});

it('includes correct meta tags for SEO', () => {
it("includes correct meta tags for SEO", () => {
renderComponent();

// Check for some key meta tags
const metaTags = document.querySelectorAll('meta');
const titleElement = document.querySelector('title');
expect(titleElement?.textContent).toBe('6529 MISSION - 6529.io');
const metaTags = document.querySelectorAll("meta");
const titleElement = document.querySelector("title");

expect(titleElement?.textContent).toBe("6529 MISSION - 6529.io");

// Check for specific meta tags
const descriptionMeta = Array.from(metaTags).find(meta =>
meta.getAttribute('name') === 'description'
const descriptionMeta = Array.from(metaTags).find(
(meta) => meta.getAttribute("name") === "description"
);
expect(descriptionMeta?.getAttribute("content")).toBe(
"THE 6529 MISSION IS TO ACCELERATE THE DEVELOPMENT OF AN OPEN METAVERSE"
);

const robotsMeta = Array.from(metaTags).find(
(meta) => meta.getAttribute("name") === "robots"
);
expect(descriptionMeta?.getAttribute('content')).toBe('THE 6529 MISSION IS TO ACCELERATE THE DEVELOPMENT OF AN OPEN METAVERSE');

const robotsMeta = Array.from(metaTags).find(meta =>
meta.getAttribute('name') === 'robots'
expect(robotsMeta?.getAttribute("content")).toBe(
"index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1"
);
expect(robotsMeta?.getAttribute('content')).toBe('index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1');
});

it('includes Open Graph meta tags', () => {
it("includes Open Graph meta tags", () => {
renderComponent();
const metaTags = document.querySelectorAll('meta');
const ogTitle = Array.from(metaTags).find(meta =>
meta.getAttribute('property') === 'og:title'

const metaTags = document.querySelectorAll("meta");

const ogTitle = Array.from(metaTags).find(
(meta) => meta.getAttribute("property") === "og:title"
);
expect(ogTitle?.getAttribute('content')).toBe('6529 MISSION - 6529.io');
const ogType = Array.from(metaTags).find(meta =>
meta.getAttribute('property') === 'og:type'
expect(ogTitle?.getAttribute("content")).toBe("6529 MISSION - 6529.io");

const ogType = Array.from(metaTags).find(
(meta) => meta.getAttribute("property") === "og:type"
);
expect(ogType?.getAttribute('content')).toBe('article');
const ogUrl = Array.from(metaTags).find(meta =>
meta.getAttribute('property') === 'og:url'
expect(ogType?.getAttribute("content")).toBe("article");

const ogUrl = Array.from(metaTags).find(
(meta) => meta.getAttribute("property") === "og:url"
);
expect(ogUrl?.getAttribute('content')).toBe('/about/mission/');
expect(ogUrl?.getAttribute("content")).toBe("/about/mission/");
});

it('includes Twitter meta tags', () => {
it("includes Twitter meta tags", () => {
renderComponent();
const metaTags = document.querySelectorAll('meta');
const twitterCard = Array.from(metaTags).find(meta =>
meta.getAttribute('name') === 'twitter:card'

const metaTags = document.querySelectorAll("meta");

const twitterCard = Array.from(metaTags).find(
(meta) => meta.getAttribute("name") === "twitter:card"
);
expect(twitterCard?.getAttribute('content')).toBe('summary_large_image');
const twitterSite = Array.from(metaTags).find(meta =>
meta.getAttribute('name') === 'twitter:site'
expect(twitterCard?.getAttribute("content")).toBe("summary_large_image");

const twitterSite = Array.from(metaTags).find(
(meta) => meta.getAttribute("name") === "twitter:site"
);
expect(twitterSite?.getAttribute('content')).toBe('@om100m');
expect(twitterSite?.getAttribute("content")).toBe("@om100m");
});

it('renders the main content section', () => {
it("renders the main content section", () => {
renderComponent();
const mainElement = document.querySelector('#main');

const mainElement = document.querySelector("#main");
expect(mainElement).toBeInTheDocument();
expect(mainElement).toHaveClass('clearfix', 'width-100');
expect(mainElement).toHaveClass("clearfix", "width-100");
});

it('renders the page title bar section', () => {
it("renders the page title bar section", () => {
renderComponent();

const titleBarSection = document.querySelector('.avada-page-titlebar-wrapper');

const titleBarSection = document.querySelector(
".avada-page-titlebar-wrapper"
);
expect(titleBarSection).toBeInTheDocument();
expect(titleBarSection).toHaveAttribute('aria-label', 'Page Title Bar');
expect(titleBarSection).toHaveAttribute("aria-label", "Page Title Bar");
});

it('includes social media links', () => {
it("includes social media links", () => {
renderComponent();

const twitterLink = document.querySelector('a[href="https://twitter.com/punk6529"]');

const twitterLink = document.querySelector(
'a[href="https://twitter.com/punk6529"]'
);
expect(twitterLink).toBeInTheDocument();
expect(twitterLink).toHaveAttribute('href', 'https://twitter.com/punk6529');
expect(twitterLink).toHaveAttribute('target', '_blank');
expect(twitterLink).toHaveAttribute("href", "https://twitter.com/punk6529");
expect(twitterLink).toHaveAttribute("target", "_blank");
});

it('includes skip to content link for accessibility', () => {
it("includes skip to content link for accessibility", () => {
renderComponent();
const skipLink = screen.getByText('Skip to content');

const skipLink = screen.getByText("Skip to content");
expect(skipLink).toBeInTheDocument();
expect(skipLink).toHaveClass('skip-link', 'screen-reader-text');
expect(skipLink).toHaveAttribute('href', '#content');
expect(skipLink).toHaveClass("skip-link", "screen-reader-text");
expect(skipLink).toHaveAttribute("href", "#content");
});

it('includes go to top functionality', () => {
it("includes go to top functionality", () => {
renderComponent();
const goToTopSection = document.querySelector('.to-top-container');

const goToTopSection = document.querySelector(".to-top-container");
expect(goToTopSection).toBeInTheDocument();
expect(goToTopSection).toHaveAttribute('aria-labelledby', 'awb-to-top-label');

const goToTopLink = document.querySelector('#toTop');
expect(goToTopSection).toHaveAttribute(
"aria-labelledby",
"awb-to-top-label"
);

const goToTopLink = document.querySelector("#toTop");
expect(goToTopLink).toBeInTheDocument();
expect(goToTopLink).toHaveClass('fusion-top-top-link');
expect(goToTopLink).toHaveClass("fusion-top-top-link");
});

it('renders with proper page structure', () => {
it("renders with proper page structure", () => {
renderComponent();
expect(document.querySelector('#boxed-wrapper')).toBeInTheDocument();
expect(document.querySelector('#wrapper')).toBeInTheDocument();
expect(document.querySelector('#content')).toBeInTheDocument();

expect(document.querySelector("#boxed-wrapper")).toBeInTheDocument();
expect(document.querySelector("#wrapper")).toBeInTheDocument();
expect(document.querySelector("#content")).toBeInTheDocument();
});

it('includes canonical link', () => {
it("includes canonical link", () => {
renderComponent();

const canonicalLink = document.querySelector('link[rel="canonical"]');
expect(canonicalLink).toBeInTheDocument();
expect(canonicalLink?.getAttribute('href')).toBe('/about/mission/');
expect(canonicalLink?.getAttribute("href")).toBe("/about/mission/");
});

it('includes viewport meta tag for responsive design', () => {
renderComponent();

const viewportMeta = document.querySelector('meta[name="viewport"]');
expect(viewportMeta).toBeInTheDocument();
expect(viewportMeta?.getAttribute('content')).toBe('width=device-width, initial-scale=1');
});
});
});
4 changes: 2 additions & 2 deletions __tests__/app/access.test.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { render, fireEvent, waitFor } from '@testing-library/react';
import React from 'react';
import AccessPage from '@/app/access/page';
import { AuthContext } from '../../components/auth/Auth';
import { AuthContext } from '@/components/auth/Auth';
import { useRouter } from 'next/navigation';

jest.mock('next/image', () => ({ __esModule: true, default: (p: any) => <img alt="" {...p} /> }));
jest.mock('next/navigation', () => ({ useRouter: jest.fn() }));

// Mock TitleContext
jest.mock('../../contexts/TitleContext', () => ({
jest.mock('@/contexts/TitleContext', () => ({
useTitle: () => ({
title: 'Test Title',
setTitle: jest.fn(),
Expand Down
4 changes: 2 additions & 2 deletions __tests__/app/api/open-graph.route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jest.mock("next/server", () => ({
NextRequest: class {},
}));

jest.mock("../../../app/api/open-graph/utils", () => ({
jest.mock("@/app/api/open-graph/utils", () => ({
buildResponse: jest.fn(),
buildGoogleWorkspaceResponse: jest.fn(),
HTML_ACCEPT_HEADER:
Expand All @@ -40,7 +40,7 @@ jest.mock("@/lib/security/urlGuard", () => {
};
});

jest.mock("../../../app/api/open-graph/compound/service", () => ({
jest.mock("@/app/api/open-graph/compound/service", () => ({
createCompoundPlan: jest.fn(() => null),
}));

Expand Down
2 changes: 1 addition & 1 deletion __tests__/app/api/open-graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jest.mock("node:dns/promises", () => ({
import {
buildGoogleWorkspaceResponse,
buildResponse,
} from "../../../app/api/open-graph/utils";
} from "@/app/api/open-graph/utils";
import { assertPublicUrl } from "@/lib/security/urlGuard";

const { lookup } = require("node:dns/promises") as {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/app/buidl.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { render } from '@testing-library/react';
import Buidl from '@/app/buidl/page';
import { AuthContext } from '../../components/auth/Auth';
import { AuthContext } from '@/components/auth/Auth';


// Mock TitleContext
jest.mock('../../contexts/TitleContext', () => ({
jest.mock('@/contexts/TitleContext', () => ({
useTitle: () => ({
title: 'Test Title',
setTitle: jest.fn(),
Expand Down
4 changes: 2 additions & 2 deletions __tests__/app/category/news/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import NewsPage from '@/app/category/news/page';

jest.mock('../../../../components/header/Header', () => () => <div data-testid="header">Header</div>);
jest.mock('../../../../components/header/HeaderPlaceholder', () => () => <div data-testid="header-placeholder">Header Placeholder</div>);
jest.mock('@/components/header/Header', () => () => <div data-testid="header">Header</div>);
jest.mock('@/components/header/HeaderPlaceholder', () => () => <div data-testid="header-placeholder">Header Placeholder</div>);

describe('NewsPage', () => {
const renderComponent = () => render(<NewsPage />);
Expand Down
4 changes: 2 additions & 2 deletions __tests__/app/consolidationMappingTool.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, screen, waitFor } from '@testing-library/react';
import React from 'react';
import ConsolidationMappingToolPage from '@/app/consolidation-mapping-tool/page';
import { AuthContext } from '../../components/auth/Auth';
import { AuthContext } from '@/components/auth/Auth';

jest.mock('next/dynamic', () => () => () => <div data-testid="dynamic" />);

Expand All @@ -11,7 +11,7 @@ const TestProvider: React.FC<{ children: React.ReactNode }> = ({ children }) =>


// Mock TitleContext
jest.mock('../../contexts/TitleContext', () => ({
jest.mock('@/contexts/TitleContext', () => ({
useTitle: () => ({
title: 'Test Title',
setTitle: jest.fn(),
Expand Down
4 changes: 2 additions & 2 deletions __tests__/app/delegationMappingToolPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, screen, waitFor } from '@testing-library/react';
import React from 'react';
import DelegationMappingToolPage from '@/app/delegation-mapping-tool/page';
import { AuthContext } from '../../components/auth/Auth';
import { AuthContext } from '@/components/auth/Auth';

jest.mock('next/dynamic', () => () => () => <div data-testid="dynamic" />);

Expand All @@ -11,7 +11,7 @@ const TestProvider: React.FC = ({ children }) => (


// Mock TitleContext
jest.mock('../../contexts/TitleContext', () => ({
jest.mock('@/contexts/TitleContext', () => ({
useTitle: () => ({
title: 'Test Title',
setTitle: jest.fn(),
Expand Down
Loading
Loading