Skip to content

Commit 18be13b

Browse files
authored
mods: the diff, sec-default and telemetry tests move next to the mods (#93951)
Squash merge of 4 commits
1 parent b593276 commit 18be13b

204 files changed

Lines changed: 5277 additions & 52 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎mods/diff/hooks/ask/fitted-ask-text-of.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function fittedAskTextOf(
1717
}
1818

1919
const kept: string[] = []
20+
2021
let used = ASK_CUT_NOTE.length
2122

2223
for (const line of text.split('\n')) {

‎mods/diff/hooks/git/parse/parse-numstat.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function parseNumstat(
2020
const files: Types.FileStat[] = []
2121
const stats = { filesCount: 0, linesAdded: 0, linesRemoved: 0 }
2222
const records = stdout.split('\0')
23+
2324
let at = 0
2425

2526
while (at < records.length) {

‎mods/diff/hooks/git/probes/kind-walk-of/kind-walk-of.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export function kindWalkOf(
4141

4242
async function kindOf(path: string): Promise<Types.WalkKind> {
4343
const names = path === '' ? [] : path.split('/')
44+
4445
let directory = ''
4546

4647
for (const [depth, name] of names.entries()) {

‎mods/diff/hooks/register.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ export function register(on: On) {
4343
let isRefreshQueued = false
4444
let generation = 0
4545
let bodyKey: string | null = null
46+
4647
const polled = { toplevel: '', headKey: '' }
48+
4749
let model: PaneState.PaneModel = PaneState.INITIAL_MODEL
50+
4851
const timers = new Map<'refresh' | 'redraw' | 'poll', Timer>()
4952
const loggedBaseKinds = new Set<'ok' | 'sad'>()
5053

‎mods/diff/hooks/views/detail/code-blocks-of/code-blocks-of.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { drawnLineOf } from './drawn-line-of'
2323
*/
2424
export function codeBlocksOf(hunks: readonly Git.Hunk[]): Types.CodeBody {
2525
const blocks: Types.CodeBlock[] = []
26+
2627
let chars = 0
2728
let nodes = 0
2829
let isTruncated = false

‎mods/diff/hooks/views/detail/sub-hunks-of/sub-hunks-of.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export function subHunksOf(
1919
maxChars: number,
2020
): Pick<Git.FileHunks, 'hunks' | 'isTruncated'> {
2121
const hunks: Git.Hunk[] = []
22+
2223
let rest = hunk
2324
let isTruncated = false
2425

‎mods/diff/hooks/views/layout/truncate-start/truncate-start.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export function truncateStart(text: string, cells: number) {
1818
}
1919

2020
const characters = [...text]
21+
2122
let kept = ''
2223

2324
for (let at = characters.length - 1; at >= 0; at--) {

‎mods/diff/hooks/views/layout/wrapped-lines/wrapped-lines.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export function wrappedLines(text: string, columns: number): string[] {
1818

1919
for (const [index, word] of words.entries()) {
2020
const wordWidth = cellWidth(word)
21+
2122
let rowWidth = cellWidth(rows[rows.length - 1] ?? '')
2223

2324
if (index !== 0) {
@@ -39,6 +40,7 @@ export function wrappedLines(text: string, columns: number): string[] {
3940
}
4041

4142
const characters = [...word]
43+
4244
let visible = cellWidth(rows[rows.length - 1] ?? '')
4345

4446
for (const [at, character] of characters.entries()) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { describe, expect, test, tier } from 'claude-code/testing'
2+
3+
import Ask from '../../hooks/ask'
4+
import Fixtures from '../fixtures'
5+
6+
tier('builtin')
7+
8+
describe('fitted-ask-text-of', () => {
9+
test('an ask that fits rides whole', () => {
10+
expect(
11+
Ask.fittedAskTextOf(Fixtures.ASK_TEXT, Fixtures.ASK_TEXT.length),
12+
).toBe(Fixtures.ASK_TEXT)
13+
})
14+
15+
test('an ask past the room keeps its first lines and the cut note', () => {
16+
const fitted = Ask.fittedAskTextOf(
17+
Fixtures.ASK_TEXT,
18+
Fixtures.ROOM_FOR_TWO_LINES,
19+
)
20+
21+
expect(fitted).toBe(
22+
`${Fixtures.ASK_LINES.slice(0, 2).join('\n')}\n${Ask.ASK_CUT_NOTE}`,
23+
)
24+
25+
expect(fitted?.length).toBeLessThanOrEqual(Fixtures.ROOM_FOR_TWO_LINES)
26+
})
27+
28+
test('an ask whose first hunk line does not fit is not attached', () => {
29+
expect(
30+
Ask.fittedAskTextOf(Fixtures.ASK_TEXT, Fixtures.ROOM_FOR_ONE_LINE),
31+
).toBeUndefined()
32+
})
33+
})
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { describe, expect, test, tier } from 'claude-code/testing'
2+
3+
import Backend from '../../hooks/backend'
4+
import Fixtures from '../fixtures'
5+
6+
tier('builtin')
7+
8+
describe('backend-of', () => {
9+
test('as published: no probes, so git or nothing', async () => {
10+
const inGit = Fixtures.gitHostOf()
11+
const outside = Fixtures.recordingBackendHostOf({})
12+
13+
expect((await Backend.backendOf(inGit.host, []))?.words.lister).toBe('git')
14+
expect(await Backend.backendOf(outside.host, [])).toBeNull()
15+
expect([inGit.programs, outside.programs]).toEqual([['git'], ['git']])
16+
})
17+
18+
test('a declining probe leaves a git working tree to git', async () => {
19+
const declining = Fixtures.recordingProbeOf(null)
20+
const inGit = Fixtures.gitHostOf()
21+
const backend = await Backend.backendOf(inGit.host, [declining.probe])
22+
23+
expect(backend?.words.lister).toBe('git')
24+
expect(backend?.baseModes).toEqual(['session', 'uncommitted', 'branch'])
25+
expect(declining.asked).toEqual([inGit.host])
26+
expect(inGit.programs).toEqual(['git'])
27+
})
28+
29+
test('a probe that answers pins before git is asked', async () => {
30+
const inGit = Fixtures.gitHostOf()
31+
32+
const backend = await Backend.backendOf(inGit.host, [
33+
Fixtures.recordingProbeOf('/home/me/src').probe,
34+
])
35+
36+
expect(backend?.repository).toEqual({ toplevel: '/home/me/src' })
37+
expect(inGit.programs).toEqual([])
38+
})
39+
40+
test('the probes are asked in order and the first answer pins', async () => {
41+
const declining = Fixtures.recordingProbeOf(null)
42+
const first = Fixtures.recordingProbeOf('/first')
43+
const second = Fixtures.recordingProbeOf('/second')
44+
const { host } = Fixtures.recordingBackendHostOf({})
45+
46+
const backend = await Backend.backendOf(host, [
47+
declining.probe,
48+
first.probe,
49+
second.probe,
50+
])
51+
52+
expect(backend?.repository).toEqual({ toplevel: '/first' })
53+
54+
expect([
55+
declining.asked.length,
56+
first.asked.length,
57+
second.asked.length,
58+
]).toEqual([1, 1, 0])
59+
60+
expect(declining.asked[0]).toBe(host)
61+
})
62+
})

0 commit comments

Comments
 (0)