chore: stabilize Zhinian pilot delivery
This commit is contained in:
@@ -53,6 +53,7 @@ describe('useYinianStore', () => {
|
||||
error: null,
|
||||
});
|
||||
vi.mocked(window.yinian.auth.restoreSession).mockReset();
|
||||
vi.mocked(window.yinian.auth.getSessionState).mockReset();
|
||||
vi.mocked(window.yinian.auth.loginWithPassword).mockReset();
|
||||
vi.mocked(window.yinian.auth.logout).mockReset();
|
||||
vi.mocked(window.yinian.app.getConfig).mockReset();
|
||||
@@ -75,6 +76,34 @@ describe('useYinianStore', () => {
|
||||
expect(window.yinian.skills.getRegistry).toHaveBeenCalledWith('workspace_hangzhou_ops');
|
||||
});
|
||||
|
||||
it('falls back to session state when restoreSession handler is not registered yet', async () => {
|
||||
vi.mocked(window.yinian.auth.restoreSession).mockRejectedValueOnce(
|
||||
new Error("Error invoking remote method 'yinian:auth:restoreSession': Error: No handler registered for 'yinian:auth:restoreSession'"),
|
||||
);
|
||||
vi.mocked(window.yinian.auth.getSessionState).mockResolvedValueOnce({ authenticated: false });
|
||||
|
||||
await useYinianStore.getState().init();
|
||||
|
||||
expect(window.yinian.auth.getSessionState).toHaveBeenCalled();
|
||||
expect(useYinianStore.getState().status).toBe('unauthenticated');
|
||||
expect(useYinianStore.getState().error).toBeNull();
|
||||
});
|
||||
|
||||
it('opens login when yinian auth handlers are absent in a mismatched build', async () => {
|
||||
vi.mocked(window.yinian.auth.restoreSession).mockRejectedValueOnce(
|
||||
new Error("Error invoking remote method 'yinian:auth:restoreSession': Error: No handler registered for 'yinian:auth:restoreSession'"),
|
||||
);
|
||||
vi.mocked(window.yinian.auth.getSessionState).mockRejectedValueOnce(
|
||||
new Error("Error invoking remote method 'yinian:auth:getSessionState': Error: No handler registered for 'yinian:auth:getSessionState'"),
|
||||
);
|
||||
|
||||
await useYinianStore.getState().init();
|
||||
|
||||
expect(useYinianStore.getState().status).toBe('unauthenticated');
|
||||
expect(useYinianStore.getState().session.authenticated).toBe(false);
|
||||
expect(useYinianStore.getState().error).toBeNull();
|
||||
});
|
||||
|
||||
it('switches workspace and refreshes registry for the new hotel', async () => {
|
||||
const switched = { ...session, currentHotelId: 'workspace_shanghai_growth' };
|
||||
vi.mocked(window.yinian.app.switchHotel).mockResolvedValueOnce(switched);
|
||||
|
||||
Reference in New Issue
Block a user