Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions apps/ember-admin/tests/unit/services/limit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,36 @@ describe('Unit | Service | limit', function () {
expect(await limitService.getEmailsCount(undefined, '2026-01-01T00:00:00.000Z')).to.equal(0);
});
});

// The billing view calls this when a plan changes, so that a publisher who has just paid
// for more is not still refused by the allowance they had a moment ago.
describe('reload', function () {
it('replaces the limits it is holding with the ones now configured', function () {
limitService.config.hostSettings = {
limits: {staff: {max: 1}}
};
limitService.loadLimits();
expect(limitService.limiter.isLimited('staff')).to.be.true;

limitService.config.hostSettings = {
limits: {customThemes: {allowlist: ['casper']}}
};
limitService.reload();

expect(limitService.limiter.isLimited('staff')).to.be.false;
expect(limitService.limiter.isLimited('customThemes')).to.be.true;
});

it('keeps the limits it has when the configuration is gone', function () {
limitService.config.hostSettings = {
limits: {staff: {max: 1}}
};
limitService.loadLimits();

limitService.config.hostSettings = {};
limitService.reload();

expect(limitService.limiter.isLimited('staff')).to.be.true;
});
});
});
10 changes: 5 additions & 5 deletions e2e/helpers/playwright/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ export interface User {
}

export interface GhostConfig {
hostSettings__billing__enabled?: string;
hostSettings__billing__url?: string;
hostSettings__forceUpgrade?: string;
hostSettings__limits__customIntegrations__disabled?: string;
hostSettings__limits__customIntegrations__error?: string;
// Any hostSettings path, spelled the way the environment does: double underscores for
// nesting, so `hostSettings__limits__staff__max`. Open rather than enumerated, because a
// limit is just configuration and a test wanting a new one should not also need a new
// field here.
[key: `hostSettings__${string}`]: string | undefined;
}

export interface GhostInstanceFixture {
Expand Down
Loading
Loading