fix: Add robust auto-login system with exponential backoff to fix authentication redirects in make command environments (#6848)
* 📝 (frontend): add IS_AUTO_LOGIN constant to handle auto login functionality 🔧 (frontend): update API calls to consider IS_AUTO_LOGIN constant for authentication errors ♻️ (frontend): refactor useGetAutoLogin to handle auto login retries and errors ♻️ (frontend): refactor usePostRefreshAccess to handle auto login retries ♻️ (frontend): refactor request processor to include retry logic with exponential backoff 🔧 (frontend): update Vite config to include LANGFLOW_AUTO_LOGIN environment variable * 🐛 (constants.ts): fix logic in IS_AUTO_LOGIN constant to correctly evaluate the auto login condition based on the environment variable LANGFLOW_AUTO_LOGIN * ✨ (index.tsx): Add support for testMockAutoLogin to simulate auto login for testing purposes 🔧 (constants.ts): Refactor IS_AUTO_LOGIN to handle optional chaining for process.env properties ✨ (auto-login-off.spec.ts): Add test cases to simulate auto login behavior for testing 🔧 (vite.config.mts): Update vite configuration to load environment variables from .env file and handle optional chaining for envLangflow properties
This commit is contained in:
parent
9ade6977c7
commit
ff02e3d20e
8 changed files with 137 additions and 22 deletions
|
|
@ -15,6 +15,20 @@ test(
|
|||
});
|
||||
});
|
||||
|
||||
await page.addInitScript(() => {
|
||||
window.process = window.process || {};
|
||||
|
||||
const newEnv = { ...window.process.env, LANGFLOW_AUTO_LOGIN: "false" };
|
||||
|
||||
Object.defineProperty(window.process, "env", {
|
||||
value: newEnv,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
sessionStorage.setItem("testMockAutoLogin", "true");
|
||||
});
|
||||
|
||||
const randomName = Math.random().toString(36).substring(5);
|
||||
const randomPassword = Math.random().toString(36).substring(5);
|
||||
const secondRandomName = Math.random().toString(36).substring(5);
|
||||
|
|
@ -28,6 +42,10 @@ test(
|
|||
await page.getByPlaceholder("Username").fill("langflow");
|
||||
await page.getByPlaceholder("Password").fill("langflow");
|
||||
|
||||
await page.evaluate(() => {
|
||||
sessionStorage.removeItem("testMockAutoLogin");
|
||||
});
|
||||
|
||||
await page.getByRole("button", { name: "Sign In" }).click();
|
||||
|
||||
await page.waitForSelector('[data-testid="mainpage_title"]', {
|
||||
|
|
@ -161,6 +179,10 @@ test(
|
|||
|
||||
await page.getByTestId("user-profile-settings").click();
|
||||
|
||||
await page.evaluate(() => {
|
||||
sessionStorage.setItem("testMockAutoLogin", "true");
|
||||
});
|
||||
|
||||
await page.getByText("Logout", { exact: true }).click();
|
||||
|
||||
await page.waitForSelector("text=sign in to langflow", { timeout: 30000 });
|
||||
|
|
@ -174,6 +196,10 @@ test(
|
|||
|
||||
await page.getByRole("button", { name: "Sign In" }).click();
|
||||
|
||||
await page.evaluate(() => {
|
||||
sessionStorage.removeItem("testMockAutoLogin");
|
||||
});
|
||||
|
||||
await page.waitForSelector('[id="new-project-btn"]', {
|
||||
timeout: 30000,
|
||||
});
|
||||
|
|
@ -231,6 +257,10 @@ test(
|
|||
|
||||
await page.getByTestId("user-profile-settings").click();
|
||||
|
||||
await page.evaluate(() => {
|
||||
sessionStorage.setItem("testMockAutoLogin", "true");
|
||||
});
|
||||
|
||||
await page.getByText("Logout", { exact: true }).click();
|
||||
|
||||
await page.waitForSelector("text=sign in to langflow", { timeout: 30000 });
|
||||
|
|
@ -238,6 +268,10 @@ test(
|
|||
await page.getByPlaceholder("Username").fill("langflow");
|
||||
await page.getByPlaceholder("Password").fill("langflow");
|
||||
|
||||
await page.evaluate(() => {
|
||||
sessionStorage.removeItem("testMockAutoLogin");
|
||||
});
|
||||
|
||||
await page.getByRole("button", { name: "Sign In" }).click();
|
||||
|
||||
await page.waitForSelector('[data-testid="mainpage_title"]', {
|
||||
|
|
@ -255,5 +289,9 @@ test(
|
|||
await expect(page.getByText(randomFlowName, { exact: true })).toBeVisible({
|
||||
timeout: 2000,
|
||||
});
|
||||
|
||||
await page.evaluate(() => {
|
||||
sessionStorage.removeItem("testMockAutoLogin");
|
||||
});
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue