forked from aeharding/voyager
-
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.
- Loading branch information
Showing
26 changed files
with
1,085 additions
and
1,120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
** @aeharding | ||
/e2e/ @aashu16 @aeharding |
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,27 @@ | ||
name: Run e2e tests | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
playwright: | ||
name: Run Playwright tests | ||
runs-on: ubuntu-latest | ||
container: | ||
image: mcr.microsoft.com/playwright:v1.43.0-jammy | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: pnpm | ||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
- name: Build project | ||
run: pnpm build | ||
- name: Run tests | ||
run: env HOME=/root pnpm test:e2e |
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,30 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
import { posts } from "./testdata/posts"; | ||
|
||
test("load community posts", async ({ page }) => { | ||
await page.route("*/**/api/v3/post/list**", async (route) => { | ||
await route.fulfill({ json: { posts } }); | ||
}); | ||
|
||
await page.goto("/"); | ||
await page.waitForURL("/posts/lemmy.world/all"); | ||
|
||
await expect(page).toHaveTitle("Voyager for Lemmy"); | ||
|
||
await expect(page.getByText(posts[0].post.name)).toBeVisible(); | ||
}); | ||
|
||
test("navigate to post on click", async ({ page }) => { | ||
await page.route("*/**/api/v3/post/list**", async (route) => { | ||
await route.fulfill({ json: { posts } }); | ||
}); | ||
|
||
await page.goto("/"); | ||
|
||
await page.getByText(posts[0].post.name).click(); | ||
|
||
await expect(page).toHaveURL( | ||
"/posts/lemmy.world/c/community_1@test.lemmy/comments/999", | ||
); | ||
}); |
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,75 @@ | ||
import type { PostView } from "lemmy-js-client"; | ||
|
||
export const posts: PostView[] = [ | ||
{ | ||
post: { | ||
id: 999, | ||
name: "Post 999 title", | ||
body: "Post 999 body.", | ||
creator_id: 100, | ||
community_id: 111, | ||
removed: false, | ||
locked: false, | ||
published: "2024-04-01T00:00:00.000000Z", | ||
updated: "2024-04-01T00:00:00.000000Z", | ||
deleted: false, | ||
nsfw: false, | ||
thumbnail_url: "", | ||
ap_id: "", | ||
local: false, | ||
language_id: 0, | ||
featured_community: false, | ||
featured_local: false, | ||
}, | ||
creator: { | ||
id: 100, | ||
name: "user_1", | ||
display_name: "lemmy_user", | ||
banned: false, | ||
published: "2024-04-01T00:00:00.000000Z", | ||
actor_id: "https://test.lemmy/u/lemmy_user", | ||
local: false, | ||
deleted: false, | ||
bot_account: false, | ||
instance_id: 1, | ||
}, | ||
community: { | ||
id: 111, | ||
name: "community_1", | ||
title: "Community", | ||
description: "Description 1", | ||
removed: false, | ||
published: "2024-04-01T00:00:00.000000Z", | ||
updated: "2024-04-01T00:00:00.000000Z", | ||
deleted: false, | ||
nsfw: false, | ||
actor_id: "https://test.lemmy/c/community_1", | ||
local: false, | ||
icon: "", | ||
banner: "", | ||
hidden: false, | ||
posting_restricted_to_mods: false, | ||
instance_id: 3, | ||
visibility: "Public", | ||
}, | ||
creator_banned_from_community: false, | ||
creator_is_moderator: false, | ||
creator_is_admin: false, | ||
counts: { | ||
post_id: 111, | ||
comments: 20, | ||
score: 91, | ||
upvotes: 100, | ||
downvotes: 9, | ||
published: "2024-04-01T00:00:00.000000Z", | ||
newest_comment_time: "2024-04-01T00:00:00.000000Z", | ||
}, | ||
subscribed: "NotSubscribed", | ||
saved: false, | ||
read: false, | ||
creator_blocked: false, | ||
unread_comments: 20, | ||
banned_from_community: false, | ||
hidden: false, | ||
}, | ||
]; |
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,46 @@ | ||
import { defineConfig, devices } from "@playwright/test"; | ||
|
||
const serverURL = "http://localhost:" + (process.env.CI ? "4173" : "5173"); | ||
|
||
export default defineConfig({ | ||
testDir: "./e2e", | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
reporter: "list", | ||
use: { | ||
baseURL: serverURL, | ||
|
||
trace: "on-first-retry", | ||
}, | ||
|
||
projects: [ | ||
{ | ||
name: "chromium", | ||
use: { ...devices["Desktop Chrome"] }, | ||
}, | ||
{ | ||
name: "firefox", | ||
use: { ...devices["Desktop Firefox"] }, | ||
}, | ||
{ | ||
name: "webkit", | ||
use: { ...devices["Desktop Safari"] }, | ||
}, | ||
{ | ||
name: "Mobile Chrome", | ||
use: { ...devices["Pixel 7"] }, | ||
}, | ||
{ | ||
name: "Mobile Safari", | ||
use: { ...devices["iPhone 14"] }, | ||
}, | ||
], | ||
|
||
webServer: { | ||
command: process.env.CI ? "pnpm preview" : "pnpm dev", | ||
url: serverURL, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}); |
Oops, something went wrong.