Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor de alertas de Queue y correccion de los Warnings #173

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/InfoLoader/InfoLoader.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from "react";
import './InfoLoader.css';

const InfoLoader: React.FC = () => {
interface IInfoLoader {
testId?: string;
}
const InfoLoader: React.FC<IInfoLoader> = () => {

return (
<div role="progressbar" className="info-loader">
<div className="info-loader__bubble"></div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { render, cleanup, screen } from '@testing-library/react';
import InformationBar from '../InformationBar';
import { cleanup, render, screen } from '@testing-library/react';
import { IItemSubitem } from '../../ItemSubitem/types';
import InformationBar from '../InformationBar';

afterEach(() => {
cleanup();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Queue/Queue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Queue: React.FC = () => {
Queue: <span data-testid="queue-title-id" className=' text-aci-orange'>{shortId(id ?? '')}</span>
</span>
{loading ?
(<InfoLoader/>) :
(<InfoLoader testId='infoloader'/>) :
(
!loading && queueInfo && !errorQueueInfo ? (
<div data-testid="queue-information-metrics-section">
Expand Down
20 changes: 10 additions & 10 deletions src/pages/Queue/__tests__/Queue.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,21 @@ describe("Tests for Queue page", () => {
expect(screen.getAllByRole("progressbar")).toHaveLength(4);
});

test("Displays error message when data fetch fails", async () => {
(getQueueInfo as jest.Mock).mockImplementation(() => Promise.reject(new Error("Failed to fetch")));

test("Should handle all types of alert priorities", async () => {
(getQueueInfo as jest.Mock).mockResolvedValue(mockQueueInformation[0]);
render(<Queue />);

await waitFor(() => {
expect(screen.getByText("Error fetching queue")).toBeInTheDocument();
expect(screen.getByText("Critic")).toBeInTheDocument();
});
});

test("Correctly displays no alerts found when there are no alerts", async () => {
const modifiedData = { ...mockQueueInformation[0], alerts: { high: [], medium: [], low: [] } };
(getQueueInfo as jest.Mock).mockResolvedValue(modifiedData);
render(<Queue />);
await waitFor(() => {
expect(screen.getByText("No alerts found")).toBeInTheDocument();
expect(screen.getByText("Medium")).toBeInTheDocument();
});

await waitFor(() => {
expect(screen.getByText("Low")).toBeInTheDocument();
});
});

Expand All @@ -157,5 +158,4 @@ describe("Tests for Queue page", () => {
expect(screen.getByText("Diego Jacobo")).toBeInTheDocument();
});
});

});