From 3cff6f8e4a2f2afeff5fa0695bc70415ab78deba Mon Sep 17 00:00:00 2001 From: gscottqueen Date: Tue, 19 Mar 2024 13:04:04 -0400 Subject: [PATCH 1/3] PXBF-978-e2e-releative-benefits-icons: include data with render --- .../__tests__/index.spec.jsx | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/benefit-finder/src/shared/components/RelativeBenefitList/__tests__/index.spec.jsx b/benefit-finder/src/shared/components/RelativeBenefitList/__tests__/index.spec.jsx index a76de2b7d..e7a43dd72 100644 --- a/benefit-finder/src/shared/components/RelativeBenefitList/__tests__/index.spec.jsx +++ b/benefit-finder/src/shared/components/RelativeBenefitList/__tests__/index.spec.jsx @@ -1,9 +1,42 @@ -import { render } from '@testing-library/react' +import { render, waitFor, screen } from '@testing-library/react' import RelativeBenefitList from '../index.jsx' +import content from '../../../api/mock-data/current.js' + +const { data } = JSON.parse(content) +const relativeBenefits = data.lifeEventForm.relevantBenefits +const args = { + data: relativeBenefits, + carrotType: 'carrot-big', +} describe('RelativeBenefitList', () => { it('renders a match to the previous snapshot', () => { - const { asFragment } = render() + const { asFragment } = render( + + ) expect(asFragment()).toMatchSnapshot() }) + + it('renders icons based on its lifeEvent id', async () => { + render( + + ) + + // wait until the last relative benefit renders + await waitFor(() => { + screen.getByTestId(relativeBenefits[1].lifeEvent.lifeEventId) + }) + const links = screen.getAllByRole('link') + + // ensure the link contains values from the lifeEventId + expect(links[0].href).toContain(relativeBenefits[0].lifeEvent.lifeEventId) + expect(links[1].href).toContain(relativeBenefits[1].lifeEvent.lifeEventId) + // ensure the icons that contain values from the lifeEventId are in the dom + expect( + screen.getByTestId(`icon-${relativeBenefits[0].lifeEvent.lifeEventId}`) + ).toBeInTheDocument() + expect( + screen.getByTestId(`icon-${relativeBenefits[1].lifeEvent.lifeEventId}`) + ).toBeInTheDocument() + }) }) From 5f8007b474b9c0bd22d3dada6dd8c643b1dce376 Mon Sep 17 00:00:00 2001 From: gscottqueen Date: Tue, 19 Mar 2024 13:04:50 -0400 Subject: [PATCH 2/3] PXBF-978-e2e-releative-benefits-icons: pass props to list item --- benefit-finder/src/shared/components/Card/index.jsx | 2 ++ benefit-finder/src/shared/components/Icon/index.jsx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/benefit-finder/src/shared/components/Card/index.jsx b/benefit-finder/src/shared/components/Card/index.jsx index d39f184cf..0811f24f3 100644 --- a/benefit-finder/src/shared/components/Card/index.jsx +++ b/benefit-finder/src/shared/components/Card/index.jsx @@ -26,6 +26,7 @@ const Card = ({ noCarrot, carrotType, icon, + ...props }) => { const defaultClasses = icon !== undefined ? ['bf-card-icon'] : '' const utilityClasses = ['add-list-reset'] @@ -44,6 +45,7 @@ const Card = ({ utilityClasses, })} key={`${title}`} + {...props} > {handleIcon} diff --git a/benefit-finder/src/shared/components/Icon/index.jsx b/benefit-finder/src/shared/components/Icon/index.jsx index d6f69ede0..e7012d868 100644 --- a/benefit-finder/src/shared/components/Icon/index.jsx +++ b/benefit-finder/src/shared/components/Icon/index.jsx @@ -51,7 +51,7 @@ const Icon = ({ type, color, ...props }) => { icon = null } return ( -