-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
67 additions
and
5 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
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,53 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('Add and then delete a favorite stop.', async ({ page, context }) => { | ||
// Navigate to favorites tab | ||
await page.goto('/') | ||
await page.getByRole('listitem', { name: 'Favorites' }).getByRole('button').click() | ||
|
||
// Expect empty state | ||
await expect(page.getByRole('heading', { name: 'Favorite Stops' })).toBeVisible() | ||
await expect(page.getByText('You can select up to 3')).toBeVisible() | ||
|
||
// Change to bus selector tab | ||
await page.getByRole('listitem', { name: 'Selector' }).getByRole('button').click() | ||
await expect(page.getByRole('heading', { name: 'Bus Selector' })).toBeVisible() | ||
|
||
// Select first agency, click first stop | ||
await page.getByText('Agency').click() | ||
await page.getByRole('option').first().click() | ||
await page.getByText('Stop', { exact: true }).click() | ||
|
||
// Save stop option text, click favorite icon, change to favorites tab | ||
const stopOption = page.getByRole('option').first() | ||
const stopOptionText = await stopOption.innerText() | ||
await stopOption.click() | ||
await page.getByTestId('favoriteStop').click() | ||
await page.getByRole('listitem', { name: 'Favorites' }).getByRole('button').click() | ||
|
||
// Expect empty state to be replaced with a corresponding favorite | ||
await expect(page.getByText('You can select up to 3')).not.toBeVisible() | ||
const favLink = page.getByTestId('favoriteLink') | ||
const favLinkText = await favLink.innerText() | ||
expect(stopOptionText).toEqual(favLinkText) | ||
|
||
// Expect localStorage to contain the favorite | ||
let storage = await context.storageState() | ||
let favoritesEntry = storage.origins[0].localStorage.find( | ||
entry => entry.name === 'busmap-favorites' | ||
) | ||
expect(favoritesEntry).toBeTruthy() | ||
let favorites = JSON.parse(favoritesEntry?.value ?? 'null') | ||
expect(favorites.length).toEqual(1) | ||
expect(favorites[0].stop.title).toEqual(stopOptionText) | ||
|
||
// Delete the favorite and restore the empty state | ||
await page.getByLabel('Delete').getByRole('button').click() | ||
await expect(page.getByText('You can select up to 3')).toBeVisible() | ||
storage = await context.storageState() | ||
favoritesEntry = storage.origins[0].localStorage.find( | ||
entry => entry.name === 'busmap-favorites' | ||
) | ||
favorites = JSON.parse(favoritesEntry?.value ?? 'null') | ||
expect(favorites.length).toEqual(0) | ||
}) |
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,4 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"include": ["*/*.spec.ts"] | ||
} |