Skip to content

Commit b8d08e4

Browse files
committed
Removed tests, cleaned up dependencies, moved tests to coresponding package (what code they are testing)
1 parent 7fd9dc7 commit b8d08e4

21 files changed

Lines changed: 697 additions & 1634 deletions

tests/jest/contactApi.test.tsx renamed to apps/contact/app/tests/contactApi.test.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/**
2-
* @jest-environment jsdom
3-
*/
4-
51
const mockNotion = jest.fn();
62
jest.mock("@notionhq/client", () => {
73
const actual = jest.requireActual("@notionhq/client");
@@ -17,7 +13,7 @@ jest.mock("@notionhq/client", () => {
1713
};
1814
});
1915

20-
jest.mock("../../apps/contact/app/(helpers)/slack", () => {
16+
jest.mock("../(helpers)/slack", () => {
2117
return {
2218
notifyContactCreated: jest.fn(),
2319
};
@@ -26,8 +22,8 @@ jest.mock("../../apps/contact/app/(helpers)/slack", () => {
2622
process.env.NOTION_DATABASE_ID = "mocked-notion-database-id";
2723

2824
import { NextRequest } from "next/server";
29-
import { POST } from "../../apps/contact/app/api/contact/route";
30-
import { notifyContactCreated } from "../../apps/contact/app/(helpers)/slack";
25+
import { POST } from "../api/contact/route";
26+
import { notifyContactCreated } from "../(helpers)/slack";
3127

3228
const mockSlack = notifyContactCreated as jest.Mock;
3329

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
notifyContactCreated,
3-
createPayload,
4-
} from "../../apps/contact/app/(helpers)/slack";
1+
import { notifyContactCreated, createPayload } from "../(helpers)/slack";
52

63
const mockData = {
74
name: "Test name",

apps/contact/package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"start": "next start",
99
"lint": "next lint",
1010
"emails": "email dev --dir app/\\(email-templates\\)",
11-
"playwright": "npx playwright test",
12-
"test": "npx jest && npx playwright test"
11+
"test": "npx jest"
1312
},
1413
"dependencies": {
1514
"@aws-sdk/client-sesv2": "^3.888.0",
@@ -24,18 +23,13 @@
2423
"zod": "^4.0.17"
2524
},
2625
"devDependencies": {
27-
"@playwright/test": "^1.55.0",
2826
"@react-email/preview-server": "4.2.11",
2927
"@types/jest": "^30.0.0",
3028
"@types/node": "^24",
31-
"@types/node-fetch": "^2.6.13",
3229
"@types/nodemailer": "^7.0.1",
3330
"@types/react": "^19",
3431
"@types/react-dom": "^19",
35-
"@whatwg-node/fetch": "^0.10.10",
3632
"jest": "^30.1.1",
37-
"jest-environment-jsdom": "^30.1.1",
38-
"node-fetch": "^3.3.2",
3933
"react-email": "4.2.11",
4034
"ts-jest": "^29.4.1",
4135
"typescript": "^5",

apps/contact/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
},
2525
"types": ["jest", "node"]
2626
},
27-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "../../tests/jest.setup.ts"],
27+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "jest.setup.ts"],
2828
"exclude": ["node_modules"]
2929
}

bun.lock

Lines changed: 651 additions & 272 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,11 @@
66
"dev": "turbo dev",
77
"lint": "turbo lint",
88
"format": "prettier --write \"**/*.{ts,tsx,astro}\"",
9-
"test:jest": "cd tests && npx jest",
10-
"test:playwright": "cd tests && npx playwright test",
11-
"test": "npm run test:jest && npm run test:playwright"
9+
"test": "cd tests && npx playwright test"
1210
},
1311
"devDependencies": {
1412
"@playwright/test": "^1.55.0",
15-
"@types/jest": "^30.0.0",
16-
"@types/node-fetch": "^2.6.13",
17-
"jest-environment-jsdom": "^30.1.1",
18-
"jest": "^30.1.1",
19-
"ts-jest": "^29.4.1",
20-
"turbo": "^2.5.6",
21-
"undici": "^6.21.3",
22-
"web-streams-polyfill": "^4.2.0"
13+
"turbo": "^2.5.6"
2314
},
2415
"engines": {
2516
"bun": ">=1.2.21"

tests/playwright/bookACallSection.spec.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
// const baseUrl = "http://localhost:4321";
4+
const baseUrl = "https://www.crocoder.dev";
5+
const contactUrl = "contact";
6+
const successUrl = "success";
7+
const routeUrl = "https://api.crocoder.dev/api/contact";
8+
9+
test.describe("Submiting a form", () => {
10+
test.beforeEach(async ({ page }) => {
11+
await page.goto(`${baseUrl}`);
12+
});
13+
14+
test("sucessfully", async ({ page }) => {
15+
await page.route(`${routeUrl}**`, async (route) => {
16+
await route.fulfill({
17+
status: 200,
18+
contentType: "application/json",
19+
body: JSON.stringify({
20+
success: true,
21+
message:
22+
"Page successfully created in Notion and message sent to Slack.",
23+
}),
24+
});
25+
});
26+
await page.getByRole("link", { name: "Contact us", exact: true }).click();
27+
28+
await expect(page).toHaveURL(`${baseUrl}/${contactUrl}`);
29+
await page.fill('input[name="form-full-name"]', "Test name");
30+
await page.fill('input[name="form-email"]', "test@test.com");
31+
await page.fill('textarea[name="form-message"]', "This is a test input");
32+
await page.check('input[name="form-consent"]');
33+
await page.click("#form-submit-button");
34+
35+
await expect(page).toHaveURL(`${baseUrl}/${contactUrl}/${successUrl}`);
36+
});
37+
});

0 commit comments

Comments
 (0)