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).
128 lines
4.0 KiB
TypeScript
128 lines
4.0 KiB
TypeScript
///<reference path="../../global.d.ts" />
|
|
|
|
describe('imports', () => {
|
|
const baseUrl = Cypress.config().baseUrl;
|
|
const randomSeed = String(Math.random()).split('.')[1];
|
|
const randomFeatureName = `cypress-features${randomSeed}`;
|
|
const userIds: any[] = [];
|
|
|
|
before(() => {
|
|
cy.runBefore();
|
|
cy.login_UI();
|
|
for (let i = 1; i <= 2; i++) {
|
|
cy.request('POST', `${baseUrl}/api/admin/user-admin`, {
|
|
name: `unleash-e2e-user${i}-${randomFeatureName}`,
|
|
email: `unleash-e2e-user${i}-${randomFeatureName}@test.com`,
|
|
sendEmail: false,
|
|
rootRole: 3,
|
|
}).then(response => userIds.push(response.body.id));
|
|
}
|
|
});
|
|
|
|
after(() => {
|
|
userIds.forEach(id =>
|
|
cy.request('DELETE', `${baseUrl}/api/admin/user-admin/${id}`)
|
|
);
|
|
});
|
|
|
|
beforeEach(() => {
|
|
cy.login_UI();
|
|
if (document.querySelector("[data-testid='CLOSE_SPLASH']")) {
|
|
cy.get("[data-testid='CLOSE_SPLASH']").click();
|
|
}
|
|
});
|
|
|
|
it('can import data', () => {
|
|
cy.visit('/projects/default');
|
|
cy.get("[data-testid='IMPORT_BUTTON']").click({ force: true });
|
|
|
|
const exportText = {
|
|
features: [
|
|
{
|
|
name: randomFeatureName,
|
|
description: '',
|
|
type: 'release',
|
|
project: 'default',
|
|
stale: false,
|
|
impressionData: false,
|
|
archived: false,
|
|
},
|
|
],
|
|
featureStrategies: [
|
|
{
|
|
name: 'flexibleRollout',
|
|
id: '14a0d9dd-2b5d-4a21-98fd-ede72bda0328',
|
|
featureName: randomFeatureName,
|
|
parameters: {
|
|
groupId: randomFeatureName,
|
|
rollout: '50',
|
|
stickiness: 'default',
|
|
},
|
|
constraints: [],
|
|
segments: [],
|
|
},
|
|
],
|
|
featureEnvironments: [
|
|
{
|
|
enabled: true,
|
|
featureName: randomFeatureName,
|
|
environment: 'test',
|
|
variants: [],
|
|
name: randomFeatureName,
|
|
},
|
|
],
|
|
contextFields: [],
|
|
featureTags: [
|
|
{
|
|
featureName: randomFeatureName,
|
|
tagType: 'simple',
|
|
tagValue: 'best-tag',
|
|
},
|
|
{
|
|
featureName: randomFeatureName,
|
|
tagType: 'simple',
|
|
tagValue: 'rserw',
|
|
},
|
|
{
|
|
featureName: randomFeatureName,
|
|
tagType: 'simple',
|
|
tagValue: 'FARO',
|
|
},
|
|
],
|
|
segments: [],
|
|
tagTypes: [
|
|
{
|
|
name: 'simple',
|
|
description: 'Used to simplify filtering of features',
|
|
icon: '#',
|
|
},
|
|
],
|
|
};
|
|
|
|
cy.get("[data-testid='VALIDATE_BUTTON']").should('be.disabled');
|
|
|
|
// cypress can only work with input@file that is visible
|
|
cy.get('input[type=file]')
|
|
.invoke('attr', 'style', 'display: block')
|
|
.selectFile({
|
|
contents: Cypress.Buffer.from(JSON.stringify(exportText)),
|
|
fileName: 'upload.json',
|
|
lastModified: Date.now(),
|
|
});
|
|
cy.get("[data-testid='VALIDATE_BUTTON']").click();
|
|
cy.get("[data-testid='IMPORT_CONFIGURATION_BUTTON']").click();
|
|
// cy.contains('Import completed');
|
|
|
|
cy.visit(`/projects/default/features/${randomFeatureName}`);
|
|
|
|
cy.wait(500);
|
|
|
|
cy.get(
|
|
"[data-testid='feature-toggle-status'] input[type='checkbox']:checked"
|
|
)
|
|
.closest('div')
|
|
.contains('development');
|
|
cy.contains('50%');
|
|
});
|
|
});
|