-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new .env variable "LANGFLOW_FEATURE_MVP_COMPONENTS" to show…
…/hide integration sidebar components (#4270) * ✨ (authContext.tsx): Add functionality to fetch global variables on authentication 🔧 (api.tsx): Replace universal-cookie import with react-cookie for consistency 🔧 (authStore.ts): Replace universal-cookie import with react-cookie for consistency 🔧 (use-get-global-variables.ts): Add check to only fetch global variables if user is authenticated ✨ (use-get-mutation-global-variables.ts): Add mutation function to fetch and update global variables 🔧 (authStore.ts): Replace universal-cookie import with react-cookie for consistency * 📝 (endpoints.py): add feature_flags field to ConfigResponse schema 📝 (endpoints.py): modify get_config function to include feature_flags in the response 📝 (feature_flags.py): add mvp_components field to FeatureFlags settings 📝 (schemas.py): add feature_flags field to ConfigResponse schema * ✨ (use-get-config.ts): Add feature_flags field to ConfigResponse interface to support feature flags in the application 🔧 (utilityStore.ts): Add featureFlags field and setFeatureFlags function to utilityStore to manage feature flags in the application 💡 (extraSidebarComponent/index.tsx): Use featureFlags from utilityStore to conditionally render components based on feature flags in ExtraSidebar component * ♻️ (frontend/package-lock.json): remove extraneous flag from is-unicode-supported package to clean up unnecessary information * ✨ (integration-side-bar.spec.ts): Add integration tests to ensure correct visibility of integrations in the sidebar based on the value of mvp_components. * ✨ (integration-side-bar.spec.ts): update integration-side-bar tests to use feature_flags object for mvp_components flag for better readability and maintainability. * ✨ (integration-side-bar.spec.ts): add a 4-second delay before making the API call to improve test reliability * [autofix.ci] apply automated fixes * Update src/backend/base/langflow/api/v1/schemas.py Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> * Update src/backend/base/langflow/api/v1/endpoints.py Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> * formata * [autofix.ci] apply automated fixes * ✨ (extraSidebarComponent/index.tsx): update featureFlags property access to use optional chaining for better error handling 📝 (stop-building.spec.ts): add ua-parser-js import to get user agent information and update control key based on user's operating system for better user experience. Also, refactor code to improve readability and add comments for better understanding. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
- Loading branch information
1 parent
d53107c
commit a88fd9b
Showing
9 changed files
with
180 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/frontend/tests/extended/features/integration-side-bar.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test("user should be able to see integrations in the sidebar if mvp_components is true", async ({ | ||
page, | ||
}) => { | ||
await page.route("**/api/v1/config", (route) => { | ||
route.fulfill({ | ||
status: 200, | ||
contentType: "application/json", | ||
body: JSON.stringify({ | ||
feature_flags: { | ||
mvp_components: true, | ||
}, | ||
}), | ||
headers: { | ||
"content-type": "application/json", | ||
...route.request().headers(), | ||
}, | ||
}); | ||
}); | ||
|
||
await page.goto("/"); | ||
await page.waitForTimeout(1000); | ||
|
||
let modalCount = 0; | ||
try { | ||
const modalTitleElement = await page?.getByTestId("modal-title"); | ||
if (modalTitleElement) { | ||
modalCount = await modalTitleElement.count(); | ||
} | ||
} catch (error) { | ||
modalCount = 0; | ||
} | ||
|
||
while (modalCount === 0) { | ||
await page.getByText("New Project", { exact: true }).click(); | ||
await page.waitForTimeout(3000); | ||
modalCount = await page.getByTestId("modal-title")?.count(); | ||
} | ||
|
||
await page.getByTestId("blank-flow").click(); | ||
await page.waitForSelector('[data-testid="extended-disclosure"]', { | ||
timeout: 30000, | ||
}); | ||
|
||
await expect(page.getByText("Integrations")).toBeVisible(); | ||
await expect(page.getByText("Notion")).toBeVisible(); | ||
}); | ||
|
||
test("user should NOT be able to see integrations in the sidebar if mvp_components is false", async ({ | ||
page, | ||
}) => { | ||
await page.waitForTimeout(4000); | ||
await page.route("**/api/v1/config", (route) => { | ||
route.fulfill({ | ||
status: 200, | ||
contentType: "application/json", | ||
body: JSON.stringify({ | ||
feature_flags: { | ||
mvp_components: false, | ||
}, | ||
}), | ||
headers: { | ||
"content-type": "application/json", | ||
...route.request().headers(), | ||
}, | ||
}); | ||
}); | ||
|
||
await page.goto("/"); | ||
await page.waitForTimeout(1000); | ||
|
||
let modalCount = 0; | ||
try { | ||
const modalTitleElement = await page?.getByTestId("modal-title"); | ||
if (modalTitleElement) { | ||
modalCount = await modalTitleElement.count(); | ||
} | ||
} catch (error) { | ||
modalCount = 0; | ||
} | ||
|
||
while (modalCount === 0) { | ||
await page.getByText("New Project", { exact: true }).click(); | ||
await page.waitForTimeout(3000); | ||
modalCount = await page.getByTestId("modal-title")?.count(); | ||
} | ||
|
||
await page.getByTestId("blank-flow").click(); | ||
await page.waitForSelector('[data-testid="extended-disclosure"]', { | ||
timeout: 30000, | ||
}); | ||
|
||
await expect(page.getByText("Integrations")).not.toBeVisible(); | ||
await expect(page.getByText("Notion")).not.toBeVisible(); | ||
}); |