File size: 1,872 Bytes
a8fb296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { describe, expect, it } from 'vitest'
import {
  fullRunPhaseFromLog,
  fullRunPhaseLabel,
  stageOwnsFullRunLog,
} from './batchJobFullRunPhase'

describe('fullRunPhaseFromLog', () => {
  it('defaults Run all to Discover before any banner', () => {
    expect(fullRunPhaseFromLog([], '', { step: 'all' })).toBe('discover')
  })

  it('defaults Run each to Videos (no Discover)', () => {
    expect(fullRunPhaseFromLog([], '', { step: 'each' })).toBe('videos')
  })

  it('stays on Discover while channel candidates run', () => {
    const lines = [
      '=== Discover (channel candidates) ===',
      'Discovering YouTube channels for Coffee, AL',
      'Testing 13 common handle patterns...',
    ]
    expect(
      fullRunPhaseFromLog(lines, '--- Discover (channel candidates) ---', {
        step: 'all',
      }),
    ).toBe('discover')
  })

  it('moves to Videos once Catalog banner appears', () => {
    const lines = [
      '=== Discover (channel candidates) ===',
      '=== Catalog → captions → analyze-light → reports-light ===',
      '=== Catalog: max 10 video(s) per channel ===',
      '--- Catalog: AL — Anniston ---',
    ]
    expect(fullRunPhaseFromLog(lines, '--- Catalog: AL — Anniston ---', { step: 'all' })).toBe(
      'videos',
    )
  })
})

describe('stageOwnsFullRunLog', () => {
  it('does not give Videos the Discover log', () => {
    expect(stageOwnsFullRunLog('videos', 'discover')).toBe(false)
    expect(stageOwnsFullRunLog('discover', 'discover')).toBe(true)
  })

  it('gives Videos the shared log only in catalog phase', () => {
    expect(stageOwnsFullRunLog('videos', 'videos')).toBe(true)
    expect(stageOwnsFullRunLog('discover', 'videos')).toBe(false)
  })
})

describe('fullRunPhaseLabel', () => {
  it('labels Discover clearly', () => {
    expect(fullRunPhaseLabel('discover')).toBe('Discover')
  })
})