Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cspell/custom-dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ gunicorn
hackathon
heroui
hsl
ics
igoat
inlinehilite
isanori
Expand Down
48 changes: 48 additions & 0 deletions frontend/__tests__/e2e/pages/CalendarButton.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import fs from 'node:fs'
import { mockHomeData } from '@e2e/data/mockHomeData'
import { test, expect } from '@playwright/test'
import slugify from 'utils/slugify'

test.describe('Calendar Export Functionality', () => {
test.beforeEach(async ({ page }) => {
await page.route('**/graphql/', async (route) => {
await route.fulfill({
status: 200,
json: mockHomeData,
})
})
await page.context().addCookies([
{
name: 'csrftoken',
value: 'abc123',
domain: 'localhost',
path: '/',
},
])
await page.goto('/')
})

test('should download a valid ICS file when clicked', async ({ page }) => {
const calendarButton = page.getByRole('button', { name: 'Add Event 1 to Calendar' })
await expect(calendarButton).toBeVisible()

const downloadPromise = page.waitForEvent('download')

await calendarButton.click()

const download = await downloadPromise

expect(download.suggestedFilename()).toBe(`${slugify('Event 1')}.ics`)

const path = await download.path()
expect(path, 'Expected Playwright to provide a download path').toBeTruthy()
const content = fs.readFileSync(path, 'utf-8')

expect(content).toContain('BEGIN:VCALENDAR')
expect(content).toContain('VERSION:2.0')
expect(content).toContain('BEGIN:VEVENT')

expect(content).toContain('SUMMARY:')
expect(content).toContain('END:VCALENDAR')
})
})
4 changes: 2 additions & 2 deletions frontend/__tests__/e2e/pages/Home.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ test.describe('Home Page', () => {
await expect(page.getByRole('heading', { name: 'Upcoming Events' })).toBeVisible({
timeout: 10000,
})
await expect(page.getByRole('button', { name: 'Event 1' })).toBeVisible()
await expect(page.getByRole('button', { name: 'Event 1', exact: true })).toBeVisible()
await expect(page.getByText('Apr 5 — 6, 2025')).toBeVisible()
await page.getByRole('button', { name: 'Event 1' }).click()
await page.getByRole('button', { name: 'Event 1', exact: true }).click()
})

test('should have stats', async ({ page }) => {
Expand Down
Loading