From 7a844466d84537e7b886015e92d173fc359c51e8 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 28 Mar 2024 17:17:24 -0300 Subject: [PATCH] migrate commits on wrong branch --- .../end-to-end/codeAreaModalComponent.spec.ts | 103 ++++-------------- .../end-to-end/curl_api_generation.spec.ts | 17 +++ .../end-to-end/python_api_generation.spec.ts | 17 +++ 3 files changed, 53 insertions(+), 84 deletions(-) create mode 100644 src/frontend/tests/end-to-end/curl_api_generation.spec.ts create mode 100644 src/frontend/tests/end-to-end/python_api_generation.spec.ts diff --git a/src/frontend/tests/end-to-end/codeAreaModalComponent.spec.ts b/src/frontend/tests/end-to-end/codeAreaModalComponent.spec.ts index 2dac888ac..5101a6be2 100644 --- a/src/frontend/tests/end-to-end/codeAreaModalComponent.spec.ts +++ b/src/frontend/tests/end-to-end/codeAreaModalComponent.spec.ts @@ -1,10 +1,10 @@ import { expect, test } from "@playwright/test"; test.beforeEach(async ({ page }) => { - // await page.waitForTimeout(2000); - // test.setTimeout(120000); + await page.waitForTimeout(2000); + test.setTimeout(120000); }); test("CodeAreaModalComponent", async ({ page }) => { - await page.goto("/"); + await page.goto("http://localhost:3000/"); await page.waitForTimeout(2000); await page.locator('//*[@id="new-project-btn"]').click(); @@ -28,86 +28,21 @@ test("CodeAreaModalComponent", async ({ page }) => { await page.getByTestId("code-button-modal").click(); let value = await page.locator('//*[@id="codeValue"]').inputValue(); - - if ( - value != - 'def python_function(text: str) -> str: """This is a default python function that returns the input text""" return text' - ) { - expect(false).toBeTruthy(); - } - + const code = 'def python_function(text: str) -> str:\n """This is a default python function that returns the input text"""\n return text' + const wCode = 'def python_function(text: str) -> st: """This is a default python function that returns the input text""" return text' + const assertCode ='def python_function(text: str) -> str: """This is a default python function that returns the input text""" return text' + await page.locator('#CodeEditor div').filter({ hasText: 'def python_function(text: str' }).nth(1).click(); + await page.locator('textarea').press('Control+a'); + await page.locator('textarea').fill(wCode); await page.locator('//*[@id="checkAndSaveBtn"]').click(); + await page.waitForTimeout(1000); + expect(await page.getByText("invalid syntax (, line 1)").isVisible()).toBeTruthy(); + await page.locator('textarea').press('Control+a'); + await page.locator('textarea').fill(wCode); + await page.locator('textarea').fill(code); + await page.locator('//*[@id="checkAndSaveBtn"]').click(); + expect(await page.getByText("Code is ready to run").isVisible()).toBeTruthy(); + await page.getByTestId("code-button-modal").click(); + expect(await page.locator('//*[@id="codeValue"]').inputValue()).toBe(assertCode); - await page.getByTestId("div-generic-node").click(); - - await page.getByTestId("more-options-modal").click(); - await page.getByTestId("edit-button-modal").click(); - - await page.locator('//*[@id="showdescription"]').click(); - expect( - await page.locator('//*[@id="showdescription"]').isChecked() - ).toBeFalsy(); - - await page.locator('//*[@id="showname"]').click(); - expect(await page.locator('//*[@id="showname"]').isChecked()).toBeFalsy(); - - await page.locator('//*[@id="showreturn_direct"]').click(); - expect( - await page.locator('//*[@id="showreturn_direct"]').isChecked() - ).toBeFalsy(); - - await page.locator('//*[@id="showdescription"]').click(); - expect( - await page.locator('//*[@id="showdescription"]').isChecked() - ).toBeTruthy(); - - await page.locator('//*[@id="showname"]').click(); - expect(await page.locator('//*[@id="showname"]').isChecked()).toBeTruthy(); - - await page.locator('//*[@id="showreturn_direct"]').click(); - expect( - await page.locator('//*[@id="showreturn_direct"]').isChecked() - ).toBeTruthy(); - - await page.locator('//*[@id="showdescription"]').click(); - expect( - await page.locator('//*[@id="showdescription"]').isChecked() - ).toBeFalsy(); - - await page.locator('//*[@id="showname"]').click(); - expect(await page.locator('//*[@id="showname"]').isChecked()).toBeFalsy(); - - await page.locator('//*[@id="showreturn_direct"]').click(); - expect( - await page.locator('//*[@id="showreturn_direct"]').isChecked() - ).toBeFalsy(); - - await page.locator('//*[@id="showdescription"]').click(); - expect( - await page.locator('//*[@id="showdescription"]').isChecked() - ).toBeTruthy(); - - await page.locator('//*[@id="showname"]').click(); - expect(await page.locator('//*[@id="showname"]').isChecked()).toBeTruthy(); - - await page.locator('//*[@id="showreturn_direct"]').click(); - expect( - await page.locator('//*[@id="showreturn_direct"]').isChecked() - ).toBeTruthy(); - - await page.locator('//*[@id="saveChangesBtn"]').click(); - - const plusButtonLocator = page.locator('//*[@id="code-input-0"]'); - const elementCount = await plusButtonLocator.count(); - if (elementCount === 0) { - expect(true).toBeTruthy(); - - await page.getByTestId("more-options-modal").click(); - await page.getByTestId("edit-button-modal").click(); - - await page.locator('//*[@id="saveChangesBtn"]').click(); - - await page.getByTestId("div-generic-node").click(); - await page.getByTestId("code-button-modal").click(); - } -}); +}); \ No newline at end of file diff --git a/src/frontend/tests/end-to-end/curl_api_generation.spec.ts b/src/frontend/tests/end-to-end/curl_api_generation.spec.ts new file mode 100644 index 000000000..1cbb18cd4 --- /dev/null +++ b/src/frontend/tests/end-to-end/curl_api_generation.spec.ts @@ -0,0 +1,17 @@ +import { test, expect } from '@playwright/test'; + + +test('curl_api_generation', async ({ page,context }) => { + await page.goto("/"); + await page.locator('//*[@id="new-project-btn"]').click(); + await context.grantPermissions(["clipboard-read", "clipboard-write"]); + await page.getByRole('heading', { name: 'Data Ingestion' }).click(); + await page.waitForTimeout(2000); + await page.getByText('API', { exact: true }).click(); + await page.getByRole('tab', { name: 'cURL' }).click(); + await page.getByRole('button', { name: 'Copy Code' }).click(); + const handle = await page.evaluateHandle(() => navigator.clipboard.readText()); + const clipboardContent = await handle.jsonValue(); + expect(clipboardContent.length).toBeGreaterThan(0); + +}); \ No newline at end of file diff --git a/src/frontend/tests/end-to-end/python_api_generation.spec.ts b/src/frontend/tests/end-to-end/python_api_generation.spec.ts new file mode 100644 index 000000000..50992cf1f --- /dev/null +++ b/src/frontend/tests/end-to-end/python_api_generation.spec.ts @@ -0,0 +1,17 @@ +import { test, expect } from '@playwright/test'; + + +test('python_api_generation', async ({ page,context }) => { + await page.goto("/"); + await page.locator('//*[@id="new-project-btn"]').click(); + await context.grantPermissions(["clipboard-read", "clipboard-write"]); + await page.getByRole('heading', { name: 'Data Ingestion' }).click(); + await page.waitForTimeout(2000); + await page.getByText('API', { exact: true }).click(); + await page.getByRole('tab', { name: 'Python API' }).click(); + await page.getByRole('button', { name: 'Copy Code' }).click(); + const handle = await page.evaluateHandle(() => navigator.clipboard.readText()); + const clipboardContent = await handle.jsonValue(); + expect(clipboardContent.length).toBeGreaterThan(0); + +}); \ No newline at end of file