f22e0d45e1
Build & Deploy / Build & Push Docker Image (push) Successful in 7m57s
Test / Type Check (all packages) (push) Successful in 4m27s
Build & Deploy / Deploy to VPS (push) Successful in 7s
Test / API Unit Tests (push) Failing after 3m2s
Test / Homepage Unit Tests (push) Successful in 4m3s
Test / Storefront Unit Tests (push) Successful in 3m32s
Test / Admin Unit Tests (push) Successful in 3m27s
Test / Dashboard Unit Tests (push) Successful in 3m3s
Test / API Integration Tests (push) Failing after 3m53s
61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
import request from 'supertest'
|
|
import { createApp } from '../../app'
|
|
|
|
const app = createApp()
|
|
|
|
function uniqueEmail(prefix: string) {
|
|
return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}@test.com`
|
|
}
|
|
|
|
describe('Company signup API', () => {
|
|
it('creates new accounts with a 30-day trial period', async () => {
|
|
const startedAt = Date.now()
|
|
|
|
const res = await request(app)
|
|
.post('/api/v1/auth/company/signup')
|
|
.send({
|
|
firstName: 'Trial',
|
|
lastName: 'Owner',
|
|
email: uniqueEmail('trial-owner'),
|
|
password: 'Password123!',
|
|
companyName: `Trial Cars ${Date.now()}`,
|
|
legalName: `Trial Cars SARL ${Date.now()}`,
|
|
legalForm: 'LLC',
|
|
registrationNumber: `REG-${Date.now()}`,
|
|
iceNumber: `ICE-${Date.now()}`,
|
|
taxId: `IF-${Date.now()}`,
|
|
operatingLicenseNumber: `AGR-${Date.now()}`,
|
|
operatingLicenseIssuedAt: '2026-01-15',
|
|
operatingLicenseIssuedBy: 'Wilaya de Casablanca',
|
|
streetAddress: '123 Main Street',
|
|
city: 'Casablanca',
|
|
country: 'Morocco',
|
|
zipCode: '20000',
|
|
companyPhone: '+212600000000',
|
|
companyEmail: uniqueEmail('trial-company'),
|
|
yearsActive: '1',
|
|
representativeName: 'Trial Representative',
|
|
representativeTitle: 'Managing Director',
|
|
responsibleName: 'Operations Lead',
|
|
responsibleRole: 'Responsible Manager',
|
|
responsibleIdentityNumber: `CIN-${Date.now()}`,
|
|
responsibleQualification: '10 years fleet operations experience',
|
|
responsiblePhone: '+212611111111',
|
|
responsibleEmail: uniqueEmail('trial-responsible'),
|
|
preferredLanguage: 'en',
|
|
plan: 'STARTER',
|
|
billingPeriod: 'MONTHLY',
|
|
currency: 'MAD',
|
|
paymentProvider: 'AMANPAY',
|
|
})
|
|
|
|
expect(res.status).toBe(201)
|
|
|
|
const trialEndsAt = new Date(res.body.data.trialEndsAt).getTime()
|
|
const trialDurationDays = (trialEndsAt - startedAt) / (24 * 60 * 60 * 1000)
|
|
|
|
expect(trialDurationDays).toBeGreaterThan(29.9)
|
|
expect(trialDurationDays).toBeLessThan(30.1)
|
|
})
|
|
})
|