Skip to content

Commit

Permalink
Refactor de alertas de Queue y correccion de los Warnings (#173)
Browse files Browse the repository at this point in the history
* Refactor de alertas de Queue y correccion de los Warnings

* Fix informationBar tests

---------

Co-authored-by: Diego Jacobo Martínez <diegojmr5@gmail.com>
  • Loading branch information
FranciscoSanchezz and Djmr5 authored Jun 3, 2024
1 parent fbbce9e commit 22eec1f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
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();
});
});

});

0 comments on commit 22eec1f

Please sign in to comment.