55import { Kysely } from "kysely" ;
66import { beforeAll , describe , expect , it } from "vitest" ;
77import { Database } from "../core/adapters/dbApi/kysely/kysely.database" ;
8+ import { createPgDialect } from "../core/adapters/dbApi/kysely/kysely.dialect" ;
89import { stripNullOrUndefinedValues } from "../core/adapters/dbApi/kysely/kysely.utils" ;
910import type { DbUser } from "../core/ports/DbApiV2" ;
1011import type { InstanceFormData , Source } from "../core/usecases/readWriteSillData" ;
@@ -13,7 +14,8 @@ import {
1314 createInstanceFormData ,
1415 createSoftwareFormData ,
1516 expectToEqual ,
16- expectToMatchObject
17+ expectToMatchObject ,
18+ testPgUrl
1719} from "../tools/test.helpers" ;
1820import { ApiCaller , createTestCaller , defaultUser } from "./createTestCaller" ;
1921
@@ -96,7 +98,7 @@ describe("RPC e2e tests", () => {
9698 let user : DbUser ;
9799
98100 beforeAll ( async ( ) => {
99- ( { apiCaller , kyselyDb } = await createTestCaller ( ) ) ;
101+ kyselyDb = new Kysely < Database > ( { dialect : createPgDialect ( testPgUrl ) } ) ;
100102 await kyselyDb . deleteFrom ( "software_referents" ) . execute ( ) ;
101103 await kyselyDb . deleteFrom ( "software_users" ) . execute ( ) ;
102104 await kyselyDb . deleteFrom ( "instances" ) . execute ( ) ;
@@ -106,11 +108,13 @@ describe("RPC e2e tests", () => {
106108 await kyselyDb . deleteFrom ( "sources" ) . execute ( ) ;
107109
108110 await kyselyDb . insertInto ( "sources" ) . values ( mainSource ) . executeTakeFirst ( ) ;
111+
112+ ( { apiCaller, kyselyDb } = await createTestCaller ( { db : kyselyDb , currentUser : defaultUser } ) ) ;
109113 } ) ;
110114
111115 it ( "gets the list of users, which is initially empty" , async ( ) => {
112116 const { users } = await apiCaller . getUsers ( ) ;
113- expect ( users ) . toHaveLength ( 0 ) ;
117+ expect ( users ) . toHaveLength ( 1 ) ;
114118 } ) ;
115119
116120 it ( "adds a new software" , async ( ) => {
@@ -128,7 +132,7 @@ describe("RPC e2e tests", () => {
128132 expectToMatchObject ( user , {
129133 id : expect . any ( Number ) ,
130134 email : defaultUser . email ,
131- organization : null
135+ organization : defaultUser . organization
132136 } ) ;
133137
134138 const softwareRows = await getSoftwareRows ( ) ;
@@ -174,7 +178,7 @@ describe("RPC e2e tests", () => {
174178 expect ( users ) . toHaveLength ( 1 ) ;
175179 expectToMatchObject ( users [ 0 ] , {
176180 "email" : defaultUser . email ,
177- "organization" : null
181+ "organization" : defaultUser . organization
178182 } ) ;
179183 } ) ;
180184
0 commit comments