Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
JuroUhlar committed Jan 31, 2024
1 parent d277329 commit 56b8f2e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
13 changes: 13 additions & 0 deletions e2e/home.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,17 @@ test.describe('Home page', () => {
const cards = await page.getByTestId(TEST_IDS.homepageCard.useCaseTitle);
expect(await cards.count()).toBeGreaterThan(5);
});

test('Entire cards should be clickable, clicking on the description or image should take you to the use case', async ({
page,
}) => {
await page.goto('/');

await page.getByTestId(TEST_IDS.homepageCard.useCaseDescription).first().click({ force: true });
await expect(page).toHaveURL('/playground');
await page.goBack();

await page.getByTestId(TEST_IDS.homepageCard.useCaseIcon).first().click({ force: true });
await expect(page).toHaveURL('/playground');
});
});
2 changes: 2 additions & 0 deletions src/client/testIDs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const TEST_IDS = {
},
homepageCard: {
useCaseTitle: 'useCaseTitle',
useCaseDescription: 'useCaseDescription',
useCaseIcon: 'useCaseIcon',
},
loanRisk: {
monthlyInstallmentValue: 'monthlyInstallmentValue',
Expand Down
9 changes: 7 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ export default function Index() {
{HOMEPAGE_CARDS.map((card) => (
<div className={styles.useCaseCard} key={card.url}>
<div>
<Image src={card.iconSvg} alt="" className={styles.useCaseIcon} />
<Image
src={card.iconSvg}
alt=""
className={styles.useCaseIcon}
data-testid={TEST_IDS.homepageCard.useCaseIcon}
/>
<Link className={styles.useCaseTitle} data-testid={TEST_IDS.homepageCard.useCaseTitle} href={card.url}>
{card.title}
</Link>
<div className={styles.useCaseDescription}>
<div className={styles.useCaseDescription} data-testid={TEST_IDS.homepageCard.useCaseDescription}>
{card.descriptionHomepage?.map((line, i) => <Fragment key={i}>{line}</Fragment>)}
</div>
</div>
Expand Down

0 comments on commit 56b8f2e

Please sign in to comment.