-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7cf434
commit a8a14ac
Showing
26 changed files
with
310 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#language: fr | ||
Fonctionnalité: Posez une question | ||
|
||
Scénario: Poser une question sur le forum | ||
Soit une base de données nourrie au grain | ||
* je navigue sur la page | ||
* je me connecte en tant que "[email protected]" | ||
* je clique sur "Échanges" | ||
* je vois dans le titre "Exchange :: Serkels" | ||
|
||
Quand je clique sur "Mes cercles" | ||
Alors je vois "P'tit pause café avec l'ami Jackie" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,3 @@ | ||
// | ||
|
||
import { procedure, router } from "@1.modules/trpc"; | ||
import { z } from "zod"; | ||
|
||
// | ||
|
||
export default router({ | ||
verify: procedure | ||
.input(z.object({ email: z.string() })) | ||
.mutation(async ({ ctx: { prisma }, input: { email } }) => { | ||
return prisma.user.findUnique({ | ||
select: { id: true }, | ||
where: { email }, | ||
}); | ||
}), | ||
}); | ||
export { default as verify_api_router } from "./verify"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
|
||
import { procedure, router } from "@1.modules/trpc"; | ||
import { z } from "zod"; | ||
|
||
// | ||
|
||
export default router({ | ||
verify: procedure | ||
.input(z.object({ email: z.string() })) | ||
.mutation(async ({ ctx: { prisma }, input: { email } }) => { | ||
return prisma.user.findUnique({ | ||
select: { id: true }, | ||
where: { email }, | ||
}); | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
packages/@1/modules/bookmark/api/src/check/check.e2e.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
|
||
import { | ||
create_douglas_student, | ||
create_film_category, | ||
create_the_creator_exchange, | ||
} from "@1.infra/database/seeding"; | ||
import prisma, { empty_database, migrate } from "@1.infra/database/testing"; | ||
import { createCallerFactory } from "@1.modules/trpc"; | ||
import { douglas_student_session } from "@1.modules/trpc/testing"; | ||
import { afterEach, beforeAll, beforeEach, expect, test } from "bun:test"; | ||
import api_router from "./check"; | ||
|
||
// | ||
|
||
beforeAll(empty_database); | ||
beforeAll(migrate); | ||
|
||
// | ||
|
||
test("return false when an exchange is not bookmarked", async () => { | ||
const caller = createCallerFactory(api_router); | ||
const trpc = caller({ | ||
auth: () => douglas_student_session, | ||
prisma, | ||
} as any); | ||
const data = await trpc.check({ | ||
target_id: "the_creator_exchange_id", | ||
type: "exchange", | ||
}); | ||
expect(data).toBeFalse(); | ||
}); | ||
|
||
test("return true when an exchange is bookmarked", async () => { | ||
const caller = createCallerFactory(api_router); | ||
const trpc = caller({ | ||
auth: () => douglas_student_session, | ||
prisma, | ||
} as any); | ||
|
||
await prisma.bookmark.create({ | ||
data: { | ||
owner_id: "douglas_profile_id", | ||
exchange_id: "the_creator_exchange_id", | ||
}, | ||
}); | ||
|
||
const data = await trpc.check({ | ||
target_id: "the_creator_exchange_id", | ||
type: "exchange", | ||
}); | ||
expect(data).toBeTrue(); | ||
}); | ||
|
||
// | ||
|
||
beforeEach(async function seed() { | ||
await create_douglas_student(prisma); | ||
await create_film_category(prisma); | ||
await create_the_creator_exchange(prisma, "douglas_student_id"); | ||
}); | ||
|
||
afterEach(async function empty_delete_entries() { | ||
await prisma.category.deleteMany(); | ||
await prisma.user.deleteMany(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
|
||
import { Bookmark_Category } from "@1.modules/bookmark.domain"; | ||
import { router } from "@1.modules/trpc"; | ||
import { match } from "ts-pattern"; | ||
import { z } from "zod"; | ||
import { bookmark_type_procedure } from "../procedure"; | ||
|
||
// | ||
|
||
export default router({ | ||
check: bookmark_type_procedure | ||
.input(z.object({ target_id: z.string() })) | ||
.query(async ({ ctx: { prisma, session }, input: { target_id, type } }) => { | ||
const { id: owner_id } = session.profile; | ||
|
||
const where = match(type) | ||
.with(Bookmark_Category.Enum.exchange, () => ({ | ||
exchange_id: target_id, | ||
})) | ||
.with(Bookmark_Category.Enum.opportunity, () => ({ | ||
opportunity_id: target_id, | ||
})) | ||
.exhaustive(); | ||
|
||
const count = await prisma.bookmark.count({ | ||
where: { owner_id, ...where }, | ||
}); | ||
|
||
return count === 1; | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// | ||
|
||
export { default as check_api_router } from "./check"; |
Oops, something went wrong.