A desktop coding agent with free access to frontier models.
TypeScript
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { describe, expect, test } from "bun:test";
import { parseInvitationPreviewPayload } from "../app/(den)/_lib/den-org";
const joinOrgScreenPath = fileURLToPath(
new URL("../app/(den)/_components/join-org-screen.tsx", import.meta.url),
);
const authPanelPath = fileURLToPath(
new URL("../app/(den)/_components/auth-panel.tsx", import.meta.url),
);
const onboardingShellPath = fileURLToPath(
new URL("../app/(den)/_components/onboarding-shell.tsx", import.meta.url),
);
const sharedDitherShellPath = fileURLToPath(
new URL("../../../../packages/ui/src/react/dithered-onboarding-shell.tsx", import.meta.url),
);
const joinOrgSuccessPath = fileURLToPath(
new URL("../app/(den)/_components/join-org-success.tsx", import.meta.url),
);
const onboardingCardPath = fileURLToPath(
new URL("../app/(den)/_components/onboarding-card.tsx", import.meta.url),
);
const installScreenPath = fileURLToPath(
new URL("../app/(den)/_components/install-screen.tsx", import.meta.url),
);
const brandIdentityPath = fileURLToPath(
new URL("../app/(den)/_components/organization-brand-identity.tsx", import.meta.url),
);
const globalsPath = fileURLToPath(new URL("../app/globals.css", import.meta.url));
const denFlowProviderPath = fileURLToPath(
new URL("../app/(den)/_providers/den-flow-provider.tsx", import.meta.url),
);
function readJoinOrgScreenSource() {
return readFileSync(joinOrgScreenPath, "utf8");
}
function readAuthPanelSource() {
return readFileSync(authPanelPath, "utf8");
}
function readOnboardingShellSource() {
return readFileSync(sharedDitherShellPath, "utf8");
}
describe("join organization invite clean layout contract", () => {
test("uses the organization picker Dithering layer", () => {
const source = readFileSync(onboardingShellPath, "utf8");
const ditheringImports = source.match(/import \{ Dithering \} from "@paper-design\/shaders-react"/g) ?? [];
const ditheringUses = source.match(/<Dithering\b/g) ?? [];
expect(ditheringImports).toHaveLength(1);
expect(ditheringUses).toHaveLength(1);
expect(source).not.toContain("PaperMeshGradient");
expect(source).toContain('type="2x2"');
expect(source).toContain("size={20.3}");
expect(source).toContain("scale={1.19}");
expect(source).toContain("colorBack=\"#00000000\"");
expect(source).toContain("colorFront=\"#000000\"");
});
test("keeps the decorative background separate, restrained, and reduced-motion aware", () => {
const source = readFileSync(onboardingShellPath, "utf8");
expect(source).toContain("min-h-dvh overflow-y-auto bg-[var(--dls-surface)]");
expect(source).toContain("pointer-events-none fixed inset-0 z-0 overflow-hidden opacity-[0.1]");
expect(source).toContain('aria-hidden="true"');
expect(source).toContain('data-testid="join-org-background"');
expect(source).toContain('data-testid="join-org-foreground"');
expect(source).toContain("relative z-10");
expect(source).toContain("useSyncExternalStore");
expect(source).toContain('const REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";');
expect(source).toContain("() => true");
expect(source).toContain("const shaderSpeed = reducedMotion ? 0 : 0.01;");
expect(source).toContain("speed={shaderSpeed}");
expect(source).toContain('data-shader-speed={shaderSpeed}');
});
test("removes stacked frames while using the shared wide welcome card hierarchy", () => {
const source = readJoinOrgScreenSource();
const shellSource = readOnboardingShellSource();
const denShellSource = readFileSync(onboardingShellPath, "utf8");
const cardSource = readFileSync(onboardingCardPath, "utf8");
const cardUsages = source.match(/<OnboardingCard\b/g) ?? [];
const wideShellUsages = source.match(/width="wide"/g) ?? [];
expect(source).not.toContain("den-frame");
expect(source).not.toContain("den-frame-inset");
expect(shellSource).toContain('compact: "max-w-md"');
expect(shellSource).toContain('rootTestId = "join-org-root"');
expect(denShellSource).toContain("<DitheredOnboardingShell");
expect(cardUsages.length).toBeGreaterThanOrEqual(8);
expect(wideShellUsages.length).toBeGreaterThanOrEqual(8);
expect(source.match(/background="surface"/g)?.length).toBe(wideShellUsages.length);
expect(cardSource).toContain("rounded-[1.75rem] border border-slate-200/80 bg-white p-6 sm:p-8 md:p-10");
expect(cardSource).toContain("/omnirush-mark.svg");
expect(cardSource).toContain("OmniRush.ai Cloud");
expect(cardSource).toContain("OrganizationBrandIdentity");
expect(source).toContain("text-[30px] font-semibold leading-[38px] tracking-[-0.03em]");
expect(source).toContain('data-testid="join-org-invitation-details"');
expect(source).toContain('data-testid="join-org-invitation-summary"');
expect(source).toContain('data-testid="join-org-actions"');
expect(source).toContain('data-testid="join-org-auth"');
expect(source).toContain("Organization");
expect(source).toContain("Invited email");
expect(source).toContain("Role");
expect(source).toContain("Account");
expect(source).not.toMatch(/\binviter\b/i);
});
test("uses the shared moderate-radius Den button primitive", () => {
const source = readFileSync(globalsPath, "utf8");
const buttonRule = source.match(/\.den-button-primary,[\s\S]*?\n}/)?.[0] ?? "";
expect(buttonRule).toContain("border-radius: 0.75rem;");
expect(buttonRule).not.toContain("border-radius: 9999px;");
});
test("uses bare invite auth and a non-destructive Not now dismissal", () => {
const source = readJoinOrgScreenSource();
expect(source).toMatch(/<AuthPanel[\s\S]*?\bbare\b/);
expect(source).toMatch(/<AuthPanel[\s\S]*?\blockEmail\b/);
expect(source).toMatch(/<AuthPanel[\s\S]*?\bhideEmailField\b/);
expect(source).toMatch(/<AuthPanel[\s\S]*?\bhideLockedEmailSummary\b/);
expect(source).toMatch(/<AuthPanel[\s\S]*?\bemailFirstFlow\b/);
expect(source).toMatch(/<AuthPanel[\s\S]*?\bresolveEmailFirstOnPrefill\b/);
expect(source).toMatch(/<AuthPanel[\s\S]*?\bhideIntro\b/);
expect(source).toContain('submitLabel: "Create account"');
expect(source).toContain("You've been invited as");
expect(source).not.toContain("Your invitation is ready.");
expect(source).toContain('title: "Sign in to continue."');
expect(source).not.toContain("title: `Join ${preview.organization.name}.`");
expect(source).toContain("Not now");
expect(source).toContain("function handleNotNow()");
expect(source).toContain("window.sessionStorage.removeItem(PENDING_ORG_INVITATION_STORAGE_KEY);");
expect(source).toContain('router.replace("/");');
expect(source).not.toContain("Decline invitation");
expect(source).not.toContain("Cancel invitation");
});
test("keeps invitation signup enabled in private single-org deployments", () => {
const providerSource = readFileSync(denFlowProviderPath, "utf8");
const authPanelSource = readAuthPanelSource();
expect(providerSource).toMatch(/const pendingInvitationId = getPendingOrgInvitationId\(\);[\s\S]*?authMode === "sign-up"[\s\S]*?&& !pendingInvitationId[\s\S]*?\? "sign-in"[\s\S]*?: authMode;/);
expect(providerSource).toContain('submitMode === "sign-up" && pendingInvitationId');
expect(providerSource).toContain("invite: pendingInvitationId ?? undefined");
expect(authPanelSource).toContain('isSingleOrgPrivateSignup && !emailFirstInvite && authMode === "sign-up"');
expect(authPanelSource).toMatch(/loginOptionError \?[\s\S]*?: authError \?[\s\S]*?: \([\s\S]*?<p>\{authInfo\}<\/p>/);
});
test("resolves the invited email auth method before showing invite credentials", () => {
const source = readJoinOrgScreenSource();
const authPanelSource = readAuthPanelSource();
expect(source).toContain("resolveEmailFirstOnPrefill");
expect(source).toContain("emailFirstInvitationId={preview.invitation.id}");
expect(authPanelSource).toContain("function getLoginOptionsPath(targetEmail: string)");
expect(authPanelSource).toContain('params.set("invite", emailFirstInvite);');
expect(authPanelSource).toContain('emailFirstStep === "sso"');
expect(authPanelSource).toContain("startEmailFirstSso");
expect(authPanelSource).toContain("resolvedLoginOptionPrefillRef");
expect(authPanelSource).toMatch(/emailFirstStep === "new_account"[\s\S]*?!hideEmailField/);
expect(authPanelSource).toMatch(/emailFirstStep === "new_account"[\s\S]*?!hideSocialAuth/);
});
test("shows password strength feedback only on signup password fields", () => {
const authPanelSource = readAuthPanelSource();
expect(authPanelSource).toMatch(/emailFirstStep === "new_account"[\s\S]*?signupPasswordFeedback/);
expect(authPanelSource).toContain('visibleAuthMode === "sign-up" && signupPasswordFeedback');
expect(authPanelSource).not.toMatch(/emailFirstStep === "password"[\s\S]{0,500}signupPasswordFeedback/);
});
test("preserves invitation preview, account switching, status, and accept behavior", () => {
const source = readJoinOrgScreenSource();
expect(source).toContain("/v1/orgs/invitations/preview?id=");
expect(source).toContain("/v1/orgs/invitations/accept");
expect(source).toContain("parseInvitationPreviewPayload(payload)");
expect(source).toContain("isEmailAllowedForOrganization");
expect(source).toContain("statusMessage(preview)");
expect(source).toContain("handleSwitchAccount");
expect(source).toContain("window.sessionStorage.setItem(PENDING_ORG_INVITATION_STORAGE_KEY, invitationId);");
expect(source).toContain("acceptedInvitationResolutionRef");
expect(source).toContain('preview.invitation.status !== "accepted"');
expect(source).toContain("acceptedInvitationResolutionRef.current = acceptedInvitationId;");
expect(source).toContain('getStringProperty(payload, "error") === "membership_removed"');
expect(source).toContain("Your access was removed.");
expect(source).toContain("Ask a workspace admin for a new invite.");
expect(source).toContain("if (desktopAuthRequested)");
expect(source).toContain('router.replace("/install");');
expect(source).toContain("Opening your workspace.");
expect(source).toContain("You've already joined ${preview.organization.name}.");
expect(source).toContain("This invite was already accepted. Sign in as ${preview.invitation.email} to open your workspace.");
expect(source).toContain('initialMode="sign-in"');
expect(source).toContain('initialMode="sign-up"');
expect(source).toContain("This invite needs a different email domain.");
expect(source).toContain("This invite is for");
expect(source).toContain("Use a different account");
expect(source).toContain("Log out");
expect(source).toContain("Join ${preview.organization.name}");
});
test("resolves an invite accepted during sign-in before showing it as already used", () => {
const source = readJoinOrgScreenSource();
expect(source).toContain('preview.invitation.status !== "accepted"');
expect(source).toContain("acceptedInvitationResolutionRef.current === acceptedInvitationId");
expect(source).toContain("resolveAcceptedInvitation");
expect(source).toContain("Opening your workspace.");
expect(source).toContain('reason: "membership_removed" | "unknown"');
});
test("carries explicit organization branding through the invitation preview", () => {
const preview = parseInvitationPreviewPayload({
invitation: {
id: "invitation_123",
email: "[email protected]",
role: "member",
status: "pending",
},
organization: {
id: "organization_123",
name: "Blue Yonder",
slug: "blue-yonder",
allowedEmailDomains: ["example.com"],
branding: {
appName: "Agent Blue",
logoUrl: "https://cdn.example.com/wordmark.png",
iconUrl: "https://cdn.example.com/icon.png",
},
},
});
expect(preview?.organization.branding).toEqual({
appName: "Agent Blue",
logoUrl: "https://cdn.example.com/wordmark.png",
iconUrl: "https://cdn.example.com/icon.png",
});
const legacyPreview = parseInvitationPreviewPayload({
invitation: {
id: "invitation_legacy",
email: "[email protected]",
role: "member",
status: "pending",
},
organization: {
id: "organization_legacy",
name: "Blue Yonder",
slug: "blue-yonder",
allowedEmailDomains: null,
},
});
expect(legacyPreview?.organization.branding).toEqual({
appName: "OmniRush.ai",
logoUrl: null,
iconUrl: null,
});
});
test("keeps onboarding focused and reuses the responsive platform grid", () => {
const successSource = readFileSync(joinOrgSuccessPath, "utf8");
const installSource = readFileSync(installScreenPath, "utf8");
const identitySource = readFileSync(brandIdentityPath, "utf8");
expect(successSource).toContain("downloadCtaLabel");
expect(successSource).toContain("Already have OmniRush.ai? Open it.");
expect(successSource).toContain("buildInstallDownloadHref");
expect(successSource).toContain("startInstallerDownload");
expect(successSource).not.toContain("window.location.assign(await createOrganizationInstallLink");
expect(successSource).not.toContain("Get the desktop app");
expect(successSource).toContain("Return to OmniRush.ai");
expect(successSource).toContain("desktopAuthRequested");
expect(successSource).toContain('data-testid="join-org-connected"');
expect(successSource).toContain("Continue in the browser");
expect(successSource).toContain("Email me the download link");
expect(successSource).not.toContain("capabilities");
expect(successSource).not.toContain("Open OmniRush.ai");
expect(successSource).toContain("<OnboardingCard organization={{ name: organizationName, brand }}>");
expect(successSource).toContain('background="surface"');
expect(successSource).toContain("text-[30px] font-semibold leading-[38px] tracking-[-0.03em]");
expect(successSource).toContain("den-button-primary min-h-12 w-full");
expect(successSource).toContain("<span>You're in, welcome to</span>");
expect(successSource).toContain('className="whitespace-nowrap">'s {brand.appName}</span>');
expect(installSource).toContain("DownloadPlatformGrid");
expect(installSource).toContain("Set up OmniRush.ai Enterprise");
expect(installSource).toContain("Download OmniRush.ai");
expect(installSource).not.toContain('data-testid="install-cloud-download-primary"');
expect(installSource).not.toContain("Other platforms");
expect(installSource).toContain('config.distribution === "cloud"');
expect(installSource).not.toContain("never asks for an enterprise activation code");
expect(installSource).toContain("In the app, enter your workspace address:");
expect(installSource).toContain("AppImage (ARM64)");
expect(installSource).toContain('data-testid="install-workspace-address"');
expect(identitySource).toContain("failedLogoUrl");
expect(identitySource).toContain("failedIconUrl");
});
});