-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 46-jobs-page
- Loading branch information
Showing
29 changed files
with
517 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { test, expect, Locator } from '@playwright/test' | ||
|
||
/** Verifies visibility of the name, title, and photo | ||
* | ||
* @param card The Locator for the TeamMember Card | ||
* @param name The name to find | ||
* @param title The title to find, if defined | ||
*/ | ||
async function verifyTeamMemberCard(card: Locator, name: string, title?: string) { | ||
await expect(card.getByText(name)).toBeVisible() | ||
if (title) { | ||
await expect(card.getByText(title)).toBeVisible() | ||
} | ||
const photo = card.getByRole('img').first() | ||
await expect(photo).toBeVisible() | ||
await expect(photo).toHaveAttribute('alt-text', `${name} photo`) | ||
} | ||
|
||
test('shows the team in English', async ({ page }) => { | ||
await page.goto('/#/team') | ||
|
||
const teamContainer = page.getByLabel('team-container') | ||
|
||
const heading = teamContainer.getByText('✨ Leadership Team ✨') | ||
await expect(heading).toBeVisible() | ||
|
||
const cards = await teamContainer.getByLabel('team-member-card').all() | ||
expect(cards).toHaveLength(7) | ||
|
||
await verifyTeamMemberCard(cards[0], 'Ann Kilzer', 'Director') | ||
await verifyTeamMemberCard(cards[1], 'Paty Cortez', 'Director') | ||
await verifyTeamMemberCard(cards[2], 'Maria Tenorio', 'Lead') | ||
await verifyTeamMemberCard(cards[3], 'Daria Vazhenina', 'ML & Data Science Lead') | ||
await verifyTeamMemberCard(cards[4], 'Krizza Bullecer', 'Lead') | ||
await verifyTeamMemberCard(cards[5], 'Ania Nakayama', 'Lead') | ||
await verifyTeamMemberCard(cards[6], 'Aidan Fournier', 'Lead') | ||
|
||
// verify link | ||
const links = await page.getByLabel('link-wrapper').all() | ||
expect(links).toHaveLength(1) | ||
const annLink = links[0] | ||
await expect(annLink).toBeVisible() | ||
await expect(annLink).toHaveRole('link') | ||
await expect(annLink).toHaveAttribute('href', 'https://annkilzer.net') | ||
await expect(annLink).toHaveAttribute('target', '_blank') | ||
}) | ||
|
||
test('shows the team in Japanese', async ({ page, viewport }) => { | ||
await page.goto('/#/team') | ||
|
||
// switch locale to Japanese | ||
const hamburger = page.getByLabel('drawer-toggle-button') | ||
await hamburger.click() | ||
const japanese = page.getByLabel('drawer').getByText('日本語') | ||
await japanese.click() | ||
|
||
const teamContainer = page.getByLabel('team-container') | ||
|
||
// close the sidebar | ||
if (viewport && viewport.width < 600) { | ||
const closeButton = page.getByLabel('close-button') | ||
await closeButton.click() | ||
} else { | ||
await teamContainer.click({ force: true }) | ||
} | ||
|
||
const heading = teamContainer.getByText('✨ リーダーシップ・チーム ✨') | ||
await expect(heading).toBeVisible() | ||
|
||
const cards = await teamContainer.getByLabel('team-member-card').all() | ||
expect(cards).toHaveLength(7) | ||
|
||
await verifyTeamMemberCard(cards[0], 'キルザー·杏', 'ディレクター') | ||
await verifyTeamMemberCard(cards[1], 'Paty Cortez', 'ディレクター') | ||
await verifyTeamMemberCard(cards[2], 'Maria Tenorio', 'リード') | ||
await verifyTeamMemberCard(cards[3], 'バジェニナ・ダリヤ', 'ML&データサイエンス・リード') | ||
await verifyTeamMemberCard(cards[4], 'ブレサー クリザ', 'リード') | ||
await verifyTeamMemberCard(cards[5], 'Ania Nakayama', 'リード') | ||
await verifyTeamMemberCard(cards[6], 'エイデン・フォニエ', 'リード') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/components/OptionalLinkWrapper/OptionalLinkWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { FC, ReactNode } from 'react' | ||
|
||
interface OptionalLinkWrapperProps { | ||
url?: string | ||
children: ReactNode | ||
} | ||
|
||
/** | ||
* If url is falsy, returns children. If url is truthy, returns the component wrapped in a link | ||
*/ | ||
const OptionalLinkWrapper: FC<OptionalLinkWrapperProps> = ({ url, children }) => { | ||
if (url) { | ||
return <a href={url} target='_blank' rel="noreferrer" aria-label='link-wrapper'> | ||
{children} | ||
</a> | ||
} | ||
return children | ||
} | ||
|
||
export default OptionalLinkWrapper |
33 changes: 33 additions & 0 deletions
33
src/components/OptionalLinkWrapper/__test__/OptionalLinkWrapper.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { render } from '@/tests/customRender' | ||
import { screen } from '@testing-library/react' | ||
import OptionalLinkWrapper from '../OptionalLinkWrapper' | ||
|
||
|
||
describe('OptionalLinkWrapper', () => { | ||
const exampleURL = 'https://example.com' | ||
|
||
it('should render the link when URL is set', async () => { | ||
render(<OptionalLinkWrapper url={exampleURL}> | ||
<span>child</span> | ||
</OptionalLinkWrapper>) | ||
|
||
const link = await screen.findByRole('link') | ||
expect(link).toHaveAttribute('href', exampleURL) | ||
|
||
const child = await screen.findByText('child') | ||
expect(child).toBeVisible() | ||
}) | ||
|
||
it.each(['', undefined])('should render the child component when URL is %i', async (url: string | undefined) => { | ||
render(<OptionalLinkWrapper url={url}> | ||
<span>child</span> | ||
</OptionalLinkWrapper>) | ||
|
||
const child = await screen.findByText('child') | ||
expect(child).toBeVisible() | ||
|
||
const link = screen.queryByRole('link') | ||
expect(link).toBeNull() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 22 additions & 2 deletions
24
src/components/SideDrawer/__test__/TestDrawerContents.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { describe, expect, it, vi } from 'vitest' | ||
import { render } from '@/tests/customRender' | ||
import { screen } from '@testing-library/react' | ||
import DrawerContents from '../DrawerContents' | ||
import userEvent from '@testing-library/user-event' | ||
import useMediaQuery from '@mui/material/useMediaQuery' | ||
|
||
vi.mock('@mui/material/useMediaQuery', () => { | ||
return { | ||
default: vi.fn() | ||
} | ||
}) | ||
|
||
describe('DrawerContents', () => { | ||
it('should display the DrawerContents', async () => { | ||
render(<DrawerContents />) | ||
render(<DrawerContents closeDrawer={() => { }} />) | ||
const japanese = await screen.findByText('日本語') | ||
expect(japanese).toBeVisible() | ||
}) | ||
|
||
it('should call closeDrawer when clicking x on mobile viewport', async () => { | ||
const mock = vi.fn(() => { }) | ||
const user = userEvent.setup() | ||
vi.mocked(useMediaQuery).mockReturnValue(true) | ||
|
||
render(<DrawerContents closeDrawer={mock} />) | ||
const closeButton = await screen.findByLabelText('close-button') | ||
await user.click(closeButton) | ||
|
||
expect(mock).toHaveBeenCalled() | ||
}) | ||
|
||
it.todo('should show the NavLinks on mobile screens') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.