Skip to content

Commit

Permalink
chore: Stub /features call in tests (appsmithorg#25104)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hetunandu authored Jul 5, 2023
1 parent e6f2dca commit 87b6090
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 39 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
11 changes: 0 additions & 11 deletions app/client/cypress/fixtures/featureFlags.json

This file was deleted.

9 changes: 0 additions & 9 deletions app/client/cypress/fixtures/featureFlagsComplement.json

This file was deleted.

17 changes: 17 additions & 0 deletions app/client/cypress/support/Objects/FeatureFlags.ts
Original file line number Diff line number Diff line change
@@ -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();
}
};
2 changes: 2 additions & 0 deletions app/client/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down

0 comments on commit 87b6090

Please sign in to comment.