|
| 1 | +import { expect } from "@playwright/test"; |
| 2 | +import { capitalizeFirstLetter, getUpcomingEvents, test } from "./base"; |
| 3 | +import { describe } from "node:test"; |
| 4 | + |
| 5 | +describe("Events tests", () => { |
| 6 | + test("A user can login and view the upcoming events", async ({ |
| 7 | + page, |
| 8 | + becomeUser, |
| 9 | + }) => { |
| 10 | + await becomeUser(page); |
| 11 | + await page.locator('a').filter({ hasText: 'Events' }).click(); |
| 12 | + await expect(page.getByRole('heading')).toContainText('Core Management Service (NonProd)'); |
| 13 | + await expect(page.getByRole('button', { name: 'New Calendar Event' })).toBeVisible(); |
| 14 | + await expect(page.getByRole('button', { name: 'Show Previous Events' })).toBeVisible(); |
| 15 | + |
| 16 | + const table = page.getByTestId('events-table'); |
| 17 | + await expect(table).toBeVisible(); |
| 18 | + |
| 19 | + const rows = await table.locator('tbody tr').all(); |
| 20 | + const expectedTableData = await getUpcomingEvents(); |
| 21 | + |
| 22 | + for (let i = 0; i < rows.length; i++) { |
| 23 | + const row = rows[i]; |
| 24 | + const expectedData = expectedTableData[i]; |
| 25 | + |
| 26 | + const title = await row.locator('td:nth-child(1)').innerText(); |
| 27 | + const location = await row.locator('td:nth-child(4)').innerText(); |
| 28 | + const description = await row.locator('td:nth-child(5)').innerText(); |
| 29 | + const host = await row.locator('td:nth-child(6)').innerText(); |
| 30 | + const featured = await row.locator('td:nth-child(7)').innerText(); |
| 31 | + const repeats = await row.locator('td:nth-child(8)').innerText(); |
| 32 | + |
| 33 | + expect(title).toEqual(expectedData.title); |
| 34 | + expect(location).toEqual(expectedData.location); |
| 35 | + expect(description).toEqual(expectedData.description); |
| 36 | + expect(host).toEqual(expectedData.host); |
| 37 | + expect(featured).toEqual(expectedData.featured ? "Yes" : "No"); |
| 38 | + expect(repeats).toEqual(capitalizeFirstLetter(expectedData.repeats)); |
| 39 | + } |
| 40 | + |
| 41 | + expect(page.url()).toEqual("https://manage.qa.acmuiuc.org/events/manage"); |
| 42 | + }); |
| 43 | +}); |
0 commit comments