feat: update desktop workflows and app center
This commit is contained in:
38
tests/unit/product-center-url.test.ts
Normal file
38
tests/unit/product-center-url.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildProductCenterSrc } from '@/pages/ProductCenter/url';
|
||||
|
||||
describe('Product Center launch URL', () => {
|
||||
it('adds desktop embed context without inventing SSO credentials', () => {
|
||||
const src = buildProductCenterSrc({
|
||||
baseUrl: 'https://ticket.nianxx.cn/',
|
||||
reloadKey: 3,
|
||||
session: {
|
||||
authenticated: true,
|
||||
user: { id: 'user-1', name: '王管理员' },
|
||||
hotels: [{ id: 'workspace-1', name: '智念空间' }],
|
||||
currentHotelId: 'workspace-1',
|
||||
accessTokenExpiresAt: 100,
|
||||
},
|
||||
});
|
||||
const url = new URL(src);
|
||||
|
||||
expect(url.origin).toBe('https://ticket.nianxx.cn');
|
||||
expect(url.searchParams.get('zhinianEmbed')).toBe('1');
|
||||
expect(url.searchParams.get('zhinianApp')).toBe('product-center');
|
||||
expect(url.searchParams.get('zhinianHostReload')).toBe('3');
|
||||
expect(url.searchParams.get('workspaceId')).toBe('workspace-1');
|
||||
expect(url.searchParams.get('userId')).toBe('user-1');
|
||||
expect(url.searchParams.has('ssoToken')).toBe(false);
|
||||
});
|
||||
|
||||
it('can carry a future short-lived SSO ticket when one is provided', () => {
|
||||
const src = buildProductCenterSrc({
|
||||
baseUrl: 'https://ticket.nianxx.cn/',
|
||||
reloadKey: 0,
|
||||
session: { authenticated: false },
|
||||
ssoToken: 'one-time-ticket',
|
||||
});
|
||||
|
||||
expect(new URL(src).searchParams.get('ssoToken')).toBe('one-time-ticket');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user