Skip to content

Commit 2d45d96

Browse files
authored
Merge pull request #213 from codeableorg/actions
feat: update test job dependencies and correct test command in GitHub Actions workflow
2 parents 081e8e4 + 609cff9 commit 2d45d96

22 files changed

+185
-552
lines changed

.github/workflows/tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: testing
22
on:
33
push:
44
branches: [main]
5+
pull_request:
6+
branches: [main]
57

68
jobs:
79
lint:

prisma/initial_data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CategorySlug } from "generated/prisma/client.js";
1+
import type { CategorySlug } from "@/../generated/prisma/client";
22

33
export const categories = [
44
{

prisma/seed.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { categories, products } from "./initial_data";
2-
import { PrismaClient } from "../generated/prisma/client.js";
2+
3+
import { PrismaClient } from "@/../generated/prisma/client";
34

45
const prisma = new PrismaClient();
56

src/db/prisma.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PrismaClient } from "generated/prisma/client.js";
1+
import { PrismaClient } from "@/../generated/prisma/client";
22

33
// Global variable to store the Prisma client instance
44
declare global {

src/e2e/example.spec.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/lib/utils.tests.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ import type { Order, OrderDetails, OrderItem } from "@/models/order.model";
55
import type { Product } from "@/models/product.model";
66
import type { User } from "@/models/user.model";
77

8+
import type {
9+
OrderItem as PrismaOrderItem,
10+
Order as PrismaOrder,
11+
Product as PrismaProduct,
12+
} from "@/../generated/prisma/client";
813
import type { Session } from "react-router";
914

15+
import { Decimal } from "@/../generated/prisma/internal/prismaNamespace";
16+
1017
type TestRequestConfig = {
1118
url?: string;
1219
headers?: HeadersInit;
@@ -61,6 +68,23 @@ export const createTestProduct = (overrides?: Partial<Product>): Product => ({
6168
...overrides,
6269
});
6370

71+
export const createTestDBProduct = (
72+
overrides?: Partial<PrismaProduct>
73+
): PrismaProduct => ({
74+
id: 1,
75+
title: "Test Product",
76+
imgSrc: "/test-image.jpg",
77+
alt: "Test alt text",
78+
price: new Decimal(100),
79+
description: "Test description",
80+
categoryId: 1,
81+
isOnSale: false,
82+
features: ["Feature 1", "Feature 2"],
83+
createdAt: new Date(),
84+
updatedAt: new Date(),
85+
...overrides,
86+
});
87+
6488
export const createTestCategory = (
6589
overrides?: Partial<Category>
6690
): Category => ({
@@ -107,6 +131,22 @@ export const createTestOrderItem = (
107131
...overrides,
108132
} satisfies OrderItem);
109133

134+
export const createTestDBOrderItem = (
135+
overrides: Partial<PrismaOrderItem> = {}
136+
): PrismaOrderItem =>
137+
({
138+
id: 1,
139+
orderId: 1,
140+
productId: 1,
141+
quantity: 1,
142+
title: "Test Product",
143+
price: new Decimal(100),
144+
imgSrc: "test-image.jpg",
145+
createdAt: new Date(),
146+
updatedAt: new Date(),
147+
...overrides,
148+
} satisfies PrismaOrderItem);
149+
110150
export const createTestOrder = (overrides: Partial<Order> = {}): Order => {
111151
const details = overrides.details ?? createTestOrderDetails();
112152
return {
@@ -121,3 +161,26 @@ export const createTestOrder = (overrides: Partial<Order> = {}): Order => {
121161
...overrides,
122162
} satisfies Order;
123163
};
164+
165+
export const createTestDBOrder = (
166+
overrides: Partial<PrismaOrder> = {}
167+
): PrismaOrder => {
168+
return {
169+
id: 1,
170+
userId: 1,
171+
172+
totalAmount: new Decimal(100),
173+
firstName: "Test",
174+
lastName: "User",
175+
company: null,
176+
address: "Test Address",
177+
city: "Test City",
178+
country: "Test Country",
179+
region: "Test Region",
180+
zip: "12345",
181+
phone: "123456789",
182+
createdAt: new Date(),
183+
updatedAt: new Date(),
184+
...overrides,
185+
} satisfies PrismaOrder;
186+
};

src/models/cart.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { type Product } from "./product.model";
33
import type {
44
Cart as PrismaCart,
55
CartItem as PrismaCartItem,
6-
} from "generated/prisma/client";
6+
} from "@/../generated/prisma/client";
77

88
export type CartItem = PrismaCartItem & {
99
product: Pick<

src/models/category.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Category as PrismaCategory } from "generated/prisma/client";
1+
import type { Category as PrismaCategory } from "@/../generated/prisma/client";
22

33
export const VALID_SLUGS = ["polos", "stickers", "tazas"] as const;
44

src/models/order.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type {
22
Order as PrismaOrder,
33
OrderItem as PrismaOrderItem,
4-
} from "generated/prisma/client";
4+
} from "@/../generated/prisma/client";
55

66
export type OrderDetails = Pick<
77
PrismaOrder,

src/models/product.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Product as PrismaProduct } from "generated/prisma/client";
1+
import type { Product as PrismaProduct } from "@/../generated/prisma/client";
22

33
export type Product = Omit<PrismaProduct, "price"> & {
44
price: number;

0 commit comments

Comments
 (0)