login tests finished
This commit is contained in:
parent
21605d09ba
commit
55b71605ea
1 changed files with 97 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { test } from "@playwright/test";
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test.describe("Login Tests", () => {
|
||||
test("Login_Success", async ({ page }) => {
|
||||
|
|
@ -29,4 +29,100 @@ test.describe("Login Tests", () => {
|
|||
.evaluate((el) => el.children)
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
test("Login Error", async ({ page }) => {
|
||||
await page.route("**/api/v1/login", async (route) => {
|
||||
const json = { detail: "Incorrect username or password" };
|
||||
await route.fulfill({ json, status: 401 });
|
||||
});
|
||||
|
||||
await page.goto("http://localhost:3000/");
|
||||
await page.waitForURL("http://localhost:3000/login");
|
||||
await page.waitForURL("http://localhost:3000/login", { timeout: 100 });
|
||||
await page.getByPlaceholder("Username").click();
|
||||
await page.getByPlaceholder("Username").fill("test");
|
||||
await page.getByPlaceholder("Password").click();
|
||||
await page.getByPlaceholder("Password").fill("test5");
|
||||
await page.getByRole("button", { name: "Sign in" }).click();
|
||||
await page.getByRole("heading", { name: "Error signing in" }).click();
|
||||
});
|
||||
|
||||
test("Login create account wrong form", async ({ page }) => {
|
||||
const fullfillForm = async (username, password, confirmPassword) => {
|
||||
await page.getByPlaceholder("Username").click();
|
||||
await page.getByPlaceholder("Username").fill(username);
|
||||
await page.getByPlaceholder("Password", { exact: true }).click();
|
||||
await page.getByPlaceholder("Password", { exact: true }).fill(password);
|
||||
await page.getByPlaceholder("Confirm your password").click();
|
||||
await page
|
||||
.getByPlaceholder("Confirm your password")
|
||||
.fill(confirmPassword);
|
||||
};
|
||||
|
||||
await page.goto("http://localhost:3000/");
|
||||
await page.waitForURL("http://localhost:3000/login");
|
||||
await page.waitForURL("http://localhost:3000/login", { timeout: 100 });
|
||||
await page
|
||||
.getByRole("button", { name: "Don't have an account? Sign Up" })
|
||||
.click();
|
||||
await page.getByText("Sign up to Langflow").click();
|
||||
await page.goto("http://localhost:3000/signup");
|
||||
await page.getByText("Sign up to Langflow").click();
|
||||
|
||||
await fullfillForm("name", "vazz", "vazz5");
|
||||
expect(
|
||||
await page.getByRole("button", { name: "Sign up" }).isDisabled()
|
||||
).toBeTruthy();
|
||||
await fullfillForm("", "vazz", "vazz");
|
||||
expect(
|
||||
await page.getByRole("button", { name: "Sign up" }).isDisabled()
|
||||
).toBeTruthy();
|
||||
await fullfillForm("name", "", "");
|
||||
expect(
|
||||
await page.getByRole("button", { name: "Sign up" }).isDisabled()
|
||||
).toBeTruthy();
|
||||
await fullfillForm("", "", "");
|
||||
expect(
|
||||
await page.getByRole("button", { name: "Sign up" }).isDisabled()
|
||||
).toBeTruthy();
|
||||
});
|
||||
test("Login create account success", async ({ page }) => {
|
||||
await page.route("**/api/v1/users/", async (route) => {
|
||||
const json = {
|
||||
id: "e9ac1bdc-429b-475d-ac03-d26f9a2a3210",
|
||||
username: "teste",
|
||||
profile_image: null,
|
||||
is_active: false,
|
||||
is_superuser: false,
|
||||
create_at: "2023-09-21T01:45:51.873303",
|
||||
updated_at: "2023-09-21T01:45:51.873305",
|
||||
last_login_at: null,
|
||||
};
|
||||
await route.fulfill({ json, status: 201 });
|
||||
});
|
||||
const submitForm = async (username, password, confirmPassword) => {
|
||||
await page.getByPlaceholder("Username").click();
|
||||
await page.getByPlaceholder("Username").fill(username);
|
||||
await page.getByPlaceholder("Password", { exact: true }).click();
|
||||
await page.getByPlaceholder("Password", { exact: true }).fill(password);
|
||||
await page.getByPlaceholder("Confirm your password").click();
|
||||
await page
|
||||
.getByPlaceholder("Confirm your password")
|
||||
.fill(confirmPassword);
|
||||
};
|
||||
|
||||
await page.goto("http://localhost:3000/");
|
||||
await page.waitForURL("http://localhost:3000/login");
|
||||
await page.waitForURL("http://localhost:3000/login", { timeout: 100 });
|
||||
await page
|
||||
.getByRole("button", { name: "Don't have an account? Sign Up" })
|
||||
.click();
|
||||
await page.getByText("Sign up to Langflow").click();
|
||||
await page.goto("http://localhost:3000/signup");
|
||||
await page.getByText("Sign up to Langflow").click();
|
||||
await submitForm("teste", "pass", "pass");
|
||||
await page.getByRole("button", { name: "Sign up" }).click();
|
||||
await page.waitForURL("http://localhost:3000/login", { timeout: 1000 });
|
||||
await page.getByText("Account created! Await admin activation.").click();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue