fix: keep recommend runtime on local auth
This commit is contained in:
@@ -554,6 +554,8 @@ const AGENT_RESULT_STRUCTURAL_BLOCKER_CODES = new Set([
|
||||
]);
|
||||
const RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS =
|
||||
BACKGROUND_AUTH_REQUEST_OPTIONS;
|
||||
const RECOMMEND_PUZZLE_BACKGROUND_AUTH_OPTIONS =
|
||||
RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS;
|
||||
async function buildRecommendRuntimeGuestOptions() {
|
||||
const { token } = await ensureRuntimeGuestToken();
|
||||
return {
|
||||
@@ -8677,10 +8679,15 @@ export function PlatformEntryFlowShellImpl({
|
||||
? await buildRecommendRuntimeGuestOptions()
|
||||
: {};
|
||||
const authMode = useRuntimeGuestAuth ? 'isolated' : 'default';
|
||||
const runtimeAuthOptions = useRuntimeGuestAuth
|
||||
? runtimeGuestOptions
|
||||
: canUseRuntimeGuestAuth
|
||||
? RECOMMEND_PUZZLE_BACKGROUND_AUTH_OPTIONS
|
||||
: {};
|
||||
const { run } =
|
||||
authMode === 'isolated'
|
||||
? await startPuzzleRun(startRunPayload, runtimeGuestOptions)
|
||||
: await startPuzzleRun(startRunPayload);
|
||||
: await startPuzzleRun(startRunPayload, runtimeAuthOptions);
|
||||
setSelectedPuzzleDetail(item);
|
||||
setPuzzleRun(run);
|
||||
setPuzzleRuntimeAuthMode(authMode);
|
||||
|
||||
@@ -310,6 +310,7 @@ const RECOMMEND_RUNTIME_AUTH_OPTIONS = {
|
||||
...ISOLATED_RUNTIME_AUTH_OPTIONS,
|
||||
runtimeGuestToken: 'runtime-guest-token',
|
||||
};
|
||||
const LOGGED_IN_RECOMMEND_RUNTIME_AUTH_OPTIONS = ISOLATED_RUNTIME_AUTH_OPTIONS;
|
||||
|
||||
function getPlatformTabPanel(tab: string) {
|
||||
const panel = document.getElementById(`platform-tab-panel-${tab}`);
|
||||
@@ -6179,7 +6180,7 @@ test('home recommendation starts embedded puzzle without global auth reset on lo
|
||||
profileId: 'puzzle-profile-public-1',
|
||||
levelId: null,
|
||||
},
|
||||
RECOMMEND_RUNTIME_AUTH_OPTIONS,
|
||||
LOGGED_IN_RECOMMEND_RUNTIME_AUTH_OPTIONS,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -6219,10 +6220,16 @@ test('home recommendation keeps logged-in puzzle start on default auth instead o
|
||||
profileId: 'puzzle-profile-public-2',
|
||||
levelId: null,
|
||||
},
|
||||
expect.objectContaining({
|
||||
authImpact: 'local',
|
||||
skipRefresh: true,
|
||||
notifyAuthStateChange: false,
|
||||
clearAuthOnUnauthorized: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
expect(vi.mocked(startPuzzleRun).mock.calls[0]?.[1]).not.toEqual(
|
||||
ISOLATED_RUNTIME_AUTH_OPTIONS,
|
||||
expect(vi.mocked(startPuzzleRun).mock.calls[0]?.[1]).not.toHaveProperty(
|
||||
'runtimeGuestToken',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -6284,7 +6291,7 @@ test('home recommendation Match3D runtime keeps profile generated models when ca
|
||||
await waitFor(() => {
|
||||
expect(match3dServerRuntimeAdapterMock.startRun).toHaveBeenCalledWith(
|
||||
'match3d-profile-card-1',
|
||||
RECOMMEND_RUNTIME_AUTH_OPTIONS,
|
||||
LOGGED_IN_RECOMMEND_RUNTIME_AUTH_OPTIONS,
|
||||
);
|
||||
});
|
||||
await waitFor(() => {
|
||||
@@ -6603,11 +6610,13 @@ test('home recommendation surfaces start failure instead of staying in loading s
|
||||
expect(
|
||||
await screen.findByText('作品暂时无法进入,请稍后再试。'),
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
within(getPlatformTabPanel('home'))
|
||||
.queryByText('加载中...')
|
||||
?.closest('.platform-recommend-runtime-panel'),
|
||||
).toBeFalsy();
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
within(getPlatformTabPanel('home'))
|
||||
.queryByText('加载中...')
|
||||
?.closest('.platform-recommend-runtime-panel'),
|
||||
).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
test('published big fish works stay hidden from platform home and game category channel', async () => {
|
||||
|
||||
@@ -2783,19 +2783,28 @@ test('logged out desktop recommend rail enters runtime without login modal', asy
|
||||
const user = userEvent.setup();
|
||||
const openLoginModal = vi.fn();
|
||||
|
||||
renderLoggedOutHomeView(
|
||||
const { container } = renderLoggedOutHomeView(
|
||||
openLoginModal,
|
||||
{
|
||||
latestEntries: [puzzlePublicEntry],
|
||||
activeRecommendEntryKey: 'puzzle:user-2:puzzle-profile-public-1',
|
||||
},
|
||||
'category',
|
||||
true,
|
||||
);
|
||||
|
||||
await user.click(screen.getByRole('button', { name: '推荐' }));
|
||||
const desktopRail = container.querySelector('.platform-desktop-rail');
|
||||
if (!desktopRail) {
|
||||
throw new Error('缺少桌面侧边栏');
|
||||
}
|
||||
|
||||
await user.click(
|
||||
within(desktopRail as HTMLElement).getByRole('button', { name: '推荐' }),
|
||||
);
|
||||
|
||||
expect(openLoginModal).not.toHaveBeenCalled();
|
||||
expect(screen.getByTestId('recommend-runtime')).toBeTruthy();
|
||||
expect(screen.queryByTestId('recommend-runtime')).toBeNull();
|
||||
expect(container.querySelector('.platform-desktop-shell')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('logged in recommend page uses gated recommend detail callback', async () => {
|
||||
|
||||
Reference in New Issue
Block a user