Skip to content

Commit

Permalink
Merge pull request #1216 from Enterprise-CMCS/main
Browse files Browse the repository at this point in the history
Release to val
  • Loading branch information
13bfrancis authored Feb 27, 2025
2 parents 0c3689a + df6fafc commit d418940
Show file tree
Hide file tree
Showing 8 changed files with 323 additions and 46 deletions.
4 changes: 4 additions & 0 deletions lib/libs/email/content/respondToRai/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const respondToRai: AuthoritiesWithUserTypesTemplate = {
) => {
return {
to: [`${variables.submitterName} <${variables.submitterEmail}>`],
cc: variables.allStateUsersEmails ?? [],
subject: `Your Medicaid SPA RAI Response for ${variables.id} has been submitted to CMS`,
body: await render(<MedSpaStateEmail variables={variables} />),
};
Expand All @@ -55,6 +56,7 @@ export const respondToRai: AuthoritiesWithUserTypesTemplate = {
) => {
return {
to: [`${variables.submitterName} <${variables.submitterEmail}>`],
cc: variables.allStateUsersEmails ?? [],
subject: `Your CHIP SPA RAI Response for ${variables.id} has been submitted to CMS`,
body: await render(<ChipSpaStateEmail variables={variables} />),
};
Expand All @@ -80,6 +82,7 @@ export const respondToRai: AuthoritiesWithUserTypesTemplate = {
) => {
return {
to: [`${variables.submitterName} <${variables.submitterEmail}>`],
cc: variables.allStateUsersEmails ?? [],
subject: `Your 1915(b) RAI Response for ${variables.id} has been submitted to CMS`,
body: await render(<WaiverStateEmail variables={variables} />),
};
Expand All @@ -105,6 +108,7 @@ export const respondToRai: AuthoritiesWithUserTypesTemplate = {
) => {
return {
to: [`${variables.submitterName} <${variables.submitterEmail}>`],
cc: variables.allStateUsersEmails ?? [],
subject: `Your 1915(c) RAI Response for ${variables.id} has been submitted to CMS`,
body: await render(<WaiverStateEmail variables={variables} />),
};
Expand Down
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions react-app/src/components/Layout/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ vi.mock("@/components", () => ({
UserPrompt: () => null,
Banner: () => null,
ScrollToTop: () => null,
Accordion: () => null,
AccordionItem: () => null,
AccordionTrigger: () => null,
AccordionContent: () => null,
}));

// Navigation mock
Expand Down
22 changes: 19 additions & 3 deletions react-app/src/components/Opensearch/main/useOpensearch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { useEffect, useState, useRef } from "react";
import { useQuery } from "@tanstack/react-query";
import { UserRoles, opensearch } from "shared-types";
import { getOsData, useOsSearch, useGetUser } from "@/api";
Expand Down Expand Up @@ -50,8 +50,17 @@ export const useOsData = () => {
opensearch.main.Field,
opensearch.main.Response
>();

const [tabLoading, setTabLoading] = useState(false);
const previousTab = useRef(params.state.tab);

const onRequest = async (query: opensearch.main.State, options?: any) => {
try {
if (params.state.tab !== previousTab.current) {
setTabLoading(true);
previousTab.current = params.state.tab;
}

await mutateAsync(
{
index: "main",
Expand All @@ -63,16 +72,23 @@ export const useOsData = () => {
...(DEFAULT_FILTERS[params.state.tab].filters || []),
],
},
{ ...options, onSuccess: (res) => setData(res.hits) },
{
...options,
onSuccess: (res) => {
setData(res.hits);
setTabLoading(false);
},
},
);
} catch (error) {
console.error("Error occurred during search:", error);
setTabLoading(false);
}
};
useEffect(() => {
onRequest(params.state);
}, [params.queryString]);
return { data, isLoading, error, ...params };
return { data, isLoading, error, ...params, tabLoading };
};
export const useOsAggregate = () => {
const { data: user } = useGetUser();
Expand Down
50 changes: 31 additions & 19 deletions react-app/src/features/dashboard/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { describe, expect, it, vi, beforeAll, afterAll, beforeEach, afterEach } from "vitest";
import { screen, within, waitForElementToBeRemoved, cleanup } from "@testing-library/react";
import {
screen,
within,
waitForElementToBeRemoved,
cleanup,
waitFor,
} from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import {
renderWithQueryClientAndMemoryRouter,
Expand Down Expand Up @@ -173,12 +179,13 @@ describe("Dashboard", () => {
it("should handle switching to the Waiver tab", async () => {
const isWaiver = true;

const waiverTab = screen.queryByRole("heading", { level: 2, name: "Waivers" });

await user.click(waiverTab.parentElement);
await waitFor(async () => {
const waiverTab = await screen.findByRole("heading", { level: 2, name: "Waivers" });
await user.click(waiverTab.parentElement);

expect(waiverTab).toBeInTheDocument();
expect(waiverTab.parentElement.getAttribute("aria-selected")).toEqual("true");
expect(waiverTab).toBeInTheDocument();
expect(waiverTab.parentElement.getAttribute("aria-selected")).toEqual("true");
});

const spaTab = screen.queryByRole("heading", { level: 2, name: "SPAs" });
expect(spaTab).toBeInTheDocument();
Expand All @@ -192,12 +199,13 @@ describe("Dashboard", () => {
it("should handle switching back to the SPA tab", async () => {
const isWaiver = false;

const spaTab = screen.queryByRole("heading", { level: 2, name: "SPAs" });

await user.click(spaTab.parentElement);
await waitFor(async () => {
const spaTab = await screen.findByRole("heading", { level: 2, name: "SPAs" });
await user.click(spaTab.parentElement);

expect(spaTab).toBeInTheDocument();
expect(spaTab.parentElement.getAttribute("aria-selected")).toEqual("true");
expect(spaTab).toBeInTheDocument();
expect(spaTab.parentElement.getAttribute("aria-selected")).toEqual("true");
});

const waiverTab = screen.queryByRole("heading", { level: 2, name: "Waivers" });
expect(waiverTab).toBeInTheDocument();
Expand Down Expand Up @@ -266,11 +274,13 @@ describe("Dashboard", () => {
it("should handle switching to the Waiver tab", async () => {
const isWaiver = true;

const waiverTab = screen.queryByRole("heading", { level: 2, name: "Waivers" });
await user.click(waiverTab.parentElement);
await waitFor(async () => {
const waiverTab = await screen.findByRole("heading", { level: 2, name: "Waivers" });
await user.click(waiverTab.parentElement);

expect(waiverTab).toBeInTheDocument();
expect(waiverTab.parentElement.getAttribute("aria-selected")).toEqual("true");
expect(waiverTab).toBeInTheDocument();
expect(waiverTab.parentElement.getAttribute("aria-selected")).toEqual("true");
});

const spaTab = screen.queryByRole("heading", { level: 2, name: "SPAs" });
expect(spaTab).toBeInTheDocument();
Expand All @@ -284,11 +294,13 @@ describe("Dashboard", () => {
it("should handle switching back to the SPA tab", async () => {
const isWaiver = false;

const spaTab = screen.queryByRole("heading", { level: 2, name: "SPAs" });
await user.click(spaTab.parentElement);
await waitFor(async () => {
const spaTab = screen.queryByRole("heading", { level: 2, name: "SPAs" });
await user.click(spaTab.parentElement);

expect(spaTab).toBeInTheDocument();
expect(spaTab.parentElement.getAttribute("aria-selected")).toEqual("true");
expect(spaTab).toBeInTheDocument();
expect(spaTab.parentElement.getAttribute("aria-selected")).toEqual("true");
});

const waiverTab = screen.queryByRole("heading", { level: 2, name: "Waivers" });
expect(waiverTab).toBeInTheDocument();
Expand Down
2 changes: 1 addition & 1 deletion react-app/src/features/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const Dashboard = () => {
);
};

if (isLoading) {
if (isLoading || osData.tabLoading) {
return <LoadingSpinner />;
}

Expand Down
Loading

0 comments on commit d418940

Please sign in to comment.