-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1183 from weather-gov/eg-757-alert-url-parsing
Alert URL parsing (and new e2e testing setup)
- Loading branch information
Showing
9 changed files
with
624 additions
and
272 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
291 changes: 89 additions & 202 deletions
291
tests/api/data/testing/alerts/active__status=actual&area=AR.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,59 @@ | ||
/* eslint-disable no-await-in-loop, no-plusplus */ | ||
const { test, expect } = require("@playwright/test"); | ||
|
||
const { describe, beforeEach } = test; | ||
|
||
describe("Alerts e2e tests", () => { | ||
beforeEach(async ({ page }) => { | ||
await page.goto("http://localhost:8081/play/testing"); | ||
await page.goto("/point/34.749/-92.275"); | ||
}); | ||
|
||
test("The correct number of alerts show on the page", async ({ page }) => { | ||
const alertAccordions = await page.locator("weathergov-alerts div.usa-accordion").all(); | ||
expect(alertAccordions).toHaveLength(6); | ||
}); | ||
|
||
test("All alert accordions are open by default", async ({ page }) => { | ||
const alertAccordions = await page.locator('weathergov-alerts div.usa-accordion button[aria-expanded="true"]').all(); | ||
expect(alertAccordions).toHaveLength(6); | ||
}); | ||
|
||
test("Clicking the alert accordion buttons closes them", async ({ page }) => { | ||
const alertAccordions = page.locator("weathergov-alerts div.usa-accordion button"); | ||
for(let i = 0; i < await alertAccordions.count(); i++){ | ||
await alertAccordions.nth(i).click(); | ||
await expect(alertAccordions.nth(i)).toHaveAttribute("aria-expanded", "false"); | ||
} | ||
}); | ||
|
||
describe("Parsed URLs in alerts", () => { | ||
test("Should not find a link wrapping the non-gov url", async ({ page }) => { | ||
const containingText = page.locator("weathergov-alerts").getByText("www.your-power-company.com/outages"); | ||
await expect(containingText).toHaveCount(1); | ||
|
||
const link = page.locator('a[href="www.your-power-company.com/outages"]'); | ||
await expect(link).toHaveCount(0); | ||
}); | ||
|
||
test("Should find a link wrapping the external url, and should have the correct class", async ({ page }) => { | ||
const containingText = page.locator("weathergov-alerts").getByText("https://transportation.gov/safe-travels"); | ||
await expect(containingText).toHaveCount(1); | ||
|
||
const link = page.getByRole("link").filter({hasText: "https://transportation.gov/safe-travels"}); | ||
await expect(link).toHaveCount(1); | ||
await expect(link).toHaveAttribute("href", "https://transportation.gov/safe-travels"); | ||
await expect(link).toHaveClass(/usa-link--external/); | ||
}); | ||
|
||
test("Should find a link wrapping the inernal url, and should have the correct class", async ({ page }) => { | ||
const containingText = page.locator("weathergov-alerts").getByText("https://weather.gov/your-office"); | ||
await expect(containingText).toHaveCount(1); | ||
|
||
const link = page.getByRole("link").filter({hasText: "https://weather.gov/your-office"}); | ||
await expect(link).toHaveCount(1); | ||
await expect(link).toHaveAttribute("href", "https://weather.gov/your-office"); | ||
await expect(link).not.toHaveClass(/usa-link--external/); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.