refactor flows into canonical runtime architecture
This commit is contained in:
@@ -120,7 +120,7 @@ const self = {
|
||||
},
|
||||
},
|
||||
};
|
||||
const DEFAULT_STATE = { panelMode: 'cpa' };
|
||||
const DEFAULT_STATE = { targetId: 'cpa' };
|
||||
const CONTRIBUTION_RUNTIME_DEFAULTS = {
|
||||
accountContributionEnabled: false,
|
||||
accountContributionExpected: false,
|
||||
@@ -150,7 +150,7 @@ return { buildAccountContributionState };
|
||||
`)();
|
||||
|
||||
const enabledState = api.buildAccountContributionState(true, {
|
||||
panelMode: 'sub2api',
|
||||
targetId: 'sub2api',
|
||||
customPassword: 'Secret123!',
|
||||
accountRunHistoryTextEnabled: true,
|
||||
}, {
|
||||
@@ -166,12 +166,12 @@ return { buildAccountContributionState };
|
||||
openai: { enabled: true, adapterId: 'openai-oauth' },
|
||||
});
|
||||
assert.equal(enabledState.contributionSessionId, 'session-001');
|
||||
assert.equal(enabledState.panelMode, 'sub2api');
|
||||
assert.equal(enabledState.targetId, 'sub2api');
|
||||
assert.equal(enabledState.customPassword, '');
|
||||
assert.equal(enabledState.accountRunHistoryTextEnabled, false);
|
||||
|
||||
const disabledState = api.buildAccountContributionState(false, {
|
||||
panelMode: 'sub2api',
|
||||
targetId: 'sub2api',
|
||||
customPassword: 'Secret123!',
|
||||
accountRunHistoryTextEnabled: true,
|
||||
}, {
|
||||
@@ -184,17 +184,17 @@ return { buildAccountContributionState };
|
||||
assert.equal(disabledState.contributionAdapterId, '');
|
||||
assert.deepStrictEqual(disabledState.flowContributionRuntime, {});
|
||||
assert.equal(disabledState.contributionSessionId, '');
|
||||
assert.equal(disabledState.panelMode, 'sub2api');
|
||||
assert.equal(disabledState.targetId, 'sub2api');
|
||||
assert.equal(disabledState.customPassword, 'Secret123!');
|
||||
|
||||
const plusContributionState = api.buildAccountContributionState(true, {
|
||||
panelMode: 'cpa',
|
||||
targetId: 'cpa',
|
||||
plusModeEnabled: true,
|
||||
customPassword: 'Secret123!',
|
||||
accountRunHistoryTextEnabled: true,
|
||||
}, {});
|
||||
assert.equal(plusContributionState.contributionTargetGroupName, 'openai-plus');
|
||||
assert.equal(plusContributionState.panelMode, 'sub2api');
|
||||
assert.equal(plusContributionState.targetId, 'sub2api');
|
||||
});
|
||||
|
||||
test('resetState preserves contribution runtime across reset', () => {
|
||||
@@ -289,7 +289,7 @@ test('message router handles contribution mode, start flow, and status polling m
|
||||
calls.push({ type: 'toggle', enabled });
|
||||
return {
|
||||
accountContributionEnabled: Boolean(enabled),
|
||||
panelMode: 'cpa',
|
||||
targetId: 'cpa',
|
||||
};
|
||||
},
|
||||
startFlowContribution: async (options) => {
|
||||
@@ -383,7 +383,7 @@ test('message router blocks AUTO_RUN and SCHEDULE_AUTO_RUN when shared auto-run
|
||||
getPendingAutoRunTimerPlan: () => null,
|
||||
getState: async () => ({
|
||||
activeFlowId: 'site-a',
|
||||
panelMode: 'cpa',
|
||||
targetId: 'cpa',
|
||||
signupMethod: 'phone',
|
||||
stepStatuses: {},
|
||||
}),
|
||||
@@ -947,7 +947,7 @@ return { refreshOAuthUrlBeforeStep6 };
|
||||
|
||||
const oauthUrl = await api.refreshOAuthUrlBeforeStep6({
|
||||
accountContributionEnabled: false,
|
||||
panelMode: 'sub2api',
|
||||
targetId: 'sub2api',
|
||||
email: 'user@example.com',
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user