Merge pull request #16405 from mozilla/FXA-9011

fix(auth): Revise eligibilityFromEligibilityManager - blocked_iap
This commit is contained in:
Lisa Chan 2024-02-13 18:53:33 -05:00 коммит произвёл GitHub
Родитель 48150216bd a0879c46da
Коммит a686218f97
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 44 добавлений и 5 удалений

Просмотреть файл

@ -383,13 +383,10 @@ export class CapabilityService {
subscriptionEligibilityResult: SubscriptionEligibilityResult.INVALID,
};
const iapProductIds = iapSubscribedPlans.map((p) => p.product_id);
const planIds = [
...stripeSubscribedPlans.map((p) => p.plan_id),
...iapSubscribedPlans.map((p) => p.plan_id),
];
const planIds = stripeSubscribedPlans.map((p) => p.plan_id);
const overlaps = await this.eligibilityManager.getOfferingOverlap(
planIds,
[],
iapProductIds,
targetPlan.plan_id
);

Просмотреть файл

@ -820,6 +820,48 @@ describe('CapabilityService', () => {
});
});
});
describe('eligibilityManagerResult and stripeEligibilityResult should match', () => {
let mockEligibilityManager;
beforeEach(() => {
mockEligibilityManager = {};
Container.set(EligibilityManager, mockEligibilityManager);
capabilityService = new CapabilityService();
});
it('returns blocked_iap result from both', async () => {
mockEligibilityManager.getOfferingOverlap = sinon.fake.resolves([
{
comparison: 'same',
offeringProductId: mockPlanTier1ShortInterval.product_id,
type: 'offering',
},
]);
capabilityService.fetchSubscribedPricesFromAppStore =
sinon.fake.resolves(['plan_123456']);
const eligiblityActual =
await capabilityService.eligibilityFromEligibilityManager(
[],
[mockPlanTier1ShortInterval],
mockPlanTier1LongInterval
);
const stripeActual =
await capabilityService.eligibilityFromStripeMetadata(
[],
[mockPlanTier1ShortInterval],
mockPlanTier1LongInterval
);
assert.deepEqual(
eligiblityActual.subscriptionEligibilityResult,
stripeActual.subscriptionEligibilityResult
);
});
});
});
describe('processPriceIdDiff', () => {