-
Notifications
You must be signed in to change notification settings - Fork 0
fix: site-level handler overrides were ignored, org-level disable always won #1590
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -235,6 +235,62 @@ describe('ConfigurationModel', () => { | |
| expect(isEnabled).to.be.true; | ||
| }); | ||
|
|
||
| it('returns false for a site whose org is in disabled.orgs and the site is not explicitly listed', () => { | ||
| instance.addHandler('org-disabled-handler', { | ||
| enabledByDefault: true, | ||
| enabled: { sites: [], orgs: [] }, | ||
| disabled: { sites: [], orgs: [site.getOrganizationId()] }, | ||
| }); | ||
|
|
||
| expect(instance.isHandlerEnabledForSite('org-disabled-handler', site)).to.be.false; | ||
| }); | ||
|
|
||
|
tkotthakota-adobe marked this conversation as resolved.
|
||
| it('returns true when site is in enabled.sites even if its org is in disabled.orgs', () => { | ||
| instance.addHandler('site-override-handler', { | ||
| enabledByDefault: true, | ||
|
tkotthakota-adobe marked this conversation as resolved.
|
||
| enabled: { sites: [site.getId()], orgs: [] }, | ||
| disabled: { sites: [], orgs: [site.getOrganizationId()] }, | ||
| }); | ||
|
|
||
| expect(instance.isHandlerEnabledForSite('site-override-handler', site)).to.be.true; | ||
| }); | ||
|
|
||
| it('returns true for non-default handler when site is in enabled.sites and org is in disabled.orgs', () => { | ||
| instance.addHandler('paid-handler', { | ||
| enabledByDefault: false, | ||
| enabled: { sites: [site.getId()], orgs: [] }, | ||
| disabled: { sites: [], orgs: [site.getOrganizationId()] }, | ||
| }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Important - the headline production scenario lacks an end-to-end test. The PR exists to fix the free-trial -> paid upgrade path: org has handler X with Without a test that combines write + read, a future regression that breaks it('upgrades non-default handler from disabled org via updateHandlerSites', () => {
instance.addHandler('paid-handler', {
enabledByDefault: false,
enabled: { sites: [], orgs: [] },
disabled: { sites: [], orgs: [site.getOrganizationId()] },
});
instance.updateHandlerSites('paid-handler', site.getId(), true);
expect(instance.isHandlerEnabledForSite('paid-handler', site)).to.be.true;
});This is the test that tells future maintainers what the PR is for. |
||
|
|
||
| expect(instance.isHandlerEnabledForSite('paid-handler', site)).to.be.true; | ||
| }); | ||
|
|
||
| it('removes site from disabled.sites when re-enabling for a non-default handler', () => { | ||
| instance.addHandler('cleanup-handler', { | ||
| enabledByDefault: false, | ||
| enabled: { sites: [], orgs: [] }, | ||
| disabled: { sites: [site.getId()], orgs: [] }, | ||
| }); | ||
|
|
||
| instance.updateHandlerSites('cleanup-handler', site.getId(), true); | ||
|
|
||
| expect(instance.getHandler('cleanup-handler').disabled.sites).to.not.include(site.getId()); | ||
| expect(instance.getHandler('cleanup-handler').enabled.sites).to.include(site.getId()); | ||
| }); | ||
|
|
||
| it('removes site from enabled.sites when disabling a default handler', () => { | ||
| instance.addHandler('default-cleanup-handler', { | ||
| enabledByDefault: true, | ||
| enabled: { sites: [site.getId()], orgs: [] }, | ||
| disabled: { sites: [], orgs: [] }, | ||
| }); | ||
|
|
||
| instance.updateHandlerSites('default-cleanup-handler', site.getId(), false); | ||
|
|
||
| expect(instance.getHandler('default-cleanup-handler').enabled.sites).to.not.include(site.getId()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Important -
With the new "always add to enabled on enable" change in this PR, the asymmetry of branch 3 is now load-bearing: a paid handler that gets enabled (now in it('removes site from enabled.sites when disabling for a non-default handler', () => {
instance.addHandler('paid-disable-handler', {
enabledByDefault: false,
enabled: { sites: [site.getId()], orgs: [] },
disabled: { sites: [], orgs: [] },
});
instance.updateHandlerSites('paid-disable-handler', site.getId(), false);
expect(instance.getHandler('paid-disable-handler').enabled.sites).to.not.include(site.getId());
expect(instance.getHandler('paid-disable-handler').disabled.sites).to.not.include(site.getId());
});This pins the contract that disabling a non-default handler is "not in either list" (default-off applies), distinct from disabling a default handler ("in disabled list, default-on overridden"). |
||
| expect(instance.getHandler('default-cleanup-handler').disabled.sites).to.include(site.getId()); | ||
| }); | ||
|
|
||
| it('updates handler orgs for a handler disabled by default with enabled', () => { | ||
| instance.updateHandlerOrgs('lhs-mobile', org.getId(), true); | ||
| expect(instance.getHandler('lhs-mobile').enabled.orgs).to.include(org.getId()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment by @solaris007
Important: This flips existing config rows where a site is in enabled.sites and the org is in disabled.orgs from disabled to enabled at deploy time. Run a query against prod to enumerate affected rows before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have prod access @solaris007 What is the best way to do this query?