fix(gpc): keep auto mode when balance permission is unknown
This commit is contained in:
@@ -502,6 +502,70 @@ return { updatePlusModeUI, selectGpcHelperPhoneMode, plusPaymentMethodCaption, r
|
||||
assert.match(api.plusPaymentMethodCaption.textContent, /自动/);
|
||||
});
|
||||
|
||||
test('sidepanel start check keeps GPC auto mode when balance payload omits permission field', async () => {
|
||||
const bundle = [
|
||||
extractFunction('normalizeGpcAutoModePermissionValue'),
|
||||
extractFunction('getGpcAutoModePermissionFromPayload'),
|
||||
extractFunction('isGpcAutoModePermissionDenied'),
|
||||
extractFunction('normalizeGpcRemainingUsesValue'),
|
||||
extractFunction('ensureGpcApiKeyReadyForStart'),
|
||||
].join('\n');
|
||||
|
||||
const api = new Function(`
|
||||
let latestState = { gopayHelperPhoneMode: 'auto' };
|
||||
const GPC_HELPER_PHONE_MODE_AUTO = 'auto';
|
||||
const GPC_HELPER_PHONE_MODE_MANUAL = 'manual';
|
||||
const selectGpcHelperPhoneMode = { value: 'auto' };
|
||||
const dialogs = [];
|
||||
let saveCalls = 0;
|
||||
let updateCalls = 0;
|
||||
${bundle}
|
||||
function isGpcHelperCheckoutSelected() { return true; }
|
||||
function getSelectedGpcHelperPhoneMode() { return selectGpcHelperPhoneMode.value; }
|
||||
async function refreshGpcBalanceForStart() {
|
||||
return {
|
||||
gopayHelperRemainingUses: 998,
|
||||
gopayHelperApiKeyStatus: 'active',
|
||||
gopayHelperAutoModeEnabled: false,
|
||||
gopayHelperBalancePayload: {
|
||||
status: 'active',
|
||||
remaining_uses: 998,
|
||||
},
|
||||
};
|
||||
}
|
||||
async function showGpcStartBlockedDialog(message) {
|
||||
dialogs.push(message);
|
||||
}
|
||||
function syncLatestState(nextState) {
|
||||
latestState = { ...latestState, ...nextState };
|
||||
}
|
||||
function updatePlusModeUI() {
|
||||
updateCalls += 1;
|
||||
}
|
||||
async function saveSettings() {
|
||||
saveCalls += 1;
|
||||
}
|
||||
function showToast() {}
|
||||
return {
|
||||
ensureGpcApiKeyReadyForStart,
|
||||
selectGpcHelperPhoneMode,
|
||||
getDialogs: () => dialogs.slice(),
|
||||
getSaveCalls: () => saveCalls,
|
||||
getUpdateCalls: () => updateCalls,
|
||||
getPersistedPhoneMode: () => latestState.gopayHelperPhoneMode,
|
||||
};
|
||||
`)();
|
||||
|
||||
const allowed = await api.ensureGpcApiKeyReadyForStart();
|
||||
|
||||
assert.equal(allowed, true);
|
||||
assert.equal(api.selectGpcHelperPhoneMode.value, 'auto');
|
||||
assert.equal(api.getPersistedPhoneMode(), 'auto');
|
||||
assert.equal(api.getSaveCalls(), 0);
|
||||
assert.equal(api.getUpdateCalls(), 0);
|
||||
assert.deepEqual(api.getDialogs(), []);
|
||||
});
|
||||
|
||||
test('sidepanel resolves pending GoPay manual confirmation from DATA_UPDATED state', async () => {
|
||||
const bundle = [
|
||||
extractFunction('openPlusManualConfirmationDialog'),
|
||||
|
||||
Reference in New Issue
Block a user