-
Notifications
You must be signed in to change notification settings - Fork 672
test(website): keep upcoming-events coverage when nothing is scheduled #15160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
christian-byrne
merged 3 commits into
main
from
glary/website-upcoming-events-test-resilience
Aug 23, 2026
+130
−6
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
94 changes: 94 additions & 0 deletions
94
apps/website/src/templates/events/UpcomingEventsSection.test.ts
This file contains hidden or 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,94 @@ | ||
| // @vitest-environment happy-dom | ||
| import { render, screen } from '@testing-library/vue' | ||
| import { describe, expect, it, vi } from 'vitest' | ||
|
|
||
| import type * as EventsData from '../../data/events' | ||
|
|
||
| import UpcomingEventsSection from './UpcomingEventsSection.vue' | ||
|
|
||
| // `upcomingEvents` is derived from the wall clock, so it empties out once the | ||
| // newest configured event has ended and the e2e coverage of these rows goes | ||
| // quiet with it. Stubbing the list keeps the row markup, localization, and | ||
| // link targets covered whatever the date and whatever happens to be scheduled. | ||
| const { streamedEvent, externalEvent } = vi.hoisted(() => ({ | ||
| streamedEvent: { | ||
| id: 'streamed-event', | ||
| category: 'livestream', | ||
| title: { en: 'Streamed Event', 'zh-CN': '直播活动' }, | ||
| description: { en: 'Watch it live.', 'zh-CN': '在线观看。' }, | ||
| location: { en: 'Online', 'zh-CN': '线上' }, | ||
| dateLabel: { | ||
| en: 'September 1, 2026 · 10AM PT', | ||
| 'zh-CN': '2026年9月1日 · 上午10点(PT)' | ||
| }, | ||
| startDateTime: '2026-09-01T10:00:00-07:00', | ||
| liveVideoId: 'live123' | ||
| } satisfies EventsData.ComfyEvent, | ||
| externalEvent: { | ||
| id: 'external-event', | ||
| category: 'community', | ||
| title: { en: 'External Event', 'zh-CN': '外部活动' }, | ||
| description: { en: 'Hosted elsewhere.', 'zh-CN': '由他方举办。' }, | ||
| location: { en: 'San Francisco', 'zh-CN': '旧金山' }, | ||
| dateLabel: { en: 'September 8, 2026', 'zh-CN': '2026年9月8日' }, | ||
| startDateTime: '2026-09-08T10:00:00-07:00', | ||
| link: { | ||
| href: { en: 'https://lu.ma/comfy-sf', 'zh-CN': 'https://lu.ma/comfy-sf' }, | ||
| newTab: true | ||
| } | ||
| } satisfies EventsData.ComfyEvent | ||
| })) | ||
|
|
||
| vi.mock('../../data/events', async (importOriginal) => ({ | ||
| ...(await importOriginal<typeof EventsData>()), | ||
| upcomingEvents: [streamedEvent, externalEvent] | ||
| })) | ||
|
|
||
| describe('UpcomingEventsSection', () => { | ||
| it('renders a row per upcoming event with its title, blurb, location and date', () => { | ||
| render(UpcomingEventsSection) | ||
|
|
||
| const rows = screen.getAllByRole('listitem') | ||
| expect(rows).toHaveLength(2) | ||
|
|
||
| for (const [index, event] of [streamedEvent, externalEvent].entries()) { | ||
| const row = rows[index] | ||
| expect(row.textContent).toContain(event.title.en) | ||
| expect(row.textContent).toContain(event.description.en) | ||
| expect(row.textContent).toContain(event.location.en) | ||
| expect(row.textContent).toContain(event.dateLabel.en) | ||
| } | ||
| }) | ||
|
|
||
| it('links streamed events to their own page and the rest straight out', () => { | ||
| render(UpcomingEventsSection) | ||
|
|
||
| const streamedLink = screen.getByRole('link', { | ||
| name: `${streamedEvent.title.en} — Livestream` | ||
| }) | ||
| expect(streamedLink.getAttribute('href')).toBe('/events/streamed-event') | ||
| expect(streamedLink.getAttribute('target')).toBeNull() | ||
|
|
||
| const externalLink = screen.getByRole('link', { | ||
| name: `${externalEvent.title.en} — Livestream` | ||
| }) | ||
| expect(externalLink.getAttribute('href')).toBe(externalEvent.link.href.en) | ||
| expect(externalLink.getAttribute('target')).toBe('_blank') | ||
| expect(externalLink.getAttribute('rel')).toBe('noopener noreferrer') | ||
| }) | ||
|
|
||
| it('localizes rows and event-page links for the zh-CN page', () => { | ||
| render(UpcomingEventsSection, { props: { locale: 'zh-CN' } }) | ||
|
|
||
| expect(screen.getByText(streamedEvent.title['zh-CN'])).toBeTruthy() | ||
| expect(screen.getByText(streamedEvent.dateLabel['zh-CN'])).toBeTruthy() | ||
| expect(screen.queryByText(streamedEvent.title.en)).toBeNull() | ||
|
|
||
| const streamedLink = screen.getByRole('link', { | ||
| name: `${streamedEvent.title['zh-CN']} — 直播` | ||
| }) | ||
| expect(streamedLink.getAttribute('href')).toBe( | ||
| '/zh-CN/events/streamed-event' | ||
| ) | ||
| }) | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.