1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/frontend/cypress/integration/projects/settings.spec.ts
andreas-unleash c6ba6059cc
fix: reset stickiness to default on variants modal close (#3455)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
Expanded the onClose handler to reset stickiness to default for project
on modal close
## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-04-05 14:20:58 +03:00

79 lines
2.4 KiB
TypeScript

///<reference path="../../global.d.ts" />
describe('project settings', () => {
const randomId = String(Math.random()).split('.')[1];
const baseUrl = Cypress.config().baseUrl;
const projectName = `stickiness-project-${randomId}`;
const TEST_STICKINESS = 'userId';
const featureToggleName = `settings-${randomId}`;
let cleanFeature = false;
let cleanProject = false;
before(() => {
cy.runBefore();
});
beforeEach(() => {
cy.login_UI();
if (cleanFeature) {
cy.deleteFeature_API(featureToggleName);
}
if (cleanProject) {
cy.deleteProject_API(projectName);
}
cy.visit(`/projects`);
cy.wait(300);
});
it('should store default project stickiness when creating, retrieve it when editing a project', () => {
//when
cleanProject = true;
cy.createProject_UI(projectName, TEST_STICKINESS);
cy.visit(`/projects/${projectName}`);
cy.get("[data-testid='NAVIGATE_TO_EDIT_PROJECT']").click();
//then
cy.get("[id='stickiness-select']")
.first()
.should('have.text', 'userId');
//clean
cy.request('DELETE', `${baseUrl}/api/admin/projects/${projectName}`);
});
it('should respect the default project stickiness when creating a Gradual Rollout Strategy', () => {
cy.createProject_UI(projectName, TEST_STICKINESS);
cy.createFeature_UI(featureToggleName, true, projectName);
cleanFeature = true;
//when - then
cy.addFlexibleRolloutStrategyToFeature_UI({
featureToggleName,
project: projectName,
stickiness: TEST_STICKINESS,
});
//clean
});
it.skip('should respect the default project stickiness when creating a variant', () => {
cy.createProject_UI(projectName, TEST_STICKINESS);
cy.createFeature_UI(featureToggleName, true, projectName);
//when
cy.visit(
`/projects/${projectName}/features/${featureToggleName}/variants`
);
cy.get("[data-testid='ADD_VARIANT_BUTTON']").first().click();
//then
cy.get("[id='stickiness-select']")
.first()
.should('have.text', 'userId');
//clean
cy.deleteFeature_API(featureToggleName);
cy.deleteProject_API(projectName);
});
});