Skip to content

Commit

Permalink
Merge pull request #1490 from ita-social-projects/feature/issue-1361
Browse files Browse the repository at this point in the history
Feature 1361
  • Loading branch information
darkravchuk authored Dec 30, 2024
2 parents 33f6838 + 6a97ffe commit f0fd7ca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('CategoryAdminModal', () => {

await waitFor(() => {
expect(saveButton).toBeDisabled();
});
}, { timeout: 3000 });
});

it('should update existing category', async () => {
Expand All @@ -175,7 +175,6 @@ describe('CategoryAdminModal', () => {
act(() => {
render(<CategoryAdminModal {...defaultProps} initialData={initialData} />);
});

const nameInput = screen.getByRole('textbox', { name: /Назва/i });
const saveButton = screen.getByRole('button', { name: /Зберегти/i });
const fileuploader = screen.getByTestId('fileuploader');
Expand All @@ -186,6 +185,9 @@ describe('CategoryAdminModal', () => {
userEvent.upload(fileuploader, new File(['(⌐□_□)'], 'new-image.jpg', { type: 'image/jpg' }));
});

await waitFor(() => {
expect(saveButton).not.toBeDisabled();
});
await waitFor(() => userEvent.click(saveButton));

await waitFor(() => {
Expand Down Expand Up @@ -223,7 +225,7 @@ describe('CategoryAdminModal', () => {

await waitFor(() => {
expect(saveButton).toBeDisabled();
});
}, { timeout: 3000 });
});

it('should show error message when title is empty', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,20 @@ describe('NewsModal', () => {
userEvent.upload(fileUpload, file);
});
await act(async () => { await new Promise((r) => setTimeout(r, 2000)) });
screen.debug();
// There is no need to repeat this part of code for edit test (logic is the same).
// Once here is enough to check that we don`t submit empty strings.
expect(titleInput).toHaveValue('Test Title');
expect(urlInput).toHaveValue('testurl');
expect(textInput).toHaveValue('This is a test text');
if (fileUpload.files) expect(fileUpload.files[0]).toStrictEqual(file);

screen.debug();
userEvent.click(button);
await waitFor(() => {
expect(mockCreateNews).toHaveBeenCalled();
expect(mockUpdateNews).not.toHaveBeenCalled();
expect(afterSubmitMock).toHaveBeenCalled();
});
}, 10000);
}, 50000);

it('should not submit when required fields are empty', async () => {
const setIsModalOpen = jest.fn();
Expand Down Expand Up @@ -269,7 +267,7 @@ describe('NewsModal', () => {
expect(mockCreateNews).not.toHaveBeenCalled();
expect(afterSubmitMock).toHaveBeenCalled();
});
}, 10000);
}, 50000);

it('should update existing news when required fields match', async () => {
const existingNews = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const NewsModal: React.FC<{
</div>
<Form.Item
name="title"
label="Заголовок: "
label="Заголовок:"
rules={[
{ required: true, message: 'Введіть заголовок' },
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,5 @@ describe('TeamModal', () => {
expect(afterSubmit).toHaveBeenCalled();
expect(store.updateTeam).not.toHaveBeenCalled();
});
}, 20000);
}, 50000);
});

0 comments on commit f0fd7ca

Please sign in to comment.