redesign the homepage
Build & Deploy / Build & Push Docker Image (push) Failing after 47s
Build & Deploy / Deploy to VPS (push) Has been skipped
Test / API Unit Tests (push) Failing after 5m4s
Test / Marketplace Unit Tests (push) Failing after 4m55s
Test / Admin Unit Tests (push) Successful in 9m37s
Test / Dashboard Unit Tests (push) Successful in 9m37s
Test / API Integration Tests (push) Successful in 9m54s
Build & Deploy / Build & Push Docker Image (push) Failing after 47s
Build & Deploy / Deploy to VPS (push) Has been skipped
Test / API Unit Tests (push) Failing after 5m4s
Test / Marketplace Unit Tests (push) Failing after 4m55s
Test / Admin Unit Tests (push) Successful in 9m37s
Test / Dashboard Unit Tests (push) Successful in 9m37s
Test / API Integration Tests (push) Successful in 9m54s
This commit is contained in:
@@ -1,57 +1,79 @@
|
||||
import React, { isValidElement } from 'react'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import ForgotPasswordPageClient from './forgot-password/ForgotPasswordPageClient'
|
||||
import ResetPasswordPageClient from './reset-password/ResetPasswordPageClient'
|
||||
import ForgotPasswordPage from './forgot-password/page'
|
||||
import ResetPasswordPage from './reset-password/page'
|
||||
import AcceptInvitePage from './onboarding/accept-invite/page'
|
||||
import React, { isValidElement } from "react";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import ForgotPasswordPageClient from "./forgot-password/ForgotPasswordPageClient";
|
||||
import ResetPasswordPageClient from "./reset-password/ResetPasswordPageClient";
|
||||
import ForgotPasswordPage from "./forgot-password/page";
|
||||
import ResetPasswordPage from "./reset-password/page";
|
||||
import AcceptInvitePage from "./onboarding/accept-invite/page";
|
||||
|
||||
function collectText(node: unknown): string[] {
|
||||
if (node === null || node === undefined || typeof node === 'boolean') return []
|
||||
if (typeof node === 'string' || typeof node === 'number') return [String(node)]
|
||||
if (Array.isArray(node)) return node.flatMap(collectText)
|
||||
if (isValidElement<{ children?: React.ReactNode }>(node)) return collectText(node.props.children)
|
||||
return []
|
||||
if (node === null || node === undefined || typeof node === "boolean")
|
||||
return [];
|
||||
if (typeof node === "string" || typeof node === "number")
|
||||
return [String(node)];
|
||||
if (Array.isArray(node)) return node.flatMap(collectText);
|
||||
if (isValidElement<{ children?: React.ReactNode }>(node))
|
||||
return collectText(node.props.children);
|
||||
return [];
|
||||
}
|
||||
|
||||
function findElement(node: unknown, predicate: (element: React.ReactElement) => boolean): React.ReactElement | null {
|
||||
if (node === null || node === undefined || typeof node === 'boolean') return null
|
||||
function findElement(
|
||||
node: unknown,
|
||||
predicate: (element: React.ReactElement) => boolean,
|
||||
): React.ReactElement | null {
|
||||
if (node === null || node === undefined || typeof node === "boolean")
|
||||
return null;
|
||||
if (Array.isArray(node)) {
|
||||
for (const child of node) {
|
||||
const found = findElement(child, predicate)
|
||||
if (found) return found
|
||||
const found = findElement(child, predicate);
|
||||
if (found) return found;
|
||||
}
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
if (!isValidElement<{ children?: React.ReactNode }>(node)) return null
|
||||
if (predicate(node)) return node
|
||||
return findElement(node.props.children, predicate)
|
||||
if (!isValidElement<{ children?: React.ReactNode }>(node)) return null;
|
||||
if (predicate(node)) return node;
|
||||
return findElement(node.props.children, predicate);
|
||||
}
|
||||
|
||||
describe('dashboard public auth pages', () => {
|
||||
it('renders forgot-password in embedded mode for the public shell route', () => {
|
||||
const page = ForgotPasswordPage()
|
||||
describe("dashboard public auth pages", () => {
|
||||
it("renders forgot-password with public chrome by default", async () => {
|
||||
const page = await ForgotPasswordPage({
|
||||
searchParams: Promise.resolve({}),
|
||||
});
|
||||
|
||||
expect(isValidElement(page)).toBe(true)
|
||||
expect(page.type).toBe(ForgotPasswordPageClient)
|
||||
expect(page.props.embedded).toBe(true)
|
||||
})
|
||||
expect(isValidElement(page)).toBe(true);
|
||||
expect(page.type).toBe(ForgotPasswordPageClient);
|
||||
expect(page.props.embedded).toBe(false);
|
||||
});
|
||||
|
||||
it('renders reset-password in embedded mode for the public shell route', () => {
|
||||
const page = ResetPasswordPage()
|
||||
it("renders forgot-password in embedded mode when requested", async () => {
|
||||
const page = await ForgotPasswordPage({
|
||||
searchParams: Promise.resolve({ embedded: "1" }),
|
||||
});
|
||||
|
||||
expect(isValidElement(page)).toBe(true)
|
||||
expect(page.type).toBe(ResetPasswordPageClient)
|
||||
expect(page.props.embedded).toBe(true)
|
||||
})
|
||||
expect(isValidElement(page)).toBe(true);
|
||||
expect(page.type).toBe(ForgotPasswordPageClient);
|
||||
expect(page.props.embedded).toBe(true);
|
||||
});
|
||||
|
||||
it('keeps accept-invite copy and sign-in handoff visible', () => {
|
||||
const page = AcceptInvitePage()
|
||||
const text = collectText(page).join(' ')
|
||||
const signInLink = findElement(page, (element) => element.props.href === '/sign-in')
|
||||
it("renders reset-password in embedded mode for the public shell route", () => {
|
||||
const page = ResetPasswordPage();
|
||||
|
||||
expect(text).toContain('Invitation accepted')
|
||||
expect(text).toContain('Sign in to dashboard')
|
||||
expect(signInLink).not.toBeNull()
|
||||
})
|
||||
})
|
||||
expect(isValidElement(page)).toBe(true);
|
||||
expect(page.type).toBe(ResetPasswordPageClient);
|
||||
expect(page.props.embedded).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps accept-invite copy and sign-in handoff visible", () => {
|
||||
const page = AcceptInvitePage();
|
||||
const text = collectText(page).join(" ");
|
||||
const signInLink = findElement(
|
||||
page,
|
||||
(element) => element.props.href === "/sign-in",
|
||||
);
|
||||
|
||||
expect(text).toContain("Invitation accepted");
|
||||
expect(text).toContain("Sign in to dashboard");
|
||||
expect(signInLink).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user