Ghost/ghost/admin/tests/helpers/labs-flag.js
Kevin Ansfield 4b646d40ea Added non-Stripe members setting screen acceptance tests
refs https://github.com/TryGhost/Team/issues/1358

- added acceptance tests for members settings screen
  - subscription access management
  - default post access management
  - free tier management
- fixed `enableLabsFlag()` test helper overwriting existing flag settings when enabling another one
- updated API mocks and fixtures
  - matched product fixtures to default tiers-enabled products
  - updated product API mocks to include benefit handling
2022-02-18 22:36:01 +00:00

37 lines
1.1 KiB
JavaScript

export function enableLabsFlag(server, flag) {
if (!server.schema.configs.all().length) {
server.loadFixtures('configs');
}
if (!server.schema.settings.all().length) {
server.loadFixtures('settings');
}
const config = server.schema.configs.first();
config.update({enableDeveloperExperiments: true});
const existingSetting = server.db.settings.findBy({key: 'labs'}).value;
const labsSetting = existingSetting ? JSON.parse(existingSetting) : {};
labsSetting[flag] = true;
server.db.settings.update({key: 'labs'}, {value: JSON.stringify(labsSetting)});
}
export function disableLabsFlag(server, flag) {
if (!server.schema.configs.all().length) {
server.loadFixtures('configs');
}
if (!server.schema.settings.all().length) {
server.loadFixtures('settings');
}
const config = server.schema.configs.first();
config.update({enableDeveloperExperiments: true});
const labsSetting = {};
labsSetting[flag] = false;
server.db.settings.update({key: 'labs'}, {value: JSON.stringify(labsSetting)});
}