Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/** A result for a degenerate run that rendered nothing (no steps / all steps skipped). */
function
notShownResult
(
)
:
{
return
{
:
.
,
:
false
,
:
.
,
:
0
,
:
0
}
;
}
/** Captures the names of `publicLog2` telemetry events. */
class
CapturingTelemetryService
extends
NullTelemetryServiceShape
{
readonly
:
string
[
]
=
[
]
;
readonly
:
{
readonly
:
string
;
readonly
:
unknown
}
[
]
=
[
]
;
publicLog2
(
?
:
string
,
?
:
unknown
)
:
void
{
if
(
)
{
this
.
.
push
(
)
;
this
.
.
push
(
{
:
,
}
)
;
}
}
}
/** A presentation that resolves with a fixed run result. */
class
FixedResultPresentation
implements
IOnboardingPresentation
{
constructor
(
readonly
:
string
,
private
readonly
:
)
{
}
async
run
(
:
,
:
)
:
Promise
<
>
{
return
this
.
;
}
}
/** A presentation that reports its first rendered element before completing. */
class
ShownPresentation
implements
IOnboardingPresentation
{
constructor
(
readonly
:
string
)
{
}
async
run
(
:
,
:
)
:
Promise
<
>
{
.
?.
(
)
;
.
?.
(
)
;
return
completedResult
(
)
;
}
}
/** Records every scenario it renders, then resolves with a fixed outcome. */
class
RecordingPresentation
implements
IOnboardingPresentation
{
readonly
:
string
[
]
=
[
]
;
constructor
(
readonly
:
string
,
private
readonly
:
=
.
,
private
readonly
?
:
(
)
=>
void
,
)
{
}
async
run
(
:
,
:
)
:
Promise
<
>
{
this
.
.
push
(
.
)
;
this
.
?.
(
)
;
return
completedResult
(
this
.
)
;
}
}
/** Blocks until the engine aborts the run (used to test shutdown behaviour). */
class
BlockingUntilAbortPresentation
implements
IOnboardingPresentation
{
readonly
:
string
[
]
=
[
]
;
constructor
(
readonly
:
string
)
{
}
run
(
:
,
:
)
:
Promise
<
>
{
this
.
.
push
(
.
)
;
return
new
Promise<IOnboardingRunResult>
(
=>
{
const
=
.
onAbort
(
(
)
=>
{
.
dispose
(
)
;
resolve
(
completedResult
(
.
)
)
;
}
)
;
}
)
;
}
}
/**
* Assignment service test double that returns canned treatments and records the registered
* telemetry filter so tests can assert which assignment-context ids would be excluded.
*/
class
FakeAssignmentService
extends
NullWorkbenchAssignmentService
{
private
readonly
:
[
]
=
[
]
;
constructor
(
private
readonly
:
<
string
,
string
|
number
|
boolean
>
)
{
super
(
)
;
}
async
getTreatment<Textendsstring|number|boolean>
(
:
string
)
:
Promise
<
T
|
undefined
>
{
return
this
.
[
]
as
T
|
undefined
;
}
addTelemetryAssignmentFilter
(
:
)
:
void
{
this
.
.
push
(
)
;
}
/** True when the given assignment-context id is currently excluded from telemetry. */
isExcluded
(
:
string
)
:
boolean
{
return
this
.
.
some
(
=>
.
exclude
(
)
)
;
}
}
suite
(
'OnboardingScenarioService'
,
(
)
=>
{
const
=
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
teardown
(
(
)
=>
{
// The Memento maintains a static cache keyed by id; clear it so each test
// starts with fresh persisted state instead of leaking across tests.
.
clear
(
.
APPLICATION
)
;
}
)
;
test
(
'developer variation only overrides while developer mode is enabled'
,
(
)
=>
{
const
=
new
TestConfigurationService
(
{
[
ONBOARDING_DEVELOPER_MODE_CONFIG
]
:
{
:
false
}
,
[
ONBOARDING_DEVELOPER_MODE_VARIATIONS_CONFIG
]
:
{
:
'githubPrompt'
}
,
}
)
;
const
=
new
TestConfigurationService
(
{
[
ONBOARDING_DEVELOPER_MODE_CONFIG
]
:
{
:
true
}
,
[
ONBOARDING_DEVELOPER_MODE_VARIATIONS_CONFIG
]
:
{
:
'githubPrompt'
}
,
}
)
;
.
deepStrictEqual
(
{
:
getOnboardingDeveloperModeVariation
(
,
'tour'
)
,
:
getOnboardingDeveloperModeVariation
(
,
'tour'
)
,
}
,
{
:
undefined
,
:
'githubPrompt'
,
}
)
;
}
)
;
let
=
0
;
function
uniqueKind
(
)
:
string
{
return
`test-presentation-${idSeed++}`
;
}
function
createService
(
:
<
string
,
unknown
>
=
{
}
,
?
:
,
=
.
add
(
new
InMemoryStorageService
(
)
)
,
:
=
as
unknown
as
)
:
{
:
;
:
;
:
;
:
}
{
const
=
;
const
=
new
TestConfigurationService
(
)
;
const
=
.
add
(
new
ContextKeyService
(
)
)
;
const
=
.
add
(
new
TestLifecycleService
(
)
)
;
const
=
.
add
(
new
OnboardingScenarioService
(
,
,
as
unknown
as
,
,
??
new
NullWorkbenchAssignmentService
(
)
,
,
)
)
;
return
{
,
,
,
}
;
}
function
registerPresentation
(
:
)
:
void
{
.
add
(
.
register
(
)
)
;
}
function
registerScenario
(
:
)
:
void
{
.
add
(
.
register
(
)
)
;
}
test
(
'runs an eligible auto scenario exactly once and marks it shown'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
registerScenario
(
{
:
'auto-1'
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
}
=
createService
(
)
;
.
start
(
)
;
await
timeout
(
0
)
;
// Re-evaluating (e.g. another start) must not run it again.
.
start
(
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
{
:
.
,
:
.
hasBeenShown
(
'auto-1'
)
}
,
{
:
[
'auto-1'
]
,
:
true
}
)
;
}
)
;
test
(
'developer mode ignores previously shown state for auto scenarios'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
registerScenario
(
{
:
'dev-repeat-1'
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
=
.
add
(
new
InMemoryStorageService
(
)
)
;
const
=
createService
(
{
}
,
undefined
,
)
.
;
.
start
(
)
;
await
timeout
(
0
)
;
const
{
:
,
}
=
createService
(
{
[
ONBOARDING_DEVELOPER_MODE_CONFIG
]
:
{
'dev-repeat-1'
:
true
}
}
,
undefined
,
)
;
.
start
(
)
;
await
timeout
(
0
)
;
.
createKey<boolean>
(
'onboardingTestDevModeReevaluate'
,
false
)
.
set
(
true
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
.
,
[
'dev-repeat-1'
,
'dev-repeat-1'
]
)
;
}
)
;
test
(
'does not run automatically when onboarding.enabled is false'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
registerScenario
(
{
:
'disabled-1'
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
}
=
createService
(
{
[
ONBOARDING_ENABLED_CONFIG
]
:
false
}
)
;
.
start
(
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
.
,
[
]
)
;
}
)
;
test
(
'respects the when clause and reacts to context changes'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
registerScenario
(
{
:
'when-1'
,
:
.
equals
(
'onboardingTestReady'
,
true
)
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
,
}
=
createService
(
)
;
.
start
(
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
.
,
[
]
,
'should not run while when is unsatisfied'
)
;
const
:
<
boolean
>
=
.
createKey
(
'onboardingTestReady'
,
false
)
;
.
set
(
true
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
.
,
[
'when-1'
]
)
;
}
)
;
test
(
'runs higher-priority scenarios before lower-priority ones'
,
async
(
)
=>
{
const
:
string
[
]
=
[
]
;
const
=
new
RecordingPresentation
(
uniqueKind
(
)
,
.
)
;
// Track ordering via the recorder's runs array which is appended in run().
registerPresentation
(
)
;
registerScenario
(
{
:
'low'
,
:
1
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
registerScenario
(
{
:
'high'
,
:
10
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
}
=
createService
(
)
;
.
start
(
)
;
await
timeout
(
0
)
;
.
push
(
...
.
)
;
.
deepStrictEqual
(
,
[
'high'
,
'low'
]
)
;
}
)
;
test
(
'higher priority wins when eligible scenarios share a seen key'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
registerScenario
(
{
:
'low-shared'
,
:
'shared'
,
:
1
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
registerScenario
(
{
:
'high-shared'
,
:
'shared'
,
:
10
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
}
=
createService
(
)
;
.
start
(
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
.
,
[
'high-shared'
]
)
;
}
)
;
test
(
'observable triggers start the scenario when the signal turns true'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
const
=
observableValue<boolean>
(
'onboardingTestSignal'
,
false
)
;
registerScenario
(
{
:
'observable-1'
,
:
{
:
'observable'
,
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
}
=
createService
(
)
;
.
start
(
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
.
,
[
]
,
'should not run while signal is false'
)
;
.
set
(
true
,
undefined
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
.
,
[
'observable-1'
]
)
;
}
)
;
test
(
'command-triggered scenarios never run automatically'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
registerScenario
(
{
:
'command-1'
,
:
{
:
'command'
,
:
'noop'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
}
=
createService
(
)
;
.
start
(
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
.
,
[
]
)
;
}
)
;
test
(
'runScenario runs manually even when disabled and already shown'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
registerScenario
(
{
:
'manual-1'
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
}
=
createService
(
{
[
ONBOARDING_ENABLED_CONFIG
]
:
false
}
)
;
.
start
(
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
.
,
[
]
,
'disabled: should not auto-run'
)
;
const
=
await
.
runScenario
(
'manual-1'
)
;
.
deepStrictEqual
(
{
:
.
,
}
,
{
:
[
'manual-1'
]
,
:
.
}
)
;
}
)
;
test
(
'runScenario joins an in-flight run instead of starting a second one'
,
async
(
)
=>
{
let
!
:
(
)
=>
void
;
const
=
new
Promise<void>
(
=>
{
=
;
}
)
;
const
=
uniqueKind
(
)
;
const
:
string
[
]
=
[
]
;
const
:
=
{
,
async
run
(
:
)
:
Promise
<
>
{
.
push
(
.
)
;
await
;
return
completedResult
(
)
;
}
}
;
registerPresentation
(
)
;
registerScenario
(
{
:
'inflight-1'
,
:
{
:
'command'
,
:
'noop'
}
,
:
{
,
:
undefined
}
}
)
;
const
{
}
=
createService
(
)
;
.
start
(
)
;
const
=
.
runScenario
(
'inflight-1'
)
;
await
timeout
(
0
)
;
// Second call while the first run is still in-flight must not start again.
const
=
.
runScenario
(
'inflight-1'
)
;
await
timeout
(
0
)
;
release
(
)
;
const
[
,
]
=
await
Promise
.
all
(
[
,
]
)
;
.
deepStrictEqual
(
{
,
,
}
,
{
:
[
'inflight-1'
]
,
:
.
,
:
.
}
)
;
}
)
;
test
(
'resetAll clears shown state so the scenario can run again'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
registerScenario
(
{
:
'reset-1'
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
}
=
createService
(
)
;
.
start
(
)
;
await
timeout
(
0
)
;
.
resetAll
(
)
;
.
strictEqual
(
.
hasBeenShown
(
'reset-1'
)
,
false
)
;
}
)
;
test
(
'emits scenarioOutcome telemetry when a tour is shown but not when nothing is rendered'
,
async
(
)
=>
{
const
=
uniqueKind
(
)
;
const
=
uniqueKind
(
)
;
registerPresentation
(
new
FixedResultPresentation
(
,
completedResult
(
)
)
)
;
registerPresentation
(
new
FixedResultPresentation
(
,
notShownResult
(
)
)
)
;
registerScenario
(
{
:
'tele-shown'
,
:
{
:
'auto'
}
,
:
{
:
,
:
undefined
}
}
)
;
registerScenario
(
{
:
'tele-notshown'
,
:
{
:
'auto'
}
,
:
{
:
,
:
undefined
}
}
)
;
const
=
new
CapturingTelemetryService
(
)
;
const
{
}
=
createService
(
{
}
,
undefined
,
undefined
,
as
unknown
as
)
;
.
start
(
)
;
await
timeout
(
0
)
;
await
timeout
(
0
)
;
// One event for the shown tour; none for the degenerate run that rendered nothing.
.
deepStrictEqual
(
.
,
[
'onboarding.scenarioOutcome'
]
)
;
}
)
;
test
(
'emits one shown event only after a presentation renders with its experiment assignment'
,
async
(
)
=>
{
const
=
new
ShownPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
registerScenario
(
{
:
'sessions.onboarding.newSessionViewV2'
,
:
{
:
'onb.newSessionViewV2.show'
,
:
'onb.newSessionViewV2.id'
}
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
=
new
CapturingTelemetryService
(
)
;
const
{
}
=
createService
(
{
}
,
new
FakeAssignmentService
(
{
'onb.newSessionViewV2.show'
:
true
,
'onb.newSessionViewV2.id'
:
'onb-new-btn-treat2'
,
}
)
,
undefined
,
as
unknown
as
,
)
;
.
start
(
)
;
await
timeout
(
0
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
.
.
filter
(
=>
.
===
'onboarding.scenarioShown'
)
,
[
{
:
'onboarding.scenarioShown'
,
:
{
:
'sessions.onboarding.newSessionViewV2'
,
:
true
,
:
'onb-new-btn-treat2'
,
}
,
}
,
]
)
;
.
deepStrictEqual
(
.
,
[
'onboarding.scenarioShown'
,
'onboarding.scenarioOutcome'
]
)
;
}
)
;
test
(
'experiment-driven scenario does not run unless both treatment flags are set'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
registerScenario
(
{
:
'exp-off'
,
:
{
:
'exp.show'
,
:
'exp.id'
}
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
// Only one of the two flags resolves -> treated as not configured -> does not run.
const
{
}
=
createService
(
{
}
,
new
FakeAssignmentService
(
{
'exp.show'
:
true
}
)
)
;
.
start
(
)
;
await
timeout
(
0
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
.
,
[
]
)
;
}
)
;
test
(
'an assignment-context id without the reserved prefix is rejected as inactive'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
// Misconfigured id: would never be gated by the prefix filter, so it must not run.
const
=
new
FakeAssignmentService
(
{
'exp.show'
:
true
,
'exp.id'
:
'newsession-2026q3'
}
)
;
registerScenario
(
{
:
'exp-badid'
,
:
{
:
'exp.show'
,
:
'exp.id'
}
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
=
.
getUnexpectedErrorHandler
(
)
;
const
:
unknown
[
]
=
[
]
;
setUnexpectedErrorHandler
(
=>
.
push
(
)
)
;
try
{
const
{
}
=
createService
(
{
}
,
)
;
.
start
(
)
;
await
timeout
(
0
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
{
:
.
,
:
.
hasBeenShown
(
'exp-badid'
)
,
:
.
===
1
}
,
{
:
[
]
,
:
false
,
:
true
}
)
;
}
finally
{
setUnexpectedErrorHandler
(
)
;
}
}
)
;
test
(
'treatment arm shows the tour and opens the telemetry gate'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
const
=
new
FakeAssignmentService
(
{
'exp.show'
:
true
,
'exp.id'
:
'onb-tour-q3'
}
)
;
registerScenario
(
{
:
'exp-treat'
,
:
{
:
'exp.show'
,
:
'exp.id'
}
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
=
'onb-tour-q3:12345'
;
const
{
}
=
createService
(
{
}
,
)
;
const
=
.
isExcluded
(
)
;
.
start
(
)
;
await
timeout
(
0
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
{
,
:
.
,
:
.
hasBeenShown
(
'exp-treat'
)
,
:
.
isExcluded
(
)
,
:
.
isExcluded
(
'onb-tour-q3-other:12346'
)
}
,
{
:
true
,
:
[
'exp-treat'
]
,
:
true
,
:
false
,
:
true
}
)
;
}
)
;
test
(
'control arm opens the gate but shows nothing and stays eligible'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
const
=
new
FakeAssignmentService
(
{
'exp.show'
:
false
,
'exp.id'
:
'onb-tour-q3'
}
)
;
registerScenario
(
{
:
'exp-control'
,
:
{
:
'exp.show'
,
:
'exp.id'
}
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
}
=
createService
(
{
}
,
)
;
.
start
(
)
;
await
timeout
(
0
)
;
await
timeout
(
0
)
;
// No tour shown, not marked shown (re-eligible later), but the id now flows.
.
deepStrictEqual
(
{
:
.
,
:
.
hasBeenShown
(
'exp-control'
)
,
:
.
isExcluded
(
'onb-tour-q3:12345'
)
}
,
{
:
[
]
,
:
false
,
:
false
}
)
;
}
)
;
test
(
'developer mode shows an experiment scenario whose experiment is not active'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
// Neither treatment flag resolves: the experiment is inactive, so it would not run
// automatically — but developer mode bypasses the experiment gate.
const
=
new
FakeAssignmentService
(
{
}
)
;
registerScenario
(
{
:
'exp-dev-inactive'
,
:
{
:
'exp.show'
,
:
'exp.id'
}
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
}
=
createService
(
{
[
ONBOARDING_DEVELOPER_MODE_CONFIG
]
:
{
'exp-dev-inactive'
:
true
}
}
,
)
;
.
start
(
)
;
await
timeout
(
0
)
;
await
timeout
(
0
)
;
// The tour is shown, but since the experiment is not active no telemetry gate is
// opened (there is no assignment-context id to flow).
.
deepStrictEqual
(
{
:
.
,
:
.
isExcluded
(
'onb-tour-q3'
)
}
,
{
:
[
'exp-dev-inactive'
]
,
:
true
}
)
;
}
)
;
test
(
'developer mode shows the tour even when the user is in the control arm'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
const
=
new
FakeAssignmentService
(
{
'exp.show'
:
false
,
'exp.id'
:
'onb-tour-q3'
}
)
;
registerScenario
(
{
:
'exp-dev-control'
,
:
{
:
'exp.show'
,
:
'exp.id'
}
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
}
=
createService
(
{
[
ONBOARDING_DEVELOPER_MODE_CONFIG
]
:
{
'exp-dev-control'
:
true
}
}
,
)
;
.
start
(
)
;
await
timeout
(
0
)
;
await
timeout
(
0
)
;
// Developer mode shows the tour unconditionally and never opens the telemetry
// gate, so the assignment-context id stays excluded even though the user is in
// the (active) control arm — a local preview can't affect the scorecard.
.
deepStrictEqual
(
{
:
.
,
:
.
isExcluded
(
'onb-tour-q3'
)
}
,
{
:
[
'exp-dev-control'
]
,
:
true
}
)
;
}
)
;
test
(
'an opened gate persists so the id keeps flowing after a reload'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
const
=
.
add
(
new
InMemoryStorageService
(
)
)
;
registerScenario
(
{
:
'exp-persist'
,
:
{
:
'exp.show'
,
:
'exp.id'
}
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
// First "session": control reaches would-show and opens the gate.
const
=
createService
(
{
}
,
new
FakeAssignmentService
(
{
'exp.show'
:
false
,
'exp.id'
:
'onb-tour-q3'
}
)
,
)
;
.
.
start
(
)
;
await
timeout
(
0
)
;
await
timeout
(
0
)
;
// Second "session" (reload) with a fresh service + assignment service: the persisted
// gate must immediately allow the id, even before any would-show this session.
const
=
new
FakeAssignmentService
(
{
'exp.show'
:
false
,
'exp.id'
:
'onb-tour-q3'
}
)
;
createService
(
{
}
,
,
)
;
.
strictEqual
(
.
isExcluded
(
'onb-tour-q3:12345'
)
,
false
)
;
}
)
;
test
(
'a second experiment with a new id is blocked for a user who already saw the tour'
,
async
(
)
=>
{
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
const
=
.
add
(
new
InMemoryStorageService
(
)
)
;
const
=
.
;
// Experiment 1: treatment. The user sees the tour and is marked shown.
.
add
(
.
register
(
{
:
'tour'
,
:
{
:
'exp.show'
,
:
'exp.id'
}
,
:
{
:
'auto'
}
,
:
{
,
:
undefined
}
}
)
)
;
const
=
createService
(
{
}
,
new
FakeAssignmentService
(
{
'exp.show'
:
true
,
'exp.id'
:
'onb-tour-2026q3'
}
)
,
)
;
.
.
start
(
)
;
await
timeout
(
0
)
;
await
timeout
(
0
)
;
.
strictEqual
(
.
.
hasBeenShown
(
'tour'
)
,
true
)
;
// Experiment 2 (new id) in a reload: already shown -> not eligible -> id stays blocked.
const
=
new
FakeAssignmentService
(
{
'exp.show'
:
true
,
'exp.id'
:
'onb-tour-2027q1'
}
)
;
const
=
createService
(
{
}
,
,
)
;
.
.
start
(
)
;
await
timeout
(
0
)
;
await
timeout
(
0
)
;
.
deepStrictEqual
(
{
:
.
.
hasBeenShown
(
'tour'
)
,
:
.
isExcluded
(
'onb-tour-2027q1'
)
}
,
{
:
true
,
:
true
}
)
;
}
)
;
test
(
'shutdown aborts the active scenario and never starts queued ones'
,
async
(
)
=>
{
const
=
new
BlockingUntilAbortPresentation
(
uniqueKind
(
)
)
;
const
=
new
RecordingPresentation
(
uniqueKind
(
)
)
;
registerPresentation
(
)
;
registerPresentation
(
)
;
// `active` has higher priority so it runs first and blocks; `queued` waits.
registerScenario
(
{
:
'active'
,
:
10
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
registerScenario
(
{
:
'queued'
,
:
1
,
:
{
:
'auto'
}
,
:
{
:
.
,
:
undefined
}
}
)
;
const
{
,
}
=
createService
(
)
;
.
start
(
)
;
await
timeout
(
0
)
;
// Only the active (blocking) scenario should have started.
.
deepStrictEqual
(
{
:
.
,
:
.
}
,
{
:
[
'active'
]
,
:
[
]
}
)
;
.
fireShutdown
(
)
;
await
timeout
(
0
)
;
// The queued scenario must never have been presented.