Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 11 additions & 1 deletion test/features/merchant.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
Feature: Manage Merchant

Scenario: Add Merchant geolocation
Given tokenFromRegister exists
When I prepare a POST request to "/admin/merchants"
When I set a bearer authentication header with tokenFromRegister value
And I use postMerchantSchema payload
And send
Then the response should be 201
And the response body matches the merchantId schema
And save the "body.merchantId" value as addedMerchantId

Scenario: Get Merchants with default Parameter
Given tokenFromRegister exists
When I prepare a GET request to "/admin/merchants?limit=5&offset=0"
Expand Down Expand Up @@ -47,7 +57,7 @@ Feature: Manage Merchant

Scenario: Get Small Restaurant Merchants
Given tokenFromRegister exists
When I prepare a GET request to "/admin/merchants?createdAt=asc&limit=5&offset=0"
When I prepare a GET request to "/admin/merchants?createdAt=desc&limit=5&offset=0"
When I set a bearer authentication header with tokenFromRegister value
And send
Then the response should be 200
Expand Down
10 changes: 10 additions & 0 deletions test/features/merchant_item.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
Feature: Manage Merchant Items

Scenario: Add Merchant geolocation
Given tokenFromRegister exists
When I prepare a POST request to "/admin/merchants/addedMerchantId/items"
When I set a bearer authentication header with tokenFromRegister value
And I use postItemSchema payload
And send
Then the response should be 201
And the response body matches the merchantId schema
And save the "body.merchantId" value as addedMerchantLocation

Scenario: Get Merchant Items
Given tokenFromRegister exists
When I prepare a GET request to "/admin/merchants/id123abc/items"
Expand Down
10 changes: 8 additions & 2 deletions test/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import type z from "zod";
import { AuthSchema } from "./auth.schema";
import { UserSchema } from "./user.schema";
import { MerchantSchema } from "./merchant.schema";
import { ItemSchema } from "./item.schema";
import { MerchantIdSchema } from "./merchant/merchantId.schema";
import { MerchantSchema, PostMerchantSchema } from "./merchant/merchant.schema";
import { ItemIdSchema } from "./merchant/itemId.schema";
import { ItemSchema, PostItemSchema } from "./merchant/item.schema";

// biome-ignore lint/suspicious/noExplicitAny: we can't determine what ObjectSchema output will be
type ObjectSchema = z.ZodType<Record<string, unknown>, any, any>;
type SchemaRegistry = Record<string, ObjectSchema>;

export const schemaRegistry: SchemaRegistry = {
itemId: ItemIdSchema,
postItemSchema: PostItemSchema,
item: ItemSchema,
merchantId: MerchantIdSchema,
postMerchantSchema: PostMerchantSchema,
merchant: MerchantSchema,
user: UserSchema,
auth: AuthSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,17 @@ export const ItemSchema = z.object({
total: z.int(),
}),
});

export const PostItemSchema = z.object({
itemId: z.string(),
name: z.string(),
productCategory: z.enum([
"Beverage",
"Food",
"Snack",
"Condiments",
"Additions"
]),
price: z.int().min(1),
imageUrl: z.url(),
})
5 changes: 5 additions & 0 deletions test/schemas/merchant/itemId.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import z from "zod"

export const ItemIdSchema = z.object({
itemId: z.string()
})
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,21 @@ export const MerchantSchema = z.object({
total: z.int(),
}),
});

export const PostMerchantSchema = z.object({
merchantId: z.string(),
name: z.string(),
merchantCategory: z.enum([
"SmallRestaurant",
"MediumRestaurant",
"LargeRestaurant",
"MerchandiseRestaurant",
"BoothKiosk",
"ConvenienceStore"
]),
imageUrl: z.url(),
location: z.object({
lat: z.float32(),
long: z.float32(),
}),
})
5 changes: 5 additions & 0 deletions test/schemas/merchant/merchantId.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import z from "zod";

export const MerchantIdSchema = z.object({
merchantId: z.string()
})