优化邀请码链接自动打开流程
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-05-07 17:09:20 +08:00
parent 89be59d701
commit 9146e5b8ec
3 changed files with 83 additions and 3 deletions

View File

@@ -692,6 +692,7 @@ afterEach(() => {
configurable: true,
value: undefined,
});
window.history.replaceState(null, '', '/');
});
test('opens wallet ledger modal from narrative coin card', async () => {
@@ -859,6 +860,37 @@ test('profile redeem invite shortcut hides after redeemed or one day old', async
).toBeNull();
});
test('invite query opens login modal for logged out users', async () => {
const openLoginModal = vi.fn();
window.history.replaceState(null, '', '/?inviteCode=spring-2026');
renderLoggedOutHomeView(openLoginModal);
await waitFor(() => {
expect(openLoginModal).toHaveBeenCalledTimes(1);
});
});
test('invite query opens redeem modal directly for logged in users', async () => {
window.history.replaceState(null, '', '/?inviteCode=spring-2026');
renderProfileView();
const input = await screen.findByLabelText('邀请码');
expect((input as HTMLInputElement).value).toBe('SPRING2026');
});
test('profile redeem invite modal reads query invite code after login', async () => {
window.history.replaceState(null, '', '/?inviteCode=spring-2026');
renderProfileView();
const input = await screen.findByLabelText('邀请码');
expect((input as HTMLInputElement).value).toBe('SPRING2026');
});
test('profile redeem invite modal submits code and hides shortcut after success', async () => {
const user = userEvent.setup();
const onRechargeSuccess = vi.fn();