-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from fjordllc/chore/create-first-e2e-test
はじめてのE2Eテストを作成する
- Loading branch information
Showing
10 changed files
with
1,424 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { describe } from "node:test"; | ||
import { expect } from "@playwright/test"; | ||
import { withSupawright } from "supawright"; | ||
import type { Database } from "../src/lib/database.types"; | ||
|
||
const test = withSupawright<Database, "public">(["public"]); | ||
|
||
describe("Login and Logout E2E test", () => { | ||
let validEmail: string | undefined; | ||
const e2ePassword = "e2e_password"; | ||
|
||
test.beforeEach(async ({ supawright }) => { | ||
const attributes = { | ||
password: e2ePassword, | ||
email_confirm: true, | ||
}; | ||
const user = await supawright.createUser(attributes); | ||
validEmail = user.email; | ||
}); | ||
|
||
test("Should Success Login with valid Email and Password then Logout", async ({ | ||
page, | ||
}) => { | ||
await page.goto("http://localhost:3000/"); | ||
await page.getByRole("link", { name: "ログイン" }).click(); | ||
|
||
console.log(`valid email: ${validEmail}`); | ||
|
||
await page.getByPlaceholder("[email protected]").fill(validEmail ?? ""); | ||
await page.getByLabel("Password").fill(e2ePassword); | ||
await page.getByRole("button", { name: "ログイン" }).click(); | ||
|
||
const logoutButton = page.getByRole("link", { name: "ログアウト" }); | ||
await expect(logoutButton).toBeVisible(); | ||
|
||
/** 現在リロードしないと画面が更新されずログイン、サインインが表示されない **/ | ||
await logoutButton.click(); | ||
await page.waitForTimeout(1500); | ||
|
||
await page.reload(); | ||
|
||
const loginButton = page.getByRole("link", { name: "ログイン" }); | ||
const signInButton = page.getByRole("link", { name: "ユーザー登録" }); | ||
|
||
await expect(loginButton).toBeVisible(); | ||
await expect(signInButton).toBeVisible(); | ||
}); | ||
|
||
test("Should Fail Login with Invalid Email and Password", async ({ | ||
page, | ||
}) => { | ||
await page.goto("http://localhost:3000/"); | ||
await page.getByRole("link", { name: "ログイン" }).click(); | ||
|
||
await page.getByPlaceholder("[email protected]").fill("[email protected]"); | ||
await page.getByLabel("Password").fill("invalidpassword"); | ||
await page.getByRole("button", { name: "ログイン" }).click(); | ||
|
||
const loginButton = page.getByRole("button", { name: "ログイン" }); | ||
await expect(loginButton).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
fb0edc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
agent – ./
agent-fjord-jp.vercel.app
agent-lokkas-projects.vercel.app
agent.fjord.jp
agent-git-main-lokkas-projects.vercel.app