From 623b9b127f1688f4d3b930bba1aab00075c1bd22 Mon Sep 17 00:00:00 2001 From: Gard Rimestad Date: Thu, 11 Jan 2024 09:56:43 +0100 Subject: [PATCH] chore: validate import data using api (#5848) Use the admin api to validate the feature toggle that has been imported. This hopefully makes the test less fragile as we do not depend on the frontend to validate the import. --- .../cypress/integration/import/import.spec.ts | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/frontend/cypress/integration/import/import.spec.ts b/frontend/cypress/integration/import/import.spec.ts index e42728d45a..cf8233e936 100644 --- a/frontend/cypress/integration/import/import.spec.ts +++ b/frontend/cypress/integration/import/import.spec.ts @@ -115,17 +115,18 @@ describe('imports', () => { cy.wait(1500); - cy.visit(`/projects/default/features/${randomFeatureName}`); + cy.request({ + url: `/api/admin/projects/default/features/${randomFeatureName}`, + headers: { 'Content-Type': 'application/json' }, + }).then((response) => { + expect(response.body.name).to.equal(randomFeatureName); + const devEnv = response.body.environments.find( + (env: any) => env.name === 'development', + ); - cy.get( - "[data-testid='feature-toggle-status'] input[type='checkbox']:checked", - ) - .invoke('attr', 'aria-label') - .should('eq', 'development'); - - cy.get( - '[data-testid="FEATURE_ENVIRONMENT_ACCORDION_development"]', - ).click(); - cy.contains('50%'); + expect(devEnv.name).to.equal('development'); + expect(devEnv.strategies[0].parameters.rollout).to.equal('50'); + expect(devEnv.enabled).to.equal(true); + }); }); });