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
This commit is contained in:
Hetu Nandu 2023-07-05 19:39:04 +05:30 committed by GitHub
parent e6f2dcacde
commit 87b60908a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 31 additions and 39 deletions

View File

@ -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

View File

@ -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();

View File

@ -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();

View File

@ -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([

View File

@ -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
}
}

View File

@ -1,9 +0,0 @@
{
"responseMeta": {
"status": 200,
"success": true
},
"data": {
"APP_EMBED_VIEW_HIDE_SHARE_SETTINGS_VISIBILITY": true
}
}

View File

@ -0,0 +1,17 @@
export const featureFlagIntercept = (
flags: Record<string, boolean>,
reload = true,
) => {
const response = {
responseMeta: {
status: 200,
success: true,
},
data: flags,
errorDisplay: "",
};
cy.intercept("GET", "/api/v1/users/features", response);
if (reload) {
cy.reload();
}
};

View File

@ -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", () => {

View File

@ -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,

View File

@ -3,11 +3,6 @@
<autocreate>false</autocreate>
<audit>false</audit>
<features>
<feature uid="MULTIPLE_PANES" enable="true" description="Have multiple panes in the Appsmith IDE">
<flipstrategy class="com.appsmith.server.featureflags.strategies.EmailBasedRolloutStrategy">
<param name="emails" value="multipanes@appsmith.com,ndx@appsmith.com"/>
</flipstrategy>
</feature>
<feature uid="APP_NAVIGATION_LOGO_UPLOAD" enable="true"
description="Logo upload feature for app viewer navigation">
<flipstrategy class="com.appsmith.server.featureflags.strategies.EmailBasedRolloutStrategy">