Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert "Remove hasAds from service configs"" #7299

Merged
merged 40 commits into from
Aug 14, 2020

Conversation

tochwill
Copy link
Contributor

@tochwill tochwill commented Jul 22, 2020

Reverts #7294

We have had to revert and block this on #6866, as we had a race condition when setting up the ads bootstrap javascript.

Overall change:
Remove the hasAds field from the service config files and ensure we're just checking the ads toggle from the config endpoint.

Code changes:

  • Remove hasAds from the ads object in the service config files
  • Move ads object containing the advertisementLabel to the translations object in the service config files
  • Remove hasAds checks from the codebase
  • Update path to advertisementLabel on amp ads
  • Use ToggleContext.Provider with mocked toggle values

@tochwill tochwill added blocked This issue should not be worked on until another internal issue is completed - see desc for details ws-home ads labels Jul 22, 2020
@tochwill tochwill added this to PR in Progress in Simorgh Jul 22, 2020
@thekp
Copy link
Contributor

thekp commented Jul 30, 2020

I've recently learned that we are using manual mocks for our service context provider. I believe we can also do something similar for the toggles context provider so that in our test environment we use our hardcoded toggle values rather than making any api requests.

@thekp thekp self-assigned this Jul 30, 2020
@thekp thekp removed the blocked This issue should not be worked on until another internal issue is completed - see desc for details label Jul 30, 2020
@thekp
Copy link
Contributor

thekp commented Jul 30, 2020

I've recently learned that we are using manual mocks for our service context provider. I believe we can also do something similar for the toggles context provider so that in our test environment we use our hardcoded toggle values rather than making any api requests.

I ended up just using ToggleContext.Provider with a mocked set of values rather than mocking the implementation of ToggleContextProvider (like src/app/contexts/ServiceContext/__mocks__/index.jsx). I didn't create a manual mocks because I was getting a duplication warning:

jest-haste-map: duplicate manual mock found: index
  The following files share their name; please delete one of them:
    * <rootDir>/src/app/contexts/ServiceContext/__mocks__/index.jsx
    * <rootDir>/src/app/contexts/ToggleContext/__mocks__/index.jsx

That does not seem officially resolved: jestjs/jest#2070

Passing a mocked set of values means that we do not have to call the fetch api logic in the TogglesContextProvider.

@thekp thekp added the blocked This issue should not be worked on until another internal issue is completed - see desc for details label Jul 30, 2020
@thekp
Copy link
Contributor

thekp commented Jul 30, 2020

We still get a timeout despite me mocking the ToggleContextProvider 🤕
image

@thekp thekp removed their assignment Jul 31, 2020
@tochwill tochwill self-assigned this Aug 3, 2020
@tochwill tochwill removed their assignment Aug 6, 2020
@tochwill tochwill removed the blocked This issue should not be worked on until another internal issue is completed - see desc for details label Aug 6, 2020
@mmcculloch mmcculloch moved this from PR in Progress to Code Review in Simorgh Aug 12, 2020
@@ -9,4 +10,17 @@ describe('CanonicalAds Ads', () => {
<CanonicalAdBootstrapJs />,
);
});

describe('Assertions', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea on moving the test to this file. Do they pass now on Jenkins?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup everything seems stable now! Travis is being a bit weird but I think it's just some issues on their end.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! There are some conflicts that need to be resolved 🔧

Simorgh automation moved this from Code Review to Ready for Test Aug 12, 2020
@PriyaKR PriyaKR moved this from Ready for Test to In Test in Simorgh Aug 13, 2020
@PriyaKR PriyaKR self-assigned this Aug 13, 2020
@PriyaKR
Copy link
Contributor

PriyaKR commented Aug 13, 2020

LGTM.

@PriyaKR PriyaKR moved this from In Test to Ready for merge (probably) in Simorgh Aug 13, 2020
@sareh sareh merged commit dac91e9 into latest Aug 14, 2020
Simorgh automation moved this from Ready for merge (probably) to Done Aug 14, 2020
@sareh sareh deleted the revert-7294-revert-7220-remove-has-ads-from-config branch August 14, 2020 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants