Refactor API generation tests

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-28 20:16:16 -03:00
commit 76dbaf3b21
5 changed files with 104 additions and 84 deletions

View file

@ -28,21 +28,31 @@ test("CodeAreaModalComponent", async ({ page }) => {
await page.getByTestId("code-button-modal").click();
let value = await page.locator('//*[@id="codeValue"]').inputValue();
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);
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 (<unknown>, line 1)").isVisible()).toBeTruthy();
await page.locator('textarea').press('Control+a');
await page.locator('textarea').fill(wCode);
await page.locator('textarea').fill(code);
expect(
await page.getByText("invalid syntax (<unknown>, 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);
});
expect(await page.locator('//*[@id="codeValue"]').inputValue()).toBe(
assertCode
);
});