|
| 1 | +import { render, screen, waitFor } from '@testing-library/react' |
| 2 | +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' |
| 3 | +import DisputeResolutionPage from './page' |
| 4 | + |
| 5 | +const mockDispute = { |
| 6 | + id: 42, |
| 7 | + job_title: 'Website Rebuild', |
| 8 | + reason: 'Quality issue with the final delivery', |
| 9 | + status: 'open', |
| 10 | + created_at: '2024-02-01T12:00:00.000Z', |
| 11 | + updated_at: '2024-02-01T12:00:00.000Z', |
| 12 | + raised_by_username: 'alice', |
| 13 | + raised_by_wallet: 'GABCDE1234', |
| 14 | +} |
| 15 | + |
| 16 | +describe('DisputeResolutionPage', () => { |
| 17 | + beforeEach(() => { |
| 18 | + vi.stubGlobal('fetch', vi.fn(() => |
| 19 | + Promise.resolve({ |
| 20 | + ok: true, |
| 21 | + json: async () => mockDispute, |
| 22 | + }) as Response, |
| 23 | + )) |
| 24 | + }) |
| 25 | + |
| 26 | + afterEach(() => { |
| 27 | + vi.restoreAllMocks() |
| 28 | + }) |
| 29 | + |
| 30 | + it('renders dispute details and evidence UI', async () => { |
| 31 | + render(<DisputeResolutionPage params={{ id: '42' }} />) |
| 32 | + |
| 33 | + expect(screen.getByText(/review dispute/i)).toBeInTheDocument() |
| 34 | + expect(screen.getByText(/dispute resolution/i)).toBeInTheDocument() |
| 35 | + |
| 36 | + await waitFor(() => { |
| 37 | + expect(screen.getByText(/Website Rebuild/i)).toBeInTheDocument() |
| 38 | + expect(screen.getByText(/Quality issue with the final delivery/i)).toBeInTheDocument() |
| 39 | + expect(screen.getByText(/alice/i)).toBeInTheDocument() |
| 40 | + }) |
| 41 | + |
| 42 | + expect(screen.getByRole('button', { name: /choose files/i })).toBeInTheDocument() |
| 43 | + expect(screen.getByRole('button', { name: /submit evidence/i })).toBeInTheDocument() |
| 44 | + }) |
| 45 | +}) |
0 commit comments