Revert "feat(makelore): add platform oidc login"
This reverts commit 7236def07d.
This commit is contained in:
1 parent
f2a0eefc9e
commit
e28beff3a6
11 files changed
+10
-475
No files matched your search
@@ -8,16 +8,11 @@ import { useProviderStore } from '@/stores/providers';
|
||||
import { codingRecoveryAccount } from '@/lib/coding-login-recovery';
|
||||
|
||||
const hostApiFetchMock = vi.hoisted(() => vi.fn());
|
||||
const invokeIpcMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock('@/lib/host-api', () => ({
|
||||
hostApiFetch: (...args: unknown[]) => hostApiFetchMock(...args),
|
||||
}));
|
||||
|
||||
vi.mock('@/lib/api-client', () => ({
|
||||
invokeIpc: (...args: unknown[]) => invokeIpcMock(...args),
|
||||
}));
|
||||
|
||||
const loginWithPassword = vi.fn();
|
||||
const loginWithMobile = vi.fn();
|
||||
const logout = vi.fn();
|
||||
@@ -133,7 +128,6 @@ describe('Login page', () => {
|
||||
useProviderStore.setState({ importUserModelConfig });
|
||||
importUserModelConfig.mockResolvedValue(undefined);
|
||||
logout.mockResolvedValue(undefined);
|
||||
invokeIpcMock.mockResolvedValue(undefined);
|
||||
hostApiFetchMock.mockImplementation(async (path: string) => {
|
||||
if (path === '/api/auth/public-config') {
|
||||
return {
|
||||
@@ -159,7 +153,7 @@ describe('Login page', () => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('shows native Chinese tabs with password login as the default and a platform login action', async () => {
|
||||
it('shows native Chinese tabs with password login as the default and no browser authorization surface', async () => {
|
||||
renderLogin();
|
||||
|
||||
await screen.findByRole('link', { name: '用户协议' });
|
||||
@@ -174,36 +168,9 @@ describe('Login page', () => {
|
||||
loginButton.compareDocumentPosition(rememberPasswordCheckbox)
|
||||
& Node.DOCUMENT_POSITION_FOLLOWING,
|
||||
).toBe(Node.DOCUMENT_POSITION_FOLLOWING);
|
||||
expect(screen.getByRole('button', { name: '平台账号登录' })).toBeDisabled();
|
||||
expect(screen.queryByText(/浏览器|微信|注册/)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('opens the platform authorization URL through Main after agreement', async () => {
|
||||
hostApiFetchMock.mockImplementation(async (path: string) => {
|
||||
if (path === '/api/auth/public-config') return { success: true, links: {} };
|
||||
if (path === '/api/auth/remembered-password') return { success: true, available: false };
|
||||
if (path === '/api/auth/platform/start') {
|
||||
return { success: true, authorizationUrl: 'https://square.example.test/authorize?state=state-1' };
|
||||
}
|
||||
return { success: true };
|
||||
});
|
||||
renderLogin();
|
||||
|
||||
const agreement = await screen.findByRole('checkbox', { name: /我已阅读并同意/ });
|
||||
fireEvent.click(agreement);
|
||||
fireEvent.click(screen.getByRole('button', { name: '平台账号登录' }));
|
||||
|
||||
await waitFor(() => expect(invokeIpcMock).toHaveBeenCalledWith(
|
||||
'shell:openExternal',
|
||||
'https://square.example.test/authorize?state=state-1',
|
||||
));
|
||||
expect(hostApiFetchMock).toHaveBeenCalledWith('/api/auth/platform/start', {
|
||||
method: 'POST',
|
||||
cache: 'no-store',
|
||||
body: JSON.stringify({}),
|
||||
});
|
||||
});
|
||||
|
||||
it('restores OS-protected password credentials and keeps remember password selected', async () => {
|
||||
hostApiFetchMock.mockImplementation(async (path: string) => {
|
||||
if (path === '/api/auth/public-config') return { success: true, links: {} };
|
||||
|
||||
Reference in new issue
Block a user