amtrack / sfdx-browserforce-plugin

sfdx plugin for browser automation
MIT License
112 stars 39 forks source link

feat: add enableRelateContactToMultipleAccounts as workaround to unreliable Metadata #470

Closed jverelst closed 3 years ago

jverelst commented 3 years ago

This week, we ran into issues with our scratch orgs that the behavior of the flag 'enableRelateContactToMultipleAccounts' is very unreliable. Scratch orgs will often be created without the AccountContactRelation object available, which means you have to manually disable and then re-enable the ContactToMultipleAccounts feature.

This appears to be a known issue, which is logged here:

As a (hopefully temporary!) workaround, I implemented a plugin into your framework, to allow our azure pipelines to programatically set this flag. It might be useful for other people as well.

amtrack commented 3 years ago

@jverelst Thanks for your PR! 🙏

I just tried to run the E2E tests with yarn test:e2e -g RelateContactToMultipleAccounts. But that didn't work yet. The generated code is slightly wrong (my bad 🙈). I've added this to my review.

After that, could you please check the E2E tests again?

In the meantime and before merging, I just wanted to quickly ask you something.

Please note: I didn't try to reproduce this issue by creating scratch orgs repeatedly as you and others did. I just have the feeling that there could be a more simple workaround.

Did you already try to create a scratch org with the feature turned off (not turned on in project-scratch-def.json) and running sfdx force:source:deploy -p workaround/settings/Account.settings-meta.xml with the following content after the scratch org has been created?

<?xml version="1.0" encoding="UTF-8"?>
<AccountSettings xmlns="http://soap.sforce.com/2006/04/metadata">
    <enableRelateContactToMultipleAccounts>true</enableRelateContactToMultipleAccounts>
</AccountSettings>

If this is not reliable either, I will of course happily merge your PR!

jverelst commented 3 years ago

Thanks for the feedback @amtrack!

To start with your last point: indeed we have tried that but it had the same unreliable results. Apparently both the project-scratch-def.json configuration setting, as well as using AccountSettings deployments both don't always create the AccountContactRelation object. Only setting the flag using the UI does ...

Regarding the E2E test, I indeed didn't look at at that, and your change fixed the error. Somehow when runnign it for the first time it failed, but after retrying I got the following o utput:

$ yarn test:e2e -g RelateContactToMultipleAccounts
yarn run v1.22.15
$ mocha --forbid-only "test/**/*.e2e-spec.ts" "src/**/*.e2e-spec.ts" -g RelateContactToMultipleAccounts

  RelateContactToMultipleAccounts
    ✔ should enable
    ✔ should already be enabled
    ✔ should disable
    ✔ should already be disabled

  4 passing (22s)

✨  Done in 26.17s.
github-actions[bot] commented 3 years ago

:tada: This PR is included in version 2.7.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: