From a06406715449cd286cbf07ace44a1989a8954b81 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Fri, 18 Feb 2022 10:12:31 +0000 Subject: [PATCH] Fixed logic error in labs mock - the previous logic only allowed one flag to be mocked at a time because it kept recalling sinon.stub - now it's possible to mock multiple flags with different settings as we always just add to the same stub --- test/utils/e2e-framework-mock-manager.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/test/utils/e2e-framework-mock-manager.js b/test/utils/e2e-framework-mock-manager.js index b51e5d6d20..98a0208ebe 100644 --- a/test/utils/e2e-framework-mock-manager.js +++ b/test/utils/e2e-framework-mock-manager.js @@ -42,33 +42,29 @@ const setupStripe = () => { }; const mockLabsEnabled = (flag, alpha = true) => { - mocks.labs = mocks.labs || {}; - // We assume we should enable alpha experiments unless explicitly told not to! if (!alpha) { configUtils.set('enableDeveloperExperiments', true); } - if (mocks.labs[flag]) { - mocks.labs[flag].returns(true); - } else { - mocks.labs[flag] = sinon.stub(labs, 'isSet').withArgs(flag).returns(true); + if (!mocks.labs) { + mocks.labs = sinon.stub(labs, 'isSet'); } + + mocks.labs.withArgs(flag).returns(true); }; const mockLabsDisabled = (flag, alpha = true) => { - mocks.labs = mocks.labs || {}; - // We assume we should enable alpha experiments unless explicitly told not to! if (!alpha) { configUtils.set('enableDeveloperExperiments', true); } - if (mocks.labs[flag]) { - mocks.labs[flag].returns(false); - } else { - mocks.labs[flag] = sinon.stub(labs, 'isSet').withArgs(flag).returns(false); + if (!mocks.labs) { + mocks.labs = sinon.stub(labs, 'isSet'); } + + mocks.labs.withArgs(flag).returns(false); }; const sentEmailCount = (count) => {