mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(e2e): stop the login page requesting linked servers and update the background-activity test
This commit is contained in:
1 parent
052f2bbe04
commit
884233d95c
5 files changed
+44
-11
No files matched your search
@@ -7,6 +7,7 @@ import { SIDEBAR_SERVER_STORAGE_KEY, useSidebarServerStore } from '@/stores/side
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
useOpenCodeServers: vi.fn(),
|
||||
useAuth: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useOpenCodeServers', () => ({
|
||||
@@ -14,6 +15,10 @@ vi.mock('@/hooks/useOpenCodeServers', () => ({
|
||||
useOpenCodeServerStatuses: () => ({ statuses: [], statusById: {}, isLoading: false }),
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useAuth', () => ({
|
||||
useAuth: mocks.useAuth,
|
||||
}))
|
||||
|
||||
const kitchen = {
|
||||
id: 'srv_kitchen',
|
||||
name: 'Kitchen',
|
||||
@@ -85,6 +90,7 @@ function renderHarness(initialEntry = '/', options?: { syncRoute?: boolean }) {
|
||||
function resetSelection() {
|
||||
localStorage.clear()
|
||||
useSidebarServerStore.setState({ serverId: LOCAL_OPENCODE_SERVER_ID })
|
||||
mocks.useAuth.mockReturnValue({ isAuthenticated: true })
|
||||
mocks.useOpenCodeServers.mockReturnValue({
|
||||
servers: [kitchen, office],
|
||||
isLoading: false,
|
||||
@@ -215,6 +221,14 @@ describe('useSidebarServerRouteSync', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('does not load the server list while unauthenticated', () => {
|
||||
mocks.useAuth.mockReturnValue({ isAuthenticated: false })
|
||||
|
||||
renderHarness('/')
|
||||
|
||||
expect(mocks.useOpenCodeServers).toHaveBeenCalledWith({ enabled: false })
|
||||
})
|
||||
|
||||
it('follows a linked server route with no sidebar consumer mounted', async () => {
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/']}>
|
||||
|
||||
Reference in new issue
Block a user