File size: 2,286 Bytes
a1b6014
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
61
62
63
64
65
66
67
68
69
70
import { describe, expect, it } from 'vitest'

import { planPluginOpenSession } from './plugin-open-session-plan'

describe('planPluginOpenSession', () => {
  it('defaults to navigation: dial the worker, do not steal chrome', () => {
    const plan = planPluginOpenSession({
      activeProfile: 'default',
      profile: 'worker'
    })

    expect(plan.switchWorkspace).toBeNull()
    expect(plan.dialWithoutSwitching).toBe('worker')
    expect(plan.showAllProfiles).toBe(true)
    expect(plan.requireActiveProfileForHydration).toBe(false)
  })

  it('does not steal chrome even when keepAllProfilesScope is explicitly true', () => {
    const plan = planPluginOpenSession({
      activeProfile: 'default',
      keepAllProfilesScope: true,
      profile: 'worker'
    })

    expect(plan.switchWorkspace).toBeNull()
    expect(plan.dialWithoutSwitching).toBe('worker')
    expect(plan.showAllProfiles).toBe(true)
    expect(plan.requireActiveProfileForHydration).toBe(false)
  })

  it('does not re-dial when chrome is already on that profile', () => {
    const plan = planPluginOpenSession({
      activeProfile: 'worker',
      keepAllProfilesScope: true,
      profile: 'worker'
    })

    expect(plan.switchWorkspace).toBeNull()
    expect(plan.dialWithoutSwitching).toBeNull()
    // Still restores the unified list: re-opening an already-live bot must not
    // leave Sessions collapsed onto a profile whose forever-chat is hidden.
    expect(plan.showAllProfiles).toBe(true)
  })

  it('treats keepAllProfilesScope:false as an explicit workspace switch', () => {
    const plan = planPluginOpenSession({
      activeProfile: 'default',
      keepAllProfilesScope: false,
      profile: 'worker'
    })

    expect(plan.switchWorkspace).toBe('worker')
    expect(plan.dialWithoutSwitching).toBeNull()
    expect(plan.showAllProfiles).toBe(false)
    expect(plan.requireActiveProfileForHydration).toBe(true)
  })

  it('treats an empty profile as neither a dial nor a workspace switch', () => {
    const plan = planPluginOpenSession({
      activeProfile: 'default',
      keepAllProfilesScope: true,
      profile: '  '
    })

    expect(plan.switchWorkspace).toBeNull()
    expect(plan.dialWithoutSwitching).toBeNull()
    expect(plan.showAllProfiles).toBeNull()
  })
})