Skip to content

Commit 21a6841

Browse files
authored
Merge pull request #29 from WebFuzzing/tc-validation
Test case validation
2 parents f707e40 + d9154b5 commit 21a6841

13 files changed

Lines changed: 846 additions & 60 deletions

web-report/src-e2e/App.test.tsx

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {render, waitFor, screen, act, fireEvent} from '@testing-library/react';
1+
import {render, waitFor, screen, act, fireEvent, within} from '@testing-library/react';
22
import '@testing-library/jest-dom';
33
import {resolve} from "path";
44
import {readFileSync} from "fs";
@@ -18,7 +18,7 @@ vi.mock('@/lib/utils.tsx', async (importOriginal) => {
1818
fetchFileContent: vi.fn(async (filePath: string) => {
1919
const folderPath = resolve(__dirname, './static/');
2020
const fullPath = resolve(folderPath, filePath);
21-
if (fullPath.endsWith('.json')) {
21+
if (fullPath.endsWith('report.json')) {
2222
return reportData;
2323
} else if (filePath.endsWith('.java')) {
2424
return readFileSync(fullPath, 'utf-8');
@@ -134,6 +134,83 @@ describe('App test', () => {
134134
});
135135
});
136136

137+
it('changing a review state marks it dirty and updates counts', async () => {
138+
render(<App/>);
139+
await waitFor(() => {
140+
expect(screen.getByTestId('tab-tests')).toBeInTheDocument();
141+
});
142+
143+
act(() => {
144+
fireEvent.focus(screen.getByTestId('tab-tests'));
145+
});
146+
147+
await waitFor(() => {
148+
expect(screen.getByTestId('test-file-0')).toBeInTheDocument();
149+
});
150+
151+
act(() => {
152+
fireEvent.click(within(screen.getByTestId('test-file-0')).getByRole('button'));
153+
});
154+
155+
const firstTestId = reportData.testCases[0].id as string;
156+
await waitFor(() => {
157+
expect(screen.getByTestId(`test-review-state-${firstTestId}`)).toBeInTheDocument();
158+
});
159+
160+
act(() => {
161+
fireEvent.change(screen.getByTestId(`test-review-state-${firstTestId}`), {
162+
target: {value: 'ACCEPTED'},
163+
});
164+
});
165+
166+
await waitFor(() => {
167+
expect(screen.getByTestId('reviews-unsaved-banner')).toBeInTheDocument();
168+
expect(screen.getByTestId('reviews-filter-ACCEPTED')).toHaveTextContent('ACCEPTED (1)');
169+
expect(screen.getByTestId('reviews-filter-NOT-REVIEWED'))
170+
.toHaveTextContent(`NOT-REVIEWED (${reportData.testCases.length - 1})`);
171+
});
172+
});
173+
174+
it('clicking a test opens the detail dialog and close dismisses it', async () => {
175+
render(<App/>);
176+
await waitFor(() => {
177+
expect(screen.getByTestId('tab-tests')).toBeInTheDocument();
178+
});
179+
180+
act(() => {
181+
fireEvent.focus(screen.getByTestId('tab-tests'));
182+
});
183+
184+
await waitFor(() => {
185+
expect(screen.getByTestId('test-file-0')).toBeInTheDocument();
186+
});
187+
188+
act(() => {
189+
fireEvent.click(within(screen.getByTestId('test-file-0')).getByRole('button'));
190+
});
191+
192+
const firstTestId = reportData.testCases[0].id as string;
193+
await waitFor(() => {
194+
expect(screen.getByTestId(`test-review-open-${firstTestId}`)).toBeInTheDocument();
195+
});
196+
197+
act(() => {
198+
fireEvent.click(screen.getByTestId(`test-review-open-${firstTestId}`));
199+
});
200+
201+
await waitFor(() => {
202+
expect(screen.getByTestId('test-detail-dialog')).toBeInTheDocument();
203+
});
204+
205+
act(() => {
206+
fireEvent.click(screen.getByTestId('test-detail-dialog-close'));
207+
});
208+
209+
await waitFor(() => {
210+
expect(screen.queryByTestId('test-detail-dialog')).toBeNull();
211+
});
212+
});
213+
137214
it('check faults component', async () => {
138215
render(<App />);
139216
expect(screen.getByText(/Please wait, files are loading.../)).toBeInTheDocument();

0 commit comments

Comments
 (0)