Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/e2e tests #1061

Merged
merged 45 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
909133c
chore: added all selected columns to the groupBy function
JohnAllenTech Oct 2, 2024
b685436
Merge branch 'develop' into fix/broken-article-query
JohnAllenTech Oct 3, 2024
389acab
chore: updated drizzle orm dep and tested it works
JohnAllenTech Oct 3, 2024
6649e50
fix: e2e tests back working
JohnAllenTech Oct 3, 2024
3066351
fix: removing flaky part of e2e test
JohnAllenTech Oct 3, 2024
94f8c72
chore: removing more flakiness
JohnAllenTech Oct 4, 2024
b2d088d
chore: working but still flaky
JohnAllenTech Oct 4, 2024
abdd4d1
chore: attempting to reuse single login across multiple tests
JohnAllenTech Oct 8, 2024
489c459
chore: still not working in headless mode
JohnAllenTech Oct 11, 2024
60ad7a8
Merge branch 'develop' into fix/e2e-tests
JohnAllenTech Oct 11, 2024
a0f3387
chore: reverted merge and added autheticated browser state to gitignore
JohnAllenTech Oct 11, 2024
5cf2438
chore: removing browser.json to safeguard against people uploading th…
JohnAllenTech Oct 11, 2024
9db35ca
chore: removed playwright workflow
JohnAllenTech Oct 11, 2024
28098da
Merge branch 'develop' into fix/e2e-tests
JohnAllenTech Oct 11, 2024
91ea958
chore: classic hackerman stuff here
JohnAllenTech Oct 12, 2024
97a9545
Merge branch 'develop' into fix/e2e-tests
JohnAllenTech Oct 13, 2024
8415a67
chore: removing some unused code and making the authenticated browser…
JohnAllenTech Oct 13, 2024
ec6172c
chore: some logging for future humans
JohnAllenTech Oct 13, 2024
144a5bf
chore: nearly there. testing workflow
JohnAllenTech Oct 13, 2024
ed447a3
chore: updated e2e workflow to input new seed script
JohnAllenTech Oct 13, 2024
9312347
chore: now logging error when browser.json fails
JohnAllenTech Oct 13, 2024
7ac5ebc
chore: more logging around file creation errors
JohnAllenTech Oct 13, 2024
732b6b0
chore: removed logging
JohnAllenTech Oct 13, 2024
82ba182
Merge branch 'develop' into fix/e2e-tests
JohnAllenTech Oct 13, 2024
86c3f68
chore: updated some naming
JohnAllenTech Oct 13, 2024
6676d88
chore: now creating folder and file in workflow
JohnAllenTech Oct 13, 2024
f42dbf1
Merge branch 'develop' into fix/e2e-tests
NiallJoeMaher Oct 14, 2024
78a03ba
chore: add more logging to file creation process
JohnAllenTech Oct 14, 2024
3c8b921
chore: async file and folder creation added
JohnAllenTech Oct 14, 2024
e7f8d4f
chore: back to sync and more logging in folder/file creation
JohnAllenTech Oct 14, 2024
d62f95c
chore: removed throw errors for testing
JohnAllenTech Oct 14, 2024
bf7d103
chore: added hacky wait step
JohnAllenTech Oct 14, 2024
acf2e05
chore: new way of creating the files/folders added
JohnAllenTech Oct 14, 2024
e6bca18
chore: creating files successfully but module import failing
JohnAllenTech Oct 14, 2024
a75a83f
chore: now creating files in workflow step
JohnAllenTech Oct 14, 2024
1da9338
chore: moved file/folder creation into seed step
JohnAllenTech Oct 14, 2024
6154e0d
chore: removed git ignore as browser state is now fully mocked
JohnAllenTech Oct 14, 2024
e9fbb34
chore: now not depending on process env var
JohnAllenTech Oct 14, 2024
d5468c8
chore: made authenticated homepage test more robust
JohnAllenTech Oct 14, 2024
fbed02d
chore: replaced order of tests to see if cookies are cleared at a tes…
JohnAllenTech Oct 14, 2024
5f89326
chore: now seeding e2e user in normal seed script
JohnAllenTech Oct 14, 2024
fc64a92
chore: cleanup before PR review
JohnAllenTech Oct 14, 2024
0ae6105
Merge branch 'develop' into fix/e2e-tests
JohnAllenTech Oct 14, 2024
b2f994f
chore: cleaning up old script
JohnAllenTech Oct 14, 2024
cb662cc
chore: prettier fix
JohnAllenTech Oct 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
1 change: 1 addition & 0 deletions e2e/articles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ test.describe("Articles", () => {
(articles) => articles.length,
);

await page.getByText("Code Of Conduct").scrollIntoViewIfNeeded();
await page.evaluate(() => {
window.scrollTo(0, document.body.scrollHeight);
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/home.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test.describe("Confirm homepage content", () => {
await page.goto("http://localhost:3000/");

const elementVisible = await page
.locator('text="Recommended topics"')
.locator('text="Popular topics"')
.isVisible();

if (isMobile) {
Expand Down
16 changes: 4 additions & 12 deletions e2e/login.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import { test, expect } from "playwright/test";

test.afterEach(async ({ page }) => {
// Sign out the user after all tests are done
await page.goto("http://localhost:3000/api/auth/signout");
await page.getByRole("button", { name: "Sign out" }).click();
await expect(page.locator("#submitButton")).toBeHidden();
});

test.beforeEach(async ({ page }) => {
await page.goto("http://localhost:3000/get-started");
});

test.describe("Login Page", () => {
test("should display the login button", async ({ page }) => {
await page.goto("http://localhost:3000/get-started");
const loginButton = page.getByRole("button", {
name: "Login with GitHub",
});
Expand All @@ -22,8 +12,10 @@ test.describe("Login Page", () => {
test("should navigate to GitHub login page when clicking the login button", async ({
page,
}) => {
await page.goto("http://localhost:3000/get-started");

const button = page.getByRole("button", {
name: "Login with GitHub",
name: "Continue with GitHub",
});

await button.click();
Expand Down
48 changes: 29 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"atropos": "^2.0.2",
"clsx": "^2.1.1",
"copy-to-clipboard": "^3.3.3",
"drizzle-orm": "^0.31.2",
"drizzle-orm": "^0.33.0",
"fathom-client": "^3.7.2",
"framer-motion": "^10.18.0",
"highlight.js": "^11.10.0",
Expand Down Expand Up @@ -107,7 +107,7 @@
},
"devDependencies": {
"@axe-core/react": "^4.9.0",
"@playwright/test": "^1.43.1",
"@playwright/test": "^1.47.2",
"@svgr/webpack": "^8.1.0",
"@tailwindcss/typography": "^0.5.13",
"@types/chance": "^1.1.6",
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default defineConfig({
/* Test against mobile viewports. */
{
name: "Mobile Chrome",
use: { ...devices["Pixel 5"] },
use: { ...devices["iPhone 15"] },
},
// {
// name: 'Mobile Safari',
Expand Down
12 changes: 11 additions & 1 deletion server/api/router/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,17 @@ export const postRouter = createTRPCRouter({
cursor ? paginationMapping[sort].cursor : undefined,
),
)
.groupBy(post.id, bookmarked.id, user.id)
.groupBy(
post.id,
post.slug,
post.title,
post.excerpt,
post.published,
post.readTimeMins,
post.likes,
bookmarked.id,
user.id,
)
.limit(limit + 1)
.orderBy(paginationMapping[sort].orderBy);

Expand Down
Loading