Files
QuantEngineByItz/oms-wms-erp/tests/integration/customer-workflow.spec.ts
T
kjh2064 b34b0dd7d6
Validators (Pushes and Pull Requests) / UI & Storage Validation (pull_request) Failing after 12s
Validators (Pushes and Pull Requests) / Database & Schema Validation (pull_request) Successful in 13s
Validators (Pushes and Pull Requests) / Core Validators & Database Setup (pull_request) Failing after 28s
Validators (Pushes and Pull Requests) / WBS & Audit Validations (pull_request) Has been skipped
Validators (Pushes and Pull Requests) / .NET Contracts (pull_request) Has been skipped
Validators (Pushes and Pull Requests) / Calibration & Performance (pull_request) Has been skipped
Validators (Pushes and Pull Requests) / Operational Report & Decision Packet (pull_request) Has been skipped
Validators (Pushes and Pull Requests) / CI Workflow Lint (pull_request) Failing after 10s
Validators (Pushes and Pull Requests) / Security & Secrets (pull_request) Successful in 12s
Validators (Pushes and Pull Requests) / Notify PR Results (pull_request) Successful in 2s
Frontend CI Pipeline / ci-frontend-8-steps (pull_request) Failing after 2m50s
Add OMS WMS ERP platform
2026-07-27 00:45:39 +09:00

112 lines
3.1 KiB
TypeScript

import { describe, it, expect, beforeEach } from 'vitest'
import { setActivePinia, createPinia } from 'pinia'
import { useCustomerStore } from '@/stores'
describe('Customer Workflow Integration Tests', () => {
beforeEach(() => {
setActivePinia(createPinia())
})
describe('Customer Management', () => {
it('should create and manage customers', async () => {
const customerStore = useCustomerStore()
const customer = await customerStore.createCustomer({
code: 'CUST-001',
name: 'Test Customer',
email: 'test@example.com',
phone: '123-456-7890',
address: '123 Main St',
city: 'Springfield',
country: 'USA',
creditLimit: 10000
})
expect(customer.code).toBe('CUST-001')
expect(customer.status).toBe('ACTIVE')
expect(customer.creditUsed).toBe(0)
})
it('should track credit usage', async () => {
const customerStore = useCustomerStore()
const customer = await customerStore.createCustomer({
code: 'CUST-002',
name: 'Credit Test',
email: 'credit@test.com',
phone: '999-999-9999',
address: 'Test',
city: 'Test',
country: 'USA',
creditLimit: 5000
})
await customerStore.updateCreditUsage(customer.id, 2000)
const updated = customerStore.customers.find((c) => c.id === customer.id)
expect(updated?.creditUsed).toBe(2000)
})
it('should identify at-risk customers', async () => {
const customerStore = useCustomerStore()
const customer = await customerStore.createCustomer({
code: 'CUST-RISK',
name: 'Risk Customer',
email: 'risk@test.com',
phone: '888-888-8888',
address: 'Risk Ave',
city: 'Risk City',
country: 'USA',
creditLimit: 1000
})
// Use 85% of credit
await customerStore.updateCreditUsage(customer.id, 850)
const atRisk = customerStore.atRiskCustomers
expect(atRisk.some((c) => c.id === customer.id)).toBe(true)
})
it('should update customer status', async () => {
const customerStore = useCustomerStore()
const customer = await customerStore.createCustomer({
code: 'CUST-003',
name: 'Status Test',
email: 'status@test.com',
phone: '777-777-7777',
address: 'Status St',
city: 'Status City',
country: 'USA'
})
await customerStore.updateCustomer(customer.id, {
status: 'SUSPENDED'
})
const updated = customerStore.customers.find((c) => c.id === customer.id)
expect(updated?.status).toBe('SUSPENDED')
})
})
describe('Customer Validation', () => {
it('should maintain active customer count', async () => {
const customerStore = useCustomerStore()
const initial = customerStore.activeCustomers.length
await customerStore.createCustomer({
code: 'CUST-NEW',
name: 'New Customer',
email: 'new@test.com',
phone: '666-666-6666',
address: 'New St',
city: 'New City',
country: 'USA'
})
expect(customerStore.activeCustomers.length).toBe(initial + 1)
})
})
})