2023-04-04 10:46:28 +02:00
|
|
|
/// <reference types="cypress" />
|
|
|
|
|
|
|
|
declare namespace Cypress {
|
|
|
|
interface AddFlexibleRolloutStrategyOptions {
|
|
|
|
featureToggleName: string;
|
|
|
|
project?: string;
|
|
|
|
environment?: string;
|
|
|
|
stickiness?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface UserCredentials {
|
|
|
|
email: string;
|
|
|
|
password: string;
|
|
|
|
}
|
2023-05-08 10:16:18 +02:00
|
|
|
|
|
|
|
interface IEnvironment {
|
|
|
|
name: string;
|
|
|
|
type: 'development' | 'preproduction' | 'test' | 'production';
|
|
|
|
}
|
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
interface Chainable {
|
|
|
|
runBefore(): Chainable;
|
|
|
|
|
|
|
|
login_UI(user = AUTH_USER, password = AUTH_PASSWORD): Chainable;
|
|
|
|
logout_UI(): Chainable;
|
|
|
|
|
|
|
|
createProject_UI(
|
|
|
|
projectName: string,
|
2023-10-02 14:25:46 +02:00
|
|
|
defaultStickiness: string,
|
2023-04-04 10:46:28 +02:00
|
|
|
): Chainable;
|
|
|
|
|
|
|
|
createFeature_UI(
|
|
|
|
name: string,
|
|
|
|
shouldWait?: boolean,
|
2023-10-02 14:25:46 +02:00
|
|
|
project?: string,
|
2023-04-04 10:46:28 +02:00
|
|
|
): Chainable;
|
|
|
|
|
|
|
|
// VARIANTS
|
|
|
|
addVariantsToFeature_UI(
|
|
|
|
featureToggleName: string,
|
|
|
|
variants: Array<string>,
|
2023-10-02 14:25:46 +02:00
|
|
|
projectName?: string,
|
2023-04-04 10:46:28 +02:00
|
|
|
);
|
|
|
|
deleteVariant_UI(
|
|
|
|
featureToggleName: string,
|
|
|
|
variant: string,
|
2023-10-02 14:25:46 +02:00
|
|
|
projectName?: string,
|
2023-04-04 10:46:28 +02:00
|
|
|
): Chainable<any>;
|
|
|
|
|
|
|
|
// SEGMENTS
|
|
|
|
createSegment_UI(segmentName: string): Chainable;
|
|
|
|
deleteSegment_UI(segmentName: string, id: string): Chainable;
|
|
|
|
|
|
|
|
// STRATEGY
|
|
|
|
addUserIdStrategyToFeature_UI(
|
|
|
|
featureName: string,
|
2023-10-02 14:25:46 +02:00
|
|
|
projectName?: string,
|
2023-04-04 10:46:28 +02:00
|
|
|
): Chainable;
|
|
|
|
addFlexibleRolloutStrategyToFeature_UI(
|
2023-10-02 14:25:46 +02:00
|
|
|
options: AddFlexibleRolloutStrategyOptions,
|
2023-04-04 10:46:28 +02:00
|
|
|
): Chainable;
|
refactor: isolate tests (#5433)
This PR fixes a race condition between e2e tests where bulk archiving
all toggles in the default project would delete toggles used for the
features e2e tests.
It does by isolating the features.spec and overview.spec to their
respective projects, so that they always operate on isolated data.
### Future enhancements:
I'm not particularly fond of passing the projectName through to all the
helper methods. It complicates the tests more than it should. I would
like to be able to set the project once per test and have all the helper
methods be aware of the context. Something like this should work:
```
before(() => {
cy.wrap('projectId').as('project');
})
```
And in the helpers:
```
export const createFeature_API = (
featureName: string,
options?: Partial<Cypress.RequestOptions>,
): Chainable<any> => {
return cy.get('@project').then((project) => {
projectName = project || 'default';
return cy.request({
url: `${baseUrl}/api/admin/projects/${projectName}/features`,
method: 'POST',
body: {
name: `${featureName}`,
description: 'hello-world',
type: 'release',
impressionData: false,
},
...options,
});
});
};
```
2023-11-27 13:55:44 +01:00
|
|
|
updateFlexibleRolloutStrategy_UI(
|
|
|
|
featureToggleName: string,
|
|
|
|
projectName?: string,
|
|
|
|
);
|
2023-04-04 10:46:28 +02:00
|
|
|
deleteFeatureStrategy_UI(
|
|
|
|
featureName: string,
|
|
|
|
shouldWait?: boolean,
|
2023-10-02 14:25:46 +02:00
|
|
|
projectName?: string,
|
2023-04-04 10:46:28 +02:00
|
|
|
): Chainable;
|
|
|
|
|
|
|
|
// API
|
|
|
|
createUser_API(userName: string, role: number): Chainable;
|
|
|
|
updateUserPassword_API(id: number, pass?: string): Chainable;
|
|
|
|
addUserToProject_API(
|
|
|
|
id: number,
|
|
|
|
role: number,
|
2023-10-02 14:25:46 +02:00
|
|
|
projectName?: string,
|
2023-04-04 10:46:28 +02:00
|
|
|
): Chainable;
|
2023-05-08 10:16:18 +02:00
|
|
|
createProject_API(
|
|
|
|
name: string,
|
2023-10-02 14:25:46 +02:00
|
|
|
options?: Partial<Cypress.RequestOptions>,
|
2023-05-08 10:16:18 +02:00
|
|
|
): Chainable;
|
2023-04-04 10:46:28 +02:00
|
|
|
deleteProject_API(name: string): Chainable;
|
2023-05-08 10:16:18 +02:00
|
|
|
createFeature_API(
|
|
|
|
name: string,
|
|
|
|
projectName?: string,
|
2023-10-02 14:25:46 +02:00
|
|
|
options?: Partial<Cypress.RequestOptions>,
|
2023-05-08 10:16:18 +02:00
|
|
|
): Chainable;
|
refactor: isolate tests (#5433)
This PR fixes a race condition between e2e tests where bulk archiving
all toggles in the default project would delete toggles used for the
features e2e tests.
It does by isolating the features.spec and overview.spec to their
respective projects, so that they always operate on isolated data.
### Future enhancements:
I'm not particularly fond of passing the projectName through to all the
helper methods. It complicates the tests more than it should. I would
like to be able to set the project once per test and have all the helper
methods be aware of the context. Something like this should work:
```
before(() => {
cy.wrap('projectId').as('project');
})
```
And in the helpers:
```
export const createFeature_API = (
featureName: string,
options?: Partial<Cypress.RequestOptions>,
): Chainable<any> => {
return cy.get('@project').then((project) => {
projectName = project || 'default';
return cy.request({
url: `${baseUrl}/api/admin/projects/${projectName}/features`,
method: 'POST',
body: {
name: `${featureName}`,
description: 'hello-world',
type: 'release',
impressionData: false,
},
...options,
});
});
};
```
2023-11-27 13:55:44 +01:00
|
|
|
deleteFeature_API(name: string, projectName?: string): Chainable;
|
2023-05-08 10:16:18 +02:00
|
|
|
createEnvironment_API(
|
|
|
|
environment: IEnvironment,
|
2023-10-02 14:25:46 +02:00
|
|
|
options?: Partial<Cypress.RequestOptions>,
|
2023-05-08 10:16:18 +02:00
|
|
|
): Chainable;
|
2023-04-04 10:46:28 +02:00
|
|
|
}
|
|
|
|
}
|