fix tests
This commit is contained in:
@@ -69,8 +69,8 @@ describe('Admin API', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(typeof res.body.data.data.token).toBe('string')
|
expect(typeof res.body.data.token).toBe('string')
|
||||||
expect(res.body.data.data.admin.id).toBe(adminId)
|
expect(res.body.data.admin.id).toBe(adminId)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -81,8 +81,8 @@ describe('Admin API', () => {
|
|||||||
.set(authHeader(adminToken))
|
.set(authHeader(adminToken))
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(res.body.data.data.id).toBe(adminId)
|
expect(res.body.data.id).toBe(adminId)
|
||||||
expect(res.body.data.data).not.toHaveProperty('passwordHash')
|
expect(res.body.data).not.toHaveProperty('passwordHash')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ describe('Admin API', () => {
|
|||||||
.set(authHeader(financeToken))
|
.set(authHeader(financeToken))
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(res.body.data.data).toEqual(
|
expect(res.body.data).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
totalCompanies: expect.any(Number),
|
totalCompanies: expect.any(Number),
|
||||||
totalRenters: expect.any(Number),
|
totalRenters: expect.any(Number),
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ describe('Notifications API', () => {
|
|||||||
.set(authHeader(ownerToken))
|
.set(authHeader(ownerToken))
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(typeof res.body.data.data.unread).toBe('number')
|
expect(typeof res.body.data.unread).toBe('number')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('lists company notifications and supports unread filtering', async () => {
|
it('lists company notifications and supports unread filtering', async () => {
|
||||||
@@ -53,9 +53,9 @@ describe('Notifications API', () => {
|
|||||||
.set(authHeader(ownerToken))
|
.set(authHeader(ownerToken))
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(Array.isArray(res.body.data.data)).toBe(true)
|
expect(Array.isArray(res.body.data)).toBe(true)
|
||||||
expect(res.body.data.data.some((item: any) => item.id === unread.id)).toBe(true)
|
expect(res.body.data.some((item: any) => item.id === unread.id)).toBe(true)
|
||||||
expect(res.body.data.data.every((item: any) => item.readAt === null)).toBe(true)
|
expect(res.body.data.every((item: any) => item.readAt === null)).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('marks a company notification as read', async () => {
|
it('marks a company notification as read', async () => {
|
||||||
@@ -66,7 +66,7 @@ describe('Notifications API', () => {
|
|||||||
.set(authHeader(ownerToken))
|
.set(authHeader(ownerToken))
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(res.body.data.data.success).toBe(true)
|
expect(res.body.data.success).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates company notification preferences', async () => {
|
it('updates company notification preferences', async () => {
|
||||||
@@ -80,14 +80,14 @@ describe('Notifications API', () => {
|
|||||||
.send(payload)
|
.send(payload)
|
||||||
|
|
||||||
expect(patchRes.status).toBe(200)
|
expect(patchRes.status).toBe(200)
|
||||||
expect(patchRes.body.data.data.success).toBe(true)
|
expect(patchRes.body.data.success).toBe(true)
|
||||||
|
|
||||||
const getRes = await request(app)
|
const getRes = await request(app)
|
||||||
.get('/api/v1/notifications/company/preferences')
|
.get('/api/v1/notifications/company/preferences')
|
||||||
.set(authHeader(ownerToken))
|
.set(authHeader(ownerToken))
|
||||||
|
|
||||||
expect(getRes.status).toBe(200)
|
expect(getRes.status).toBe(200)
|
||||||
expect(getRes.body.data.data).toEqual(
|
expect(getRes.body.data).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
employeeId,
|
employeeId,
|
||||||
@@ -109,8 +109,8 @@ describe('Notifications API', () => {
|
|||||||
.set(authHeader(renterToken))
|
.set(authHeader(renterToken))
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(Array.isArray(res.body.data.data)).toBe(true)
|
expect(Array.isArray(res.body.data)).toBe(true)
|
||||||
expect(res.body.data.data.some((item: any) => item.id === notification.id)).toBe(true)
|
expect(res.body.data.some((item: any) => item.id === notification.id)).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates renter notification preferences', async () => {
|
it('updates renter notification preferences', async () => {
|
||||||
@@ -124,14 +124,14 @@ describe('Notifications API', () => {
|
|||||||
.send(payload)
|
.send(payload)
|
||||||
|
|
||||||
expect(patchRes.status).toBe(200)
|
expect(patchRes.status).toBe(200)
|
||||||
expect(patchRes.body.data.data.success).toBe(true)
|
expect(patchRes.body.data.success).toBe(true)
|
||||||
|
|
||||||
const getRes = await request(app)
|
const getRes = await request(app)
|
||||||
.get('/api/v1/notifications/renter/preferences')
|
.get('/api/v1/notifications/renter/preferences')
|
||||||
.set(authHeader(renterToken))
|
.set(authHeader(renterToken))
|
||||||
|
|
||||||
expect(getRes.status).toBe(200)
|
expect(getRes.status).toBe(200)
|
||||||
expect(getRes.body.data.data).toEqual(
|
expect(getRes.body.data).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
renterId,
|
renterId,
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ describe('Payments API', () => {
|
|||||||
.set(authHeader(ownerToken))
|
.set(authHeader(ownerToken))
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(Array.isArray(res.body.data.data)).toBe(true)
|
expect(Array.isArray(res.body.data)).toBe(true)
|
||||||
expect(res.body.data.data.some((item: any) => item.id === payment.id)).toBe(true)
|
expect(res.body.data.some((item: any) => item.id === payment.id)).toBe(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -132,8 +132,8 @@ describe('Payments API', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(res.body.data.data.amount).toBe(400)
|
expect(res.body.data.amount).toBe(400)
|
||||||
expect(res.body.data.data.status).toBe('SUCCEEDED')
|
expect(res.body.data.status).toBe('SUCCEEDED')
|
||||||
|
|
||||||
const updated = await prisma.reservation.findUniqueOrThrow({ where: { id: reservation.id } })
|
const updated = await prisma.reservation.findUniqueOrThrow({ where: { id: reservation.id } })
|
||||||
expect(updated.paidAmount).toBe(400)
|
expect(updated.paidAmount).toBe(400)
|
||||||
|
|||||||
@@ -91,16 +91,16 @@ describe('Subscriptions API', () => {
|
|||||||
const res = await request(app).get('/api/v1/subscriptions/plans')
|
const res = await request(app).get('/api/v1/subscriptions/plans')
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(res.body.data.data).toHaveProperty('STARTER')
|
expect(res.body.data).toHaveProperty('STARTER')
|
||||||
expect(res.body.data.data).toHaveProperty('GROWTH')
|
expect(res.body.data).toHaveProperty('GROWTH')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns provider availability', async () => {
|
it('returns provider availability', async () => {
|
||||||
const res = await request(app).get('/api/v1/subscriptions/providers')
|
const res = await request(app).get('/api/v1/subscriptions/providers')
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(typeof res.body.data.data.amanpay).toBe('boolean')
|
expect(typeof res.body.data.amanpay).toBe('boolean')
|
||||||
expect(typeof res.body.data.data.paypal).toBe('boolean')
|
expect(typeof res.body.data.paypal).toBe('boolean')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -111,8 +111,8 @@ describe('Subscriptions API', () => {
|
|||||||
.set(authHeader(ownerToken))
|
.set(authHeader(ownerToken))
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(res.body.data.data.companyId).toBe(companyId)
|
expect(res.body.data.companyId).toBe(companyId)
|
||||||
expect(res.body.data.data.id).toBe(subscriptionId)
|
expect(res.body.data.id).toBe(subscriptionId)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns company invoices', async () => {
|
it('returns company invoices', async () => {
|
||||||
@@ -123,8 +123,8 @@ describe('Subscriptions API', () => {
|
|||||||
.set(authHeader(ownerToken))
|
.set(authHeader(ownerToken))
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(Array.isArray(res.body.data.data)).toBe(true)
|
expect(Array.isArray(res.body.data)).toBe(true)
|
||||||
expect(res.body.data.data.some((item: any) => item.id === invoice.id)).toBe(true)
|
expect(res.body.data.some((item: any) => item.id === invoice.id)).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('changes the subscription plan for OWNER', async () => {
|
it('changes the subscription plan for OWNER', async () => {
|
||||||
@@ -138,9 +138,9 @@ describe('Subscriptions API', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
expect(res.body.data.data.plan).toBe('GROWTH')
|
expect(res.body.data.plan).toBe('GROWTH')
|
||||||
expect(res.body.data.data.billingPeriod).toBe('ANNUAL')
|
expect(res.body.data.billingPeriod).toBe('ANNUAL')
|
||||||
expect(res.body.data.data.currency).toBe('EUR')
|
expect(res.body.data.currency).toBe('EUR')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns 403 for AGENT on plan changes', async () => {
|
it('returns 403 for AGENT on plan changes', async () => {
|
||||||
@@ -162,14 +162,14 @@ describe('Subscriptions API', () => {
|
|||||||
.set(authHeader(ownerToken))
|
.set(authHeader(ownerToken))
|
||||||
|
|
||||||
expect(cancelRes.status).toBe(200)
|
expect(cancelRes.status).toBe(200)
|
||||||
expect(cancelRes.body.data.data.cancelAtPeriodEnd).toBe(true)
|
expect(cancelRes.body.data.cancelAtPeriodEnd).toBe(true)
|
||||||
|
|
||||||
const resumeRes = await request(app)
|
const resumeRes = await request(app)
|
||||||
.post('/api/v1/subscriptions/resume')
|
.post('/api/v1/subscriptions/resume')
|
||||||
.set(authHeader(ownerToken))
|
.set(authHeader(ownerToken))
|
||||||
|
|
||||||
expect(resumeRes.status).toBe(200)
|
expect(resumeRes.status).toBe(200)
|
||||||
expect(resumeRes.body.data.data.cancelAtPeriodEnd).toBe(false)
|
expect(resumeRes.body.data.cancelAtPeriodEnd).toBe(false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user