fixer: address PR #8240 follow-up items

Generated-By: looper 0.13.0 (runner=fixer, agent=codex)
This commit is contained in:
Siri-Ray
2026-09-18 16:13:47 +08:00
parent 8ee3a105c1
commit 0fdd577c1c
2 changed files with 29 additions and 8 deletions
@@ -11,7 +11,7 @@
// behaviour (pending frame within one animation frame of the click); this
// file pins the contract between EntryShell and App that makes it possible.
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
import type { ComponentProps } from 'react';
import {
buildWorkspacePermissions,
@@ -523,12 +523,22 @@ describe('OPEND-3300 · a Team member at $0 is asked to find the owner on Home',
it('identity read that never settles: the send returns to Home with the balance notice and gates nothing', async () => {
installFetch(teamMemberContext(), { holdIdentity: true });
const h = harness('amr');
await submitHome('Design the onboarding flow.');
await waitFor(() => expect(h.onBeginProjectCreation).toHaveBeenCalledTimes(1));
await screen.findByTestId('home-hero-input');
setHomeHeroPrompt('Design the onboarding flow.');
// Capture the polling timer from its creation at Send, not midway through
// a real-time wait whose pending callback fake timers cannot advance.
vi.useFakeTimers();
await vi.advanceTimersByTimeAsync(HOME_AMR_GATE_CONTEXT_SETTLE_MS + 200);
vi.useRealTimers();
await waitFor(() => expect(h.rollback).toHaveBeenCalledTimes(1));
fireEvent.click(screen.getByTestId('home-hero-submit'));
expect(h.onBeginProjectCreation).toHaveBeenCalledTimes(1);
await act(async () => {
await vi.advanceTimersByTimeAsync(HOME_AMR_GATE_CONTEXT_SETTLE_MS - 1);
});
expect(h.rollback).not.toHaveBeenCalled();
expect(mockedCheckAmrBalanceGate).not.toHaveBeenCalled();
await act(async () => {
await vi.advanceTimersByTimeAsync(1);
});
expect(h.rollback).toHaveBeenCalledTimes(1);
expect(h.rollback).toHaveBeenCalledWith({
notice: 'Couldn\'t confirm your OpenDesign Cloud balance. Try sending again.',
});
@@ -135,7 +135,7 @@ describe('EntryShell AMR workspace precheck race', () => {
});
it.each(['get', 'set'] as const)(
'starts the team gate from in-memory directory identity when sessionStorage %sItem fails',
'waits for the team identity before gating when sessionStorage %sItem fails',
async (blockedOperation) => {
window.history.replaceState(null, '', '/');
if (blockedOperation === 'get') {
@@ -228,7 +228,18 @@ describe('EntryShell AMR workspace precheck race', () => {
setHomeHeroPrompt('Create a launch poster without waiting for account chrome.');
fireEvent.click(await screen.findByTestId('home-hero-submit'));
await waitFor(() => expect(mockedCheckAmrBalanceGate).toHaveBeenCalled());
// Without a session selection the directory alone cannot publish an
// exact read identity. Do not fall back to gating the personal wallet.
expect(mockedCheckAmrBalanceGate).not.toHaveBeenCalled();
expect(onCreateProject).not.toHaveBeenCalled();
await act(async () => {
contextRead.resolve(jsonResponse({ context: workspace }));
});
await waitFor(() => expect(mockedCheckAmrBalanceGate).toHaveBeenCalledWith({
workspaceType: 'team',
workspaceId: workspace.workspaceId,
workspaceMemberId: workspace.workspaceMemberId,
}, 'glm-5'));
await waitFor(() => expect(onCreateProject).toHaveBeenCalledTimes(1));
expect(directoryReads).toBe(1);
},