From 87b60908a4fbb6701745f8f4d4d596ff256a7900 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Wed, 5 Jul 2023 19:39:04 +0530 Subject: [PATCH] chore: Stub /features call in tests (#25104) This change will stub the call to `users/features` to get the feature flags. By default it will return an empty list and rely on the client default flag list to enable/disable features --- CODEOWNERS | 1 + .../IDE/MaintainContext&Focus_spec.js | 4 ---- .../SettingsPane/EmbedSettings_spec.ts | 17 +++++++++++------ .../Sanity/Datasources/GoogleSheetsStub_spec.ts | 3 --- app/client/cypress/fixtures/featureFlags.json | 11 ----------- .../fixtures/featureFlagsComplement.json | 9 --------- .../cypress/support/Objects/FeatureFlags.ts | 17 +++++++++++++++++ app/client/cypress/support/commands.js | 2 ++ .../server/featureflags/FeatureFlagEnum.java | 1 - .../src/main/resources/features/init-flags.xml | 5 ----- 10 files changed, 31 insertions(+), 39 deletions(-) delete mode 100644 app/client/cypress/fixtures/featureFlags.json delete mode 100644 app/client/cypress/fixtures/featureFlagsComplement.json create mode 100644 app/client/cypress/support/Objects/FeatureFlags.ts diff --git a/CODEOWNERS b/CODEOWNERS index 6a09e55543..cb7f2daf14 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -38,6 +38,7 @@ app/client/src/ee/pages/Editor/NavigationSettings/LogoInput.tsx @dhruvikn # New Developers Pod app/client/src/ce/entities/FeatureFlag.ts @hetunandu app/client/src/ee/entities/FeatureFlag.ts @hetunandu +app/server/appsmith-server/src/main/resources/features/init-flags.xml @hetunandu # UI Builders Pod app/client/generators/* @appsmithorg/ui-builders diff --git a/app/client/cypress/e2e/Regression/ClientSide/IDE/MaintainContext&Focus_spec.js b/app/client/cypress/e2e/Regression/ClientSide/IDE/MaintainContext&Focus_spec.js index 236d439c4d..3a985d8eec 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/IDE/MaintainContext&Focus_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/IDE/MaintainContext&Focus_spec.js @@ -7,10 +7,6 @@ const queryLocators = require("../../../../locators/QueryEditor.json"); describe("MaintainContext&Focus", function () { before("Import the test application", () => { _.homePage.NavigateToHome(); - cy.intercept("GET", "/api/v1/users/features", { - fixture: "featureFlags.json", - }).as("featureFlags"); - cy.reload(); _.homePage.ImportApp("ContextSwitching.json"); cy.wait("@importNewApplication").then((interception) => { _.agHelper.Sleep(); diff --git a/app/client/cypress/e2e/Regression/ClientSide/SettingsPane/EmbedSettings_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/SettingsPane/EmbedSettings_spec.ts index 804d816b61..c87d526e30 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/SettingsPane/EmbedSettings_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/SettingsPane/EmbedSettings_spec.ts @@ -5,6 +5,7 @@ import { agHelper, appSettings, } from "../../../../support/Objects/ObjectsCore"; +import { featureFlagIntercept } from "../../../../support/Objects/FeatureFlags"; describe("In-app embed settings", () => { function ValidateSyncWithInviteModal(showNavigationBar: "true" | "false") { @@ -72,9 +73,12 @@ describe("In-app embed settings", () => { }); it("5. [Feature flag APP_EMBED_VIEW_HIDE_SHARE_SETTINGS_VISIBILITY=false] Changing the show navigation bar setting in the App settings pane should update the embed URL with embed parameter", () => { - cy.intercept("GET", "/api/v1/users/features", { - fixture: "featureFlags.json", - }).as("featureFlags"); + featureFlagIntercept( + { + APP_EMBED_VIEW_HIDE_SHARE_SETTINGS_VISIBILITY: false, + }, + false, + ); agHelper.RefreshPage(); embedSettings.OpenEmbedSettings(); embedSettings.TogglePublicAccess(true); @@ -93,9 +97,10 @@ describe("In-app embed settings", () => { }); it("6. [Feature flag APP_EMBED_VIEW_HIDE_SHARE_SETTINGS_VISIBILITY=true] Changing the show navigation bar setting in the App settings pane should update the embed URL with navbar parameter", () => { - cy.intercept("GET", "/api/v1/users/features", { - fixture: "featureFlagsComplement.json", - }).as("featureFlags"); + featureFlagIntercept( + { APP_EMBED_VIEW_HIDE_SHARE_SETTINGS_VISIBILITY: true }, + false, + ); agHelper.RefreshPage(); embedSettings.OpenEmbedSettings(); diff --git a/app/client/cypress/e2e/Sanity/Datasources/GoogleSheetsStub_spec.ts b/app/client/cypress/e2e/Sanity/Datasources/GoogleSheetsStub_spec.ts index 37d0cf098e..0c91f5b030 100644 --- a/app/client/cypress/e2e/Sanity/Datasources/GoogleSheetsStub_spec.ts +++ b/app/client/cypress/e2e/Sanity/Datasources/GoogleSheetsStub_spec.ts @@ -5,9 +5,6 @@ describe( "Google Sheets datasource test cases", function () { it("1. Create Google Sheets datasource", function () { - cy.intercept("GET", "/api/v1/users/features", { - fixture: "featureFlags.json", - }).as("featureFlags"); dataSources.NavigateToDSCreateNew(); dataSources.CreatePlugIn("Google Sheets"); VerifyFunctionDropdown([ diff --git a/app/client/cypress/fixtures/featureFlags.json b/app/client/cypress/fixtures/featureFlags.json deleted file mode 100644 index 11e218ae64..0000000000 --- a/app/client/cypress/fixtures/featureFlags.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "responseMeta": { - "status": 200, - "success": true - }, - "data": { - "release_datasource_environments_enabled": false, - "MULTIPLE_PANES": false, - "APP_EMBED_VIEW_HIDE_SHARE_SETTINGS_VISIBILITY": false - } -} diff --git a/app/client/cypress/fixtures/featureFlagsComplement.json b/app/client/cypress/fixtures/featureFlagsComplement.json deleted file mode 100644 index 8bced861b7..0000000000 --- a/app/client/cypress/fixtures/featureFlagsComplement.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "responseMeta": { - "status": 200, - "success": true - }, - "data": { - "APP_EMBED_VIEW_HIDE_SHARE_SETTINGS_VISIBILITY": true - } -} diff --git a/app/client/cypress/support/Objects/FeatureFlags.ts b/app/client/cypress/support/Objects/FeatureFlags.ts new file mode 100644 index 0000000000..788bde5643 --- /dev/null +++ b/app/client/cypress/support/Objects/FeatureFlags.ts @@ -0,0 +1,17 @@ +export const featureFlagIntercept = ( + flags: Record, + reload = true, +) => { + const response = { + responseMeta: { + status: 200, + success: true, + }, + data: flags, + errorDisplay: "", + }; + cy.intercept("GET", "/api/v1/users/features", response); + if (reload) { + cy.reload(); + } +}; diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index f849e42222..60dc17086a 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -31,6 +31,7 @@ const welcomePage = require("../locators/welcomePage.json"); const publishWidgetspage = require("../locators/publishWidgetspage.json"); import { ObjectsRegistry } from "../support/Objects/Registry"; import RapidMode from "./RapidMode"; +import { featureFlagIntercept } from "./Objects/FeatureFlags"; const propPane = ObjectsRegistry.PropertyPane; const agHelper = ObjectsRegistry.AggregateHelper; @@ -1126,6 +1127,7 @@ Cypress.Commands.add("startServerAndRoutes", () => { }).as("postTenant"); cy.intercept("PUT", "/api/v1/git/discard/app/*").as("discardChanges"); cy.intercept("GET", "/api/v1/libraries/*").as("getLibraries"); + featureFlagIntercept({}, false); }); Cypress.Commands.add("startErrorRoutes", () => { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/featureflags/FeatureFlagEnum.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/featureflags/FeatureFlagEnum.java index c099767c3b..6caf28956d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/featureflags/FeatureFlagEnum.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/featureflags/FeatureFlagEnum.java @@ -24,7 +24,6 @@ public enum FeatureFlagEnum { // ------------------- These are actual feature flags meant to be used across the product ----------------------- // release_datasource_environments_enabled, - MULTIPLE_PANES, APP_NAVIGATION_LOGO_UPLOAD, APP_EMBED_VIEW_HIDE_SHARE_SETTINGS_VISIBILITY, diff --git a/app/server/appsmith-server/src/main/resources/features/init-flags.xml b/app/server/appsmith-server/src/main/resources/features/init-flags.xml index 4473fec08d..09cda0331c 100644 --- a/app/server/appsmith-server/src/main/resources/features/init-flags.xml +++ b/app/server/appsmith-server/src/main/resources/features/init-flags.xml @@ -3,11 +3,6 @@ false false - - - - -