diff --git a/frontend/src/components/Rank/Rank.scss b/frontend/src/components/Cup/Cup.scss similarity index 97% rename from frontend/src/components/Rank/Rank.scss rename to frontend/src/components/Cup/Cup.scss index d706d8520..a71905385 100644 --- a/frontend/src/components/Rank/Rank.scss +++ b/frontend/src/components/Cup/Cup.scss @@ -1,4 +1,4 @@ -.aha__rank { +.aha__cup { width: 150px; height: 150px; border-radius: 50%; @@ -91,7 +91,7 @@ box-shadow: 13px 0 64px $black; } - > h4 { + >h4 { position: absolute; bottom: 9px; width: 100%; @@ -102,7 +102,7 @@ letter-spacing: 0.1em; } - > .cup { + >.cup { width: 85px; height: 85px; background-image: $cup; @@ -115,7 +115,7 @@ animation-timing-function: ease-in-out; } - &.offsetCup > .cup { + &.offsetCup>.cup { margin-top: -20px; } } diff --git a/frontend/src/components/Cup/Cup.test.tsx b/frontend/src/components/Cup/Cup.test.tsx new file mode 100644 index 000000000..b159a3be7 --- /dev/null +++ b/frontend/src/components/Cup/Cup.test.tsx @@ -0,0 +1,60 @@ +import { render } from '@testing-library/react'; +import Cup from './Cup'; +import { describe, expect, it } from 'vitest'; + + +describe('Cup Component', () => { + it('renders with the correct class and text', () => { + const rank = { + className: 'gold', + text: 'Gold Cup', + }; + + const { getByTestId, getByText } = render(); + + const cupElement = getByTestId('cup'); + + // Check if the main div has the correct classes + expect(cupElement.classList.contains('aha__cup')).toBe(true); + expect(cupElement.classList.contains('gold')).toBe(true); + expect(cupElement.classList.contains('offsetCup')).toBe(true); + + // Check if the h4 element contains the correct text + expect(document.body.contains(getByText('Gold Cup'))).toBe(true); + }); + + it('does not have offsetCup class when text is empty', () => { + const rank = { + className: 'silver', + text: '', + }; + + const { getByTestId } = render(); + + const cupElement = getByTestId('cup'); + + // Check if the main div has the correct classes + expect(cupElement.classList.contains('aha__cup')).toBe(true); + expect(cupElement.classList.contains('silver')).toBe(true); + expect(cupElement.classList.contains('offsetCup')).toBe(false); + + // Check if the h4 element contains the correct text + const cupText = getByTestId('cup-text'); + expect(document.body.contains(cupText)).toBe(true); + expect(cupText.textContent).toBe(''); + }); + + it('renders the cup div', () => { + const rank = { + className: 'bronze', + text: 'Bronze Cup', + }; + + const { getByTestId } = render(); + + const cupElement = getByTestId('cup-animation'); + + // Check if the cup div is present + expect(document.body.contains(cupElement)).toBe(true); + }); +}); diff --git a/frontend/src/components/Cup/Cup.tsx b/frontend/src/components/Cup/Cup.tsx new file mode 100644 index 000000000..060aee88b --- /dev/null +++ b/frontend/src/components/Cup/Cup.tsx @@ -0,0 +1,22 @@ +import classNames from "classnames"; + +export interface CupProps { + className: string | "diamond" | "platinum" | "gold" | "silver" | "bronze" | "plastic"; + text: string; +} + + +// Rank shows a decorated representation of a rank +const Rank = ({ className, text }: CupProps) => ( +
+
+

{text}

+
+); + +export default Rank; diff --git a/frontend/src/components/ExperimentCollection/ExperimentCollection.tsx b/frontend/src/components/ExperimentCollection/ExperimentCollection.tsx index 885aee954..de3340690 100644 --- a/frontend/src/components/ExperimentCollection/ExperimentCollection.tsx +++ b/frontend/src/components/ExperimentCollection/ExperimentCollection.tsx @@ -36,7 +36,6 @@ const ExperimentCollection = ({ match }: ExperimentCollectionProps) => { const displayDashboard = experimentCollection?.dashboard.length; const showConsent = experimentCollection?.consent; const totalScore = experimentCollection?.totalScore; - const score = experimentCollection?.score; if (experimentCollection?.theme) { setTheme(experimentCollection.theme); @@ -82,7 +81,7 @@ const ExperimentCollection = ({ match }: ExperimentCollectionProps) => {
} /> - } /> + } /> {experimentCollection.theme?.footer && (