Skip to content

Commit d261997

Browse files
committed
test(console): the no-extra-wait pin admits one flush for the deployment flags, then reads the chrome synchronously
Claude-Session: https://claude.ai/code/session_01L6bhgWwKdjqiYQSujUXhn7 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0865f61 commit d261997

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎ui/packages/app-shell/src/console/__tests__/AppContent.unresolvedAdmin-5619.test.tsx‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import '@objectstack/lint';
4747
import '@testing-library/jest-dom/vitest';
4848
import { describe, it, expect, vi, beforeEach } from 'vitest';
4949
import React from 'react';
50-
import { render, screen } from '@testing-library/react';
50+
import { act, render, screen } from '@testing-library/react';
5151
import { MemoryRouter, Routes, Route, Navigate, useLocation } from 'react-router-dom';
5252

5353
vi.mock('@object-ui/plugin-designer', async (importOriginal) => ({
@@ -85,11 +85,14 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({
8585

8686
/** The verdict AND its resolution — the axis this suite exists for. */
8787
const viewer = vi.hoisted(() => ({ isAdmin: false, isResolved: true }));
88+
// One function for every render, as `AuthProvider`'s `useCallback` gives
89+
// (objectstack#35981: the chrome waits for its answer, asked once).
90+
const getAuthConfig = vi.hoisted(() => async () => ({ features: {} }));
8891
vi.mock('@object-ui/auth', async (importOriginal) => ({
8992
...(await importOriginal<Record<string, unknown>>()),
9093
useAuth: () => ({
9194
user: { id: 'u_owner', name: 'Owner', email: 'owner@example.com', role: 'user' },
92-
getAuthConfig: async () => ({ features: {} }),
95+
getAuthConfig,
9396
activeOrganization: { id: 'org_1', name: 'Acme' },
9497
}),
9598
useWorkspaceAdminStatus: () => ({ isAdmin: viewer.isAdmin, isResolved: viewer.isResolved }),
@@ -242,13 +245,15 @@ describe('AppContent holds every admin-dependent decision until the verdict land
242245
// The cost boundary: resolution gates the surface, it does not delay a
243246
// viewer whose verdict is already in hand. objectstack#35981 — the chrome
244247
// also waits for the deployment flags (`/auth/config`), which its
245-
// navigation gates read; the mock answers them at once, so the only wait
246-
// left is that answer's promise, never the admin verdict.
248+
// navigation gates read; the mock answers them at once, so the one wait
249+
// admitted is that answer's promise: a single flush, then the chrome must
250+
// be there.
247251
metadataApps = [{ name: 'crm', label: 'CRM', navigation: [] }];
248252
viewer.isAdmin = true;
249253
viewer.isResolved = true;
250254
renderConsoleAt('/apps/crm');
255+
await act(async () => {});
251256

252-
expect(await screen.findByTestId('console-layout')).toHaveAttribute('data-active-app', 'crm');
257+
expect(screen.getByTestId('console-layout')).toHaveAttribute('data-active-app', 'crm');
253258
});
254259
});

0 commit comments

Comments
 (0)