mirror of
https://github.com/Gitlawb/openclaude.git
synced 2026-11-06 12:50:54 -04:00
test: restore leaked module mocks behind the remaining non-isolated shard failures (TA-001 round 2) (#2341)
* test: restore leaked module mocks behind the remaining non-isolated shard failures (TA-001 round 2) * test: restore real sessionStorage after resume tests (TA-001 round 2)
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
} from '../../test/sharedMutationLock.js'
|
||||
|
||||
type BrowserModule = typeof import('../../utils/browser.js')
|
||||
type ConfigModule = typeof import('../../utils/config.js')
|
||||
type ExecFileNoThrowModule = typeof import('../../utils/execFileNoThrow.js')
|
||||
|
||||
type ExecCall = {
|
||||
@@ -15,6 +16,7 @@ type ExecCall = {
|
||||
|
||||
type RealModules = {
|
||||
browser: BrowserModule
|
||||
config: ConfigModule
|
||||
execFileNoThrow: ExecFileNoThrowModule
|
||||
}
|
||||
|
||||
@@ -44,6 +46,9 @@ async function importRealModules(): Promise<RealModules> {
|
||||
browser: (await import(
|
||||
`../../utils/browser.ts?setup-actions-real-${cacheKey}`
|
||||
)) as BrowserModule,
|
||||
config: {
|
||||
...await import(`../../utils/config.js?real=${cacheKey}`),
|
||||
} as ConfigModule,
|
||||
execFileNoThrow: (await import(
|
||||
`../../utils/execFileNoThrow.ts?setup-actions-real-${cacheKey}`
|
||||
)) as ExecFileNoThrowModule,
|
||||
@@ -212,6 +217,8 @@ afterEach(() => {
|
||||
try {
|
||||
mock.restore()
|
||||
if (realModules) {
|
||||
mock.module('src/utils/config.js', () => realModules!.config)
|
||||
mock.module('../../utils/config.js', () => realModules!.config)
|
||||
mock.module(
|
||||
'../../utils/execFileNoThrow.js',
|
||||
() => realModules!.execFileNoThrow,
|
||||
|
||||
@@ -10,13 +10,29 @@ import { AppStateProvider } from '../../state/AppState.js'
|
||||
import type { LogOption, ReplayIndex } from '../../types/logs.js'
|
||||
import { renderToString } from '../../utils/staticRender.js'
|
||||
import * as realBootstrapState from '../../bootstrap/state.js'
|
||||
import * as realGetWorktreePaths from '../../utils/getWorktreePaths.js'
|
||||
import * as realSessionStorage from '../../utils/sessionStorage.js'
|
||||
import * as realReplayIndex from '../../utils/replayIndex.js'
|
||||
import * as realUseTerminalSize from '../../hooks/useTerminalSize.js'
|
||||
import * as realModalContext from '../../context/modalContext.js'
|
||||
import * as realLogSelector from '../../components/LogSelector.js'
|
||||
import * as realReplayTimeline from './ReplayTimeline.js'
|
||||
|
||||
const nonce = `${Date.now()}-${Math.random()}`
|
||||
const realGetWorktreePaths = {
|
||||
...await import(`../../utils/getWorktreePaths.js?real=${nonce}`),
|
||||
}
|
||||
const realSessionStorage = {
|
||||
...await import(`../../utils/sessionStorage.js?real=${nonce}`),
|
||||
}
|
||||
const realReplayIndex = {
|
||||
...await import(`../../utils/replayIndex.js?real=${nonce}`),
|
||||
}
|
||||
const realUseTerminalSize = {
|
||||
...await import(`../../hooks/useTerminalSize.js?real=${nonce}`),
|
||||
}
|
||||
const realModalContext = {
|
||||
...await import(`../../context/modalContext.js?real=${nonce}`),
|
||||
}
|
||||
const realLogSelector = {
|
||||
...await import(`../../components/LogSelector.js?real=${nonce}`),
|
||||
}
|
||||
const realReplayTimeline = {
|
||||
...await import(`./ReplayTimeline.js?real=${nonce}`),
|
||||
}
|
||||
|
||||
type LogSelectorProps = {
|
||||
logs: LogOption[]
|
||||
|
||||
@@ -18,6 +18,10 @@ import type {
|
||||
LocalJSXCommandOnDone,
|
||||
} from '../../types/command.js'
|
||||
|
||||
const realSessionStorage = {
|
||||
...await import(`../../utils/sessionStorage.js?real=${Date.now()}-${Math.random()}`),
|
||||
}
|
||||
|
||||
type OnDoneArgs = Parameters<LocalJSXCommandOnDone>
|
||||
|
||||
let saveGoalStateMock: ReturnType<typeof mock>
|
||||
@@ -196,6 +200,7 @@ describe('/resume and /continue unified command', () => {
|
||||
|
||||
afterEach(() => {
|
||||
mock.restore()
|
||||
mock.module('../../utils/sessionStorage.js', () => realSessionStorage)
|
||||
})
|
||||
|
||||
test('/continue continues an active goal', async () => {
|
||||
|
||||
@@ -3,8 +3,6 @@ import { PassThrough } from 'node:stream'
|
||||
import { afterAll, afterEach, beforeEach, expect, mock, test } from 'bun:test'
|
||||
import React from 'react'
|
||||
import { createRoot, Text } from '../ink.js'
|
||||
import * as realState from '../bootstrap/state.js'
|
||||
import * as realClaudeApi from '../services/api/claude.js'
|
||||
import {
|
||||
acquireSharedMutationLock,
|
||||
releaseSharedMutationLock,
|
||||
@@ -14,6 +12,12 @@ const nonce = `${Date.now()}-${Math.random()}`
|
||||
const realAuth = {
|
||||
...await import(`../utils/auth.js?real=${nonce}`),
|
||||
}
|
||||
const realState = {
|
||||
...await import(`../bootstrap/state.js?real=${nonce}`),
|
||||
}
|
||||
const realClaudeApi = {
|
||||
...await import(`../services/api/claude.js?real=${nonce}`),
|
||||
}
|
||||
|
||||
type AuthState = {
|
||||
anthropicAuthEnabled: boolean
|
||||
|
||||
@@ -2,8 +2,13 @@ import { afterEach, beforeEach, expect, mock, test } from 'bun:test'
|
||||
import type { AgentDefinition } from './loadAgentsDir.js'
|
||||
import type { ToolUseContext } from '../../Tool.js'
|
||||
|
||||
const actualSessionStorage = { ...await import('../../utils/sessionStorage.js') }
|
||||
const actualQuery = { ...await import('../../query.js') }
|
||||
const nonce = `${Date.now()}-${Math.random()}`
|
||||
const actualSessionStorage = {
|
||||
...await import(`../../utils/sessionStorage.js?real=${nonce}`),
|
||||
}
|
||||
const actualQuery = {
|
||||
...await import(`../../query.js?real=${nonce}`),
|
||||
}
|
||||
|
||||
// Track how many times each storage function is called
|
||||
let metadataWriteCount = 0
|
||||
@@ -16,6 +21,8 @@ beforeEach(() => {
|
||||
|
||||
afterEach(() => {
|
||||
mock.restore()
|
||||
mock.module('../../utils/sessionStorage.js', () => actualSessionStorage)
|
||||
mock.module('../../query.js', () => actualQuery)
|
||||
})
|
||||
|
||||
/** Load runAgent with a failing metadata writer while retaining unrelated module exports. */
|
||||
|
||||
@@ -5,9 +5,13 @@ import {
|
||||
} from '../../test/sharedMutationLock.js'
|
||||
import { parseForSecurityFromAst } from '../../utils/bash/ast.js'
|
||||
import { PARSE_ABORTED } from '../../utils/bash/parser.js'
|
||||
import * as realDebug from '../../utils/debug.js'
|
||||
import { analyzeBashCommand } from './bashCommandAnalysis.js'
|
||||
|
||||
const nonce = `${Date.now()}-${Math.random()}`
|
||||
const realDebug = {
|
||||
...await import(`../../utils/debug.js?real=${nonce}`),
|
||||
}
|
||||
|
||||
let importCounter = 0
|
||||
|
||||
beforeEach(async () => {
|
||||
|
||||
Reference in New Issue
Block a user