Skip to content

Commit

Permalink
adjust(CC-119): debug wip
Browse files Browse the repository at this point in the history
  • Loading branch information
luanavfg committed Mar 15, 2024
1 parent 1f1c528 commit 875c276
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { setupE2ETest } from '../../../../../../../../tests/utils/e2e-tests-init
import { AppointmentEntity } from '../../../../../../core/domains/appointment/entities/appointment/entity';
import { PostgreSqlPrismaOrmService } from '../../../../../database/infra/prisma/prisma.service';

describe('[E2E] - Delete Appointment', () => {
describe.only('[E2E] - Delete Appointment', () => {
let prisma: PostgreSqlPrismaOrmService;
let app: INestApplication;
let access_token: string;
Expand All @@ -20,6 +20,7 @@ describe('[E2E] - Delete Appointment', () => {
access_token = setup.access_token;
invalid_access_token = setup.invalid_access_token;
appointment = setup.appointment
console.log('APPPOINTOMENT', appointment)
});

async function deleteAppointmentWithoutAcessToken (appointmentId: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export class PostgresqlPrismaAppointmentMapper {

static toPrismaCreate(
raw: CreateSingleAppointmentInputDto,
): Prisma.AppointmentCreateArgs {
): Prisma.AppointmentUncheckedCreateInput {
return {
data: {
// data: {
...raw,
paymentMethod: raw.paymentMethod as unknown as PrismaPaymentMethod,
date: new Date(raw.date),
},
// },
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class PostgresqlPrismaOrmAppointmentRepository
});

const newAppointment =
await this.postgresqlPrismaOrmService['appointment'].create(toPrismaEntity);
await this.postgresqlPrismaOrmService['appointment'].create({data: {...toPrismaEntity}});

return PostgresqlPrismaAppointmentMapper.toDomain(newAppointment);
}
Expand Down Expand Up @@ -110,7 +110,7 @@ export class PostgresqlPrismaOrmAppointmentRepository
await this.postgresqlPrismaOrmService['appointment'].update(toPrismaEntity);
}

async updateAppointment(newAppointmentInfo: UpdateAppointmentInfoDto): Promise<void> {
async updateAppointment(newAppointmentInfo: UpdateAppointmentInfoInputDto): Promise<void> {
const oldAppointmentInfo = await this.findSingleAppointmentById(newAppointmentInfo.id);

if (!oldAppointmentInfo) {
Expand Down
15 changes: 11 additions & 4 deletions apps/core-rest-api/tests/factories/make-appointment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@ export class AppointmentFactory {
async makePrismaAppointment(
appointment: Partial<CreateSingleAppointmentInputDto> = {},
): Promise<AppointmentEntity> {
const newPrismaAppointment = makeAppointment(appointment);
try {
const newPrismaAppointment = makeAppointment(appointment);
console.log('newPrismaAppointment', newPrismaAppointment)

await this.postgreSqlPrismaOrmService['appointment'].create(
PostgresqlPrismaAppointmentMapper.toPrismaCreate(newPrismaAppointment),
);
const x = await this.postgreSqlPrismaOrmService['appointment'].create({
data: PostgresqlPrismaAppointmentMapper.toPrismaCreate({...newPrismaAppointment})}
)

console.log('xxxxxxx', x)
return newPrismaAppointment;
} catch (e) {
console.log( 'ERROR-----', e)
}

}
}
1 change: 1 addition & 0 deletions apps/core-rest-api/tests/utils/e2e-tests-initial-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export async function setupE2ETest() {
clinicId: clinic.id,
});

console.log('patient', patient)
// Creating an appointment to use in tests
const appointment = await appointmentFactory.makePrismaAppointment({
psychologistId: psychologist.id,
Expand Down

0 comments on commit 875c276

Please sign in to comment.