|
1 | | -import { fireEvent, render, screen, waitFor } from '@testing-library/react' |
2 | | -import { toast } from 'sonner' |
| 1 | +import { render, screen } from '@testing-library/react' |
3 | 2 | import { describe, expect, it, vi } from 'vitest' |
4 | 3 | import { useUser } from '@/hooks/useUser' |
5 | 4 | import { FakeUser, UserRole } from '@/types/user' |
@@ -122,45 +121,12 @@ describe('DashboardPage', () => { |
122 | 121 | expect( |
123 | 122 | screen.getByText(`User Info: ${FakeUser.name}`), |
124 | 123 | ).toBeInTheDocument() |
125 | | - expect(screen.getByText('Requisitar Documentos')).toBeInTheDocument() |
| 124 | + expect(screen.getByText('Ações do Estudante')).toBeInTheDocument() |
126 | 125 | expect( |
127 | 126 | screen.getByText( |
128 | 127 | `Grades Table: ${FakeUser.profile_details?.grades_details?.length} subjects`, |
129 | 128 | ), |
130 | 129 | ).toBeInTheDocument() |
131 | | - |
132 | | - // Mock window.open to prevent jsdom error |
133 | | - Object.defineProperty(window, 'open', { |
134 | | - value: vi.fn(), |
135 | | - writable: true, |
136 | | - }) |
137 | | - |
138 | | - // Mock window.location to prevent navigation error |
139 | | - const originalLocation = window.location |
140 | | - Object.defineProperty(window, 'location', { |
141 | | - value: { |
142 | | - ...originalLocation, |
143 | | - href: '', |
144 | | - assign: vi.fn(), |
145 | | - replace: vi.fn(), |
146 | | - }, |
147 | | - writable: true, |
148 | | - }) |
149 | | - |
150 | | - // Test handleClick for ButtonGridCard |
151 | | - const bulletinButton = screen.getByRole('button', { name: /Boletim/i }) |
152 | | - fireEvent.click(bulletinButton) |
153 | | - await waitFor(() => { |
154 | | - expect(toast.success).toHaveBeenCalledWith( |
155 | | - 'Requisição de Boletim enviada com sucesso!', |
156 | | - ) |
157 | | - }) |
158 | | - |
159 | | - // Restore original location |
160 | | - Object.defineProperty(window, 'location', { |
161 | | - value: originalLocation, |
162 | | - writable: true, |
163 | | - }) |
164 | 130 | }) |
165 | 131 |
|
166 | 132 | it('deve renderizar informações do professor e não cards específicos de aluno', () => { |
@@ -195,9 +161,7 @@ describe('DashboardPage', () => { |
195 | 161 | expect( |
196 | 162 | screen.getByText(`User Info: ${mockProfessorUser.name}`), |
197 | 163 | ).toBeInTheDocument() |
198 | | - expect( |
199 | | - screen.queryByText('Requisitar Documentos'), |
200 | | - ).not.toBeInTheDocument() |
| 164 | + expect(screen.queryByText('Ações do Estudante')).not.toBeInTheDocument() |
201 | 165 | expect(screen.queryByText(/Grades Table/i)).not.toBeInTheDocument() |
202 | 166 | }) |
203 | 167 |
|
@@ -233,9 +197,7 @@ describe('DashboardPage', () => { |
233 | 197 | expect( |
234 | 198 | screen.getByText(`User Info: ${mockGuardianUser.name}`), |
235 | 199 | ).toBeInTheDocument() |
236 | | - expect( |
237 | | - screen.queryByText('Requisitar Documentos'), |
238 | | - ).not.toBeInTheDocument() |
| 200 | + expect(screen.queryByText('Ações do Estudante')).not.toBeInTheDocument() |
239 | 201 | expect(screen.queryByText(/Grades Table/i)).not.toBeInTheDocument() |
240 | 202 | }) |
241 | 203 | }) |
0 commit comments