mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
edefa6fc7e
This PR revamps e2e tests, while adding a new one for the interactive demo guide: - Bumps Cypress from `9.7.0` to `12.11.0`; - Bumps Cypress GH action from `v2` to `v5`; - Makes any adjustments needed; - Fixes a lot of issues identified with existing tests; - Adds new `demo.spec.ts` e2e test that covers the entire demo guide flow; **Note:** Currently does not include `demo.spec.ts` in the GH action, as it [fails](https://github.com/Unleash/unleash/actions/runs/4896839575/jobs/8744137231?pr=3656) on step 2.13 (last step of "user-specific" topic). It runs perfectly fine locally, though. Might be placebo, but in general tests seem less flaky now and they may even be faster (especially when not adding the `demo` one, which would always take a long time).
104 lines
3.5 KiB
TypeScript
104 lines
3.5 KiB
TypeScript
///<reference path="../../global.d.ts" />
|
|
|
|
describe('feature', () => {
|
|
const randomId = String(Math.random()).split('.')[1];
|
|
const featureToggleName = `unleash-e2e-${randomId}`;
|
|
|
|
const variant1 = 'variant1';
|
|
const variant2 = 'variant2';
|
|
|
|
before(() => {
|
|
cy.runBefore();
|
|
});
|
|
|
|
after(() => {
|
|
cy.deleteFeature_API(featureToggleName);
|
|
});
|
|
|
|
beforeEach(() => {
|
|
cy.login_UI();
|
|
cy.visit('/features');
|
|
});
|
|
|
|
it('can create a feature toggle', () => {
|
|
cy.createFeature_UI(featureToggleName, true);
|
|
cy.url().should('include', featureToggleName);
|
|
});
|
|
|
|
it('gives an error if a toggle exists with the same name', () => {
|
|
cy.createFeature_UI(featureToggleName, false);
|
|
cy.get("[data-testid='INPUT_ERROR_TEXT']").contains(
|
|
'A toggle with that name already exists'
|
|
);
|
|
});
|
|
|
|
it('gives an error if a toggle name is url unsafe', () => {
|
|
cy.createFeature_UI('featureToggleUnsafe####$#//', false);
|
|
cy.get("[data-testid='INPUT_ERROR_TEXT']").contains(
|
|
`"name" must be URL friendly`
|
|
);
|
|
});
|
|
|
|
it('can add, update and delete a gradual rollout strategy to the development environment', () => {
|
|
cy.addFlexibleRolloutStrategyToFeature_UI({
|
|
featureToggleName,
|
|
}).then(() => {
|
|
cy.updateFlexibleRolloutStrategy_UI(featureToggleName).then(() =>
|
|
cy.deleteFeatureStrategy_UI(featureToggleName)
|
|
);
|
|
});
|
|
});
|
|
|
|
it('can add a userId strategy to the development environment', () => {
|
|
cy.addUserIdStrategyToFeature_UI(featureToggleName).then(() => {
|
|
cy.deleteFeatureStrategy_UI(featureToggleName, false);
|
|
});
|
|
});
|
|
|
|
it('can add variants to the development environment', () => {
|
|
cy.addVariantsToFeature_UI(featureToggleName, [variant1, variant2]);
|
|
});
|
|
|
|
it('can update variants', () => {
|
|
cy.visit(`/projects/default/features/${featureToggleName}/variants`);
|
|
|
|
cy.get('[data-testid=EDIT_VARIANTS_BUTTON]').click();
|
|
cy.get('[data-testid=VARIANT_NAME_INPUT]')
|
|
.last()
|
|
.children()
|
|
.find('input')
|
|
.should('have.attr', 'disabled');
|
|
cy.get('[data-testid=VARIANT_WEIGHT_CHECK]')
|
|
.last()
|
|
.find('input')
|
|
.check();
|
|
cy.get('[data-testid=VARIANT_WEIGHT_INPUT]').last().clear().type('15');
|
|
|
|
cy.intercept(
|
|
'PATCH',
|
|
`/api/admin/projects/default/features/${featureToggleName}/environments/development/variants`,
|
|
req => {
|
|
expect(req.body[0].op).to.equal('replace');
|
|
expect(req.body[0].path).to.equal('/1/weightType');
|
|
expect(req.body[0].value).to.equal('fix');
|
|
expect(req.body[1].op).to.equal('replace');
|
|
expect(req.body[1].path).to.equal('/1/weight');
|
|
expect(req.body[1].value).to.equal(150);
|
|
expect(req.body[2].op).to.equal('replace');
|
|
expect(req.body[2].path).to.equal('/0/weight');
|
|
expect(req.body[2].value).to.equal(850);
|
|
}
|
|
).as('variantUpdate');
|
|
|
|
cy.get('[data-testid=DIALOGUE_CONFIRM_ID]').click();
|
|
cy.get(`[data-testid=VARIANT_WEIGHT_${variant2}]`).should(
|
|
'have.text',
|
|
'15 %'
|
|
);
|
|
});
|
|
|
|
it('can delete variants', () => {
|
|
cy.deleteVariant_UI(featureToggleName, variant2);
|
|
});
|
|
});
|