Skip to content

Commit 5a8f459

Browse files
committed
chore: implementing the bots suggestions
1 parent 250dff5 commit 5a8f459

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

e2e/my-posts.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import test, { expect } from "@playwright/test";
22
import { articleExcerpt, loggedInAsUserOne } from "./utils";
33

44
test.describe("Unauthenticated my-posts Page", () => {
5-
test("Unauthenticed users should be redirected to get-started page if they access my-posts directly", async ({
5+
test("Unauthenticated users should be redirected to get-started page if they access my-posts directly", async ({
66
page,
77
}) => {
88
await page.goto("http://localhost:3000/my-posts");

e2e/setup.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,33 @@ import { articleContent, articleExcerpt } from "./utils";
77
dotenv.config(); // Load .env file contents into process.env
88

99
export const setup = async () => {
10+
// Dynamically import nanoid
11+
const { nanoid } = await import("nanoid");
12+
1013
if (
1114
!process.env.DATABASE_URL ||
1215
!process.env.E2E_USER_ONE_ID ||
1316
!process.env.E2E_USER_TWO_ID
1417
) {
1518
throw new Error("Missing env variables for DB clean up script");
1619
}
20+
1721
const db = drizzle(postgres(process.env.DATABASE_URL as string));
1822

1923
const addE2EArticleAndComment = async (
2024
authorId: string,
2125
commenterId: string,
2226
) => {
23-
const publishedPostId = "1nFnMmN1";
24-
const scheduledPostId = "1nFnMmN2";
25-
const draftPostId = "1nFnMmN3";
27+
const publishedPostId = nanoid(8);
28+
const scheduledPostId = nanoid(8);
29+
const draftPostId = nanoid(8);
2630
const now = new Date().toISOString();
2731

2832
const oneYearFromToday = new Date(now);
2933
oneYearFromToday.setFullYear(oneYearFromToday.getFullYear() + 1);
3034

3135
await Promise.all([
32-
await db
36+
db
3337
.insert(post)
3438
.values({
3539
id: publishedPostId,
@@ -46,10 +50,10 @@ export const setup = async () => {
4650
.onConflictDoNothing()
4751
.returning(),
4852

49-
await db
53+
db
5054
.insert(post)
5155
.values({
52-
id: scheduledPostId,
56+
id: draftPostId,
5357
published: null,
5458
excerpt: articleExcerpt,
5559
updatedAt: now,
@@ -63,10 +67,10 @@ export const setup = async () => {
6367
.onConflictDoNothing()
6468
.returning(),
6569

66-
await db
70+
db
6771
.insert(post)
6872
.values({
69-
id: draftPostId,
73+
id: scheduledPostId,
7074
published: oneYearFromToday.toISOString(),
7175
excerpt: articleExcerpt,
7276
updatedAt: now,

0 commit comments

Comments
 (0)