docbrown/cypress/integration/seededFlows/toggleFeatureFlags.spec.js
Michael Kohl a1eb6358db
Easier feature flag handling for Cypress (#16379)
* Add RailsEnvConstraint for routes

* Add feature flags API

* Add Cypress commands

* Add show action, update commands, add e2e test

* Update cypress/integration/seededFlows/toggleFeatureFlags.spec.js

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Move helper from command to test file

* Update documentation

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-02-03 10:42:13 -05:00

18 lines
540 B
JavaScript

describe('Toggling feature flags', () => {
function checkFeatureFlag(flag, expected) {
return cy
.request('GET', `/api/feature_flags?flag=${flag}`)
.should((response) => {
expect(response.body).to.deep.equal({ [flag]: expected });
});
}
it('toggles and verifies feature flags', () => {
const flag = 'test_feature_flag';
checkFeatureFlag(flag, false);
cy.enableFeatureFlag(flag);
checkFeatureFlag(flag, true);
cy.disableFeatureFlag(flag);
checkFeatureFlag(flag, false);
});
});