Skip to content

Commit

Permalink
test: fix general test and CI (langflow-ai#2839)
Browse files Browse the repository at this point in the history
🔧 (typescript_test.yml): Remove unnecessary steps and conditions in GitHub Actions workflow file
🔧 (authContext.tsx): Update cookie key from LANGFLOW_ACCESS_TOKEN to LANGFLOW_API_TOKEN for consistency
🔧 (Basic Prompting.spec.ts): Update test to click on correct dropdown option
🔧 (filterEdge-shard-0.spec.ts): Update test to check for correct element
🔧 (filterSidebar.spec.ts): Update test to check for correct elements
🔧 (generalBugs-shard-5.spec.ts): Update test to interact with correct element
🔧 (inputComponent.spec.ts): Update test to interact with correct elements
🔧 (store-shard-1.spec.ts): Update test to interact with correct elements and remove unnecessary code

(cherry picked from commit 9c9d916)
  • Loading branch information
Cristhianzl authored and nicoloboschi committed Jul 30, 2024
1 parent f588f36 commit ca626ce
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 34 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/typescript_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,8 @@ jobs:
run: |
cd src/frontend
npx playwright test --trace on --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --workers 2
continue-on-error: true
timeout-minutes: 12

# If the test fails, set a flag to indicate that the shard failed
- name: Set failure flag
id: check-failure
if: failure()
run: echo "failed=true" >> "$GITHUB_OUTPUT"

- name: Upload blob report to GitHub Actions Artifacts
if: always()
uses: actions/upload-artifact@v4
Expand All @@ -130,7 +123,6 @@ jobs:
merge-reports:
needs: setup-and-test
runs-on: ubuntu-latest
if: ${{ needs.setup-and-test.outputs.failed == 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -157,11 +149,3 @@ jobs:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 14
delete-reports:
needs: setup-and-test
runs-on: ubuntu-latest
if: ${{ needs.setup-and-test.outputs.failed != 'true' }}
steps:
- uses: geekyeggo/delete-artifact@v5
with:
name: blob-report-*
2 changes: 1 addition & 1 deletion src/frontend/src/contexts/authContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function AuthProvider({ children }): React.ReactElement {
}

function storeApiKey(apikey: string) {
cookies.set(LANGFLOW_ACCESS_TOKEN, apikey, { path: "/" });
cookies.set(LANGFLOW_API_TOKEN, apikey, { path: "/" });
setApiKey(apikey);
}

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/tests/end-to-end/Basic Prompting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test("Basic Prompting (Hello, World)", async ({ page }) => {
.fill(process.env.OPENAI_API_KEY ?? "");

await page.getByTestId("dropdown-model_name").click();
await page.getByTestId("gpt-4o-0-option").click();
await page.getByTestId("gpt-4o-1-option").click();

await page.waitForTimeout(2000);

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/tests/end-to-end/filterEdge-shard-0.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ test("RetrievalQA - Tooltip", async ({ page }) => {

await visibleElementHandle.hover().then(async () => {
await expect(
page.getByTestId("available-input-memories").first(),
page.getByTestId("available-input-helpers").first(),
).toBeVisible();
});
});
10 changes: 4 additions & 6 deletions src/frontend/tests/end-to-end/filterSidebar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,28 @@ test("LLMChain - Filter", async ({ page }) => {
await expect(page.getByTestId("dataAPI Request")).toBeVisible();
await expect(page.getByTestId("helpersChat Memory")).toBeVisible();
await expect(page.getByTestId("vectorstoresAstra DB")).toBeVisible();
await expect(page.getByTestId("langchain_utilitiesSearchApi")).toBeVisible();
await expect(page.getByTestId("toolsSearch API")).toBeVisible();
await expect(page.getByTestId("prototypesSub Flow")).toBeVisible();
await expect(
page.getByTestId("retrieversSelf Query Retriever"),
).toBeVisible();
await expect(
page.getByTestId("textsplittersCharacterTextSplitter"),
).toBeVisible();
await expect(page.getByTestId("toolsSearchApi")).toBeVisible();
await expect(page.getByTestId("toolsSearch API")).toBeVisible();

await page.getByPlaceholder("Search").click();

await expect(page.getByTestId("dataAPI Request")).not.toBeVisible();
await expect(page.getByTestId("helpersChat Memory")).not.toBeVisible();
await expect(page.getByTestId("vectorstoresAstra DB")).not.toBeVisible();
await expect(
page.getByTestId("langchain_utilitiesSearchApi"),
).not.toBeVisible();
await expect(page.getByTestId("toolsSearch API")).not.toBeVisible();
await expect(page.getByTestId("prototypesSub Flow")).not.toBeVisible();
await expect(
page.getByTestId("retrieversSelf Query Retriever"),
).not.toBeVisible();
await expect(
page.getByTestId("textsplittersCharacterTextSplitter"),
).not.toBeVisible();
await expect(page.getByTestId("toolsSearchApi")).not.toBeVisible();
await expect(page.getByTestId("toolsSearch API")).not.toBeVisible();
});
7 changes: 4 additions & 3 deletions src/frontend/tests/end-to-end/generalBugs-shard-5.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,11 @@ test("should be able to see output preview from grouped components", async ({

await page.getByTestId("button_run_text output").last().click();

await page.waitForSelector("text=Text Output built successfully", {
timeout: 30000,
});
await page.waitForSelector("text=built successfully", { timeout: 30000 });

await page.getByText("built successfully").last().click({
timeout: 15000,
});
await page.waitForTimeout(3000);

expect(
Expand Down
7 changes: 1 addition & 6 deletions src/frontend/tests/end-to-end/inputComponent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ test("InputComponent", async ({ page }) => {
expect(false).toBeTruthy();
}

await page.getByTestId("popover-anchor-input-collection_name-edit").click();
await page
.getByTestId("popover-anchor-input-collection_name-edit")
.fill("NEW_collection_name_test_123123123!@#$&*(&%$@ÇÇÇÀõe");

await page.waitForTimeout(1000);
await page.getByText("Close").last().click();

const plusButtonLocator = page.getByTestId("input-collection_name");
Expand All @@ -147,11 +147,6 @@ test("InputComponent", async ({ page }) => {
await page.getByTestId("more-options-modal").click();
await page.getByTestId("edit-button-modal").click();

await page.locator('//*[@id="showcollection_name"]').click();
expect(
await page.locator('//*[@id="showcollection_name"]').isChecked(),
).toBeTruthy();

await page.getByText("Close").last().click();

let value = await page
Expand Down
20 changes: 20 additions & 0 deletions src/frontend/tests/end-to-end/store-shard-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@ test("should like and add components and flows", async ({ page }) => {
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(5000);
modalCount = await page.getByTestId("modal-title")?.count();
}

await page.getByText("Close", { exact: true }).click();

await page.waitForTimeout(1000);

await page.getByTestId("button-store").click();
await page.waitForTimeout(1000);

Expand Down

0 comments on commit ca626ce

Please sign in to comment.