mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 06:58:58 -05:00
✨ Add user login front-end integration test
This commit is contained in:
parent
b14b8f794a
commit
c33d4ff3e2
14 changed files with 172 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
import { test, expect } from "@playwright/test";
|
||||
|
||||
test("has title", async ({ page }) => {
|
||||
test("Has title", async ({ page }) => {
|
||||
await page.route("**/api/rpc/command/get-profile", (route) => {
|
||||
route.fulfill({
|
||||
status: 200,
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"~:email": "foo@example.com",
|
||||
"~:is-demo": false,
|
||||
"~:auth-backend": "penpot",
|
||||
"~:fullname": "Princesa Leia",
|
||||
"~:modified-at": "~m1713533116365",
|
||||
"~:is-active": true,
|
||||
"~:default-project-id": "~uc7ce0794-0992-8105-8004-38e630f7920b",
|
||||
"~:id": "~uc7ce0794-0992-8105-8004-38e630f29a9b",
|
||||
"~:is-muted": false,
|
||||
"~:default-team-id": "~uc7ce0794-0992-8105-8004-38e630f40f6d",
|
||||
"~:created-at": "~m1713533116365",
|
||||
"~:is-blocked": false,
|
||||
"~:props": {
|
||||
"~:nudge": {
|
||||
"~:big": 10,
|
||||
"~:small": 1
|
||||
},
|
||||
"~:v2-info-shown": true,
|
||||
"~:viewed-tutorial?": false,
|
||||
"~:viewed-walkthrough?": false
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -0,0 +1,12 @@
|
|||
[
|
||||
{
|
||||
"~:id": "~uc7ce0794-0992-8105-8004-38e630f7920b",
|
||||
"~:team-id": "~uc7ce0794-0992-8105-8004-38e630f40f6d",
|
||||
"~:created-at": "~m1713533116382",
|
||||
"~:modified-at": "~m1713533116382",
|
||||
"~:is-default": true,
|
||||
"~:name": "Drafts",
|
||||
"~:is-pinned": false,
|
||||
"~:count": 0
|
||||
}
|
||||
]
|
|
@ -0,0 +1,16 @@
|
|||
[
|
||||
{
|
||||
"~:is-admin": true,
|
||||
"~:email": "foo@example.com",
|
||||
"~:team-id": "~uc7ce0794-0992-8105-8004-38e630f40f6d",
|
||||
"~:name": "Princesa Leia",
|
||||
"~:fullname": "Princesa Leia",
|
||||
"~:is-owner": true,
|
||||
"~:modified-at": "~m1713533116388",
|
||||
"~:can-edit": true,
|
||||
"~:is-active": true,
|
||||
"~:id": "~uc7ce0794-0992-8105-8004-38e630f29a9b",
|
||||
"~:profile-id": "~uc7ce0794-0992-8105-8004-38e630f29a9b",
|
||||
"~:created-at": "~m1713533116388"
|
||||
}
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -0,0 +1 @@
|
|||
[{"~:id":"~uc7ce0794-0992-8105-8004-38e630f29a9b","~:fullname":"Princesa Leia"}]
|
|
@ -0,0 +1,25 @@
|
|||
[
|
||||
{
|
||||
"~:features": {
|
||||
"~#set": [
|
||||
"layout/grid",
|
||||
"styles/v2",
|
||||
"fdata/pointer-map",
|
||||
"fdata/objects-map",
|
||||
"components/v2",
|
||||
"fdata/shape-data-type"
|
||||
]
|
||||
},
|
||||
"~:permissions": {
|
||||
"~:type": "~:membership",
|
||||
"~:is-owner": true,
|
||||
"~:is-admin": true,
|
||||
"~:can-edit": true
|
||||
},
|
||||
"~:name": "Default",
|
||||
"~:modified-at": "~m1713533116375",
|
||||
"~:id": "~uc7ce0794-0992-8105-8004-38e630f40f6d",
|
||||
"~:created-at": "~m1713533116375",
|
||||
"~:is-default": true
|
||||
}
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"~:is-admin": false,
|
||||
"~:email": "foo@example.com",
|
||||
"~:is-demo": false,
|
||||
"~:auth-backend": "penpot",
|
||||
"~:fullname": "Princesa Leia",
|
||||
"~:modified-at": "~m1713533116365",
|
||||
"~:is-active": true,
|
||||
"~:default-project-id": "~uc7ce0794-0992-8105-8004-38e630f7920b",
|
||||
"~:id": "~uc7ce0794-0992-8105-8004-38e630f29a9b",
|
||||
"~:is-muted": false,
|
||||
"~:default-team-id": "~uc7ce0794-0992-8105-8004-38e630f40f6d",
|
||||
"~:created-at": "~m1713533116365",
|
||||
"~:is-blocked": false,
|
||||
"~:props": {
|
||||
"~:nudge": {
|
||||
"~:big": 10,
|
||||
"~:small": 1
|
||||
},
|
||||
"~:v2-info-shown": true,
|
||||
"~:viewed-tutorial?": false,
|
||||
"~:viewed-walkthrough?": false
|
||||
}
|
||||
}
|
9
frontend/playwright/helpers/index.js
Normal file
9
frontend/playwright/helpers/index.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
export const interceptRPC = async (page, path, jsonFilename) => {
|
||||
await page.route(`**/api/rpc/command/${path}`, (route) => {
|
||||
route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/transit+json",
|
||||
path: `playwright/fixtures/${jsonFilename}`,
|
||||
});
|
||||
});
|
||||
};
|
56
frontend/playwright/login.spec.js
Normal file
56
frontend/playwright/login.spec.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
import { test, expect } from "@playwright/test";
|
||||
import { interceptRPC } from "./helpers";
|
||||
|
||||
const setupLoggedOutUser = async (page) => {
|
||||
await interceptRPC(page, "get-profile", "get-profile-anonymous.json");
|
||||
await interceptRPC(page, "login-with-password", "logged-in-user/login-with-password-success.json");
|
||||
};
|
||||
|
||||
// TODO: maybe Playwright's fixtures are the right way to do this?
|
||||
const setupDashboardUser = async (page) => {
|
||||
await interceptRPC(page, "get-profile", "logged-in-user/get-profile-logged-in.json");
|
||||
await interceptRPC(page, "get-teams", "logged-in-user/get-teams-default.json");
|
||||
await interceptRPC(page, "get-font-variants?team-id=*", "logged-in-user/get-font-variants-empty.json");
|
||||
await interceptRPC(page, "get-projects?team-id=*", "logged-in-user/get-projects-default.json");
|
||||
await interceptRPC(page, "get-team-members?team-id=*", "logged-in-user/get-team-members-your-penpot.json");
|
||||
await interceptRPC(page, "get-team-users?team-id=*", "logged-in-user/get-team-users-single-user.json");
|
||||
await interceptRPC(
|
||||
page,
|
||||
"get-unread-comment-threads?team-id=*",
|
||||
"logged-in-user/get-team-users-single-user.json",
|
||||
);
|
||||
await interceptRPC(
|
||||
page,
|
||||
"get-team-recent-files?team-id=*",
|
||||
"logged-in-user/get-team-recent-files-empty.json",
|
||||
);
|
||||
await interceptRPC(
|
||||
page,
|
||||
"get-profiles-for-file-comments",
|
||||
"logged-in-user/get-profiles-for-file-comments-empty.json",
|
||||
);
|
||||
};
|
||||
|
||||
test("Shows login page when going to index and user is logged out", async ({ page }) => {
|
||||
setupLoggedOutUser(page);
|
||||
|
||||
await page.goto("/");
|
||||
|
||||
await expect(page).toHaveURL(/auth\/login$/);
|
||||
await expect(page.getByText("Log into my account")).toBeVisible();
|
||||
});
|
||||
|
||||
test("User logs in by filling the login form", async ({ page }) => {
|
||||
setupLoggedOutUser(page);
|
||||
|
||||
await page.goto("/#/auth/login");
|
||||
|
||||
setupDashboardUser(page);
|
||||
|
||||
await page.getByLabel("Email").fill("foo@example.com");
|
||||
await page.getByLabel("Password").fill("loremipsum");
|
||||
|
||||
await page.getByRole("button", { name: "Login" }).click();
|
||||
|
||||
await expect(page).toHaveURL(/dashboard/);
|
||||
});
|
Loading…
Add table
Reference in a new issue