|
| 1 | +import { test, expect, chromium } from "@playwright/test" |
| 2 | +import login from "./utils/login" |
| 3 | + |
| 4 | +test.describe("Authenticated Dispatch App", () => { |
| 5 | + test.beforeEach(async ({ page }) => { |
| 6 | + await login(page) |
| 7 | + }) |
| 8 | + test("Should allow me to report an incident", async ({ page }) => { |
| 9 | + /* The ability to report an incident is one of the most critical |
| 10 | + user stories in the Dispatch application. */ |
| 11 | + |
| 12 | + const project = "default" |
| 13 | + const type = "Denial of Service" |
| 14 | + const priority = "Low" |
| 15 | + |
| 16 | + await page.goto("./default/incidents/report") |
| 17 | + |
| 18 | + // Title |
| 19 | + await page.getByLabel("Title").click() |
| 20 | + await page.getByLabel("Title").fill("Incident Test Created by Playwright") |
| 21 | + |
| 22 | + // Description |
| 23 | + await page.getByLabel("Description").click() |
| 24 | + await page.getByLabel("Description").fill("test") |
| 25 | + |
| 26 | + // Project |
| 27 | + await page.getByRole("combobox").filter({ hasText: "Project" }).locator("i").click() |
| 28 | + await page.getByText(project, { exact: true }).click() |
| 29 | + |
| 30 | + // Type |
| 31 | + await page.getByRole("button", { name: "Type" }).click() |
| 32 | + |
| 33 | + // Soft check that the 'Load More' selector is available upon opening the Project dropdown |
| 34 | + await expect |
| 35 | + .soft( |
| 36 | + page.getByText("Load More"), |
| 37 | + "The 'Load More' selector should be visible when there are more than 5 options in the Tags combobox." |
| 38 | + ) |
| 39 | + .toBeVisible() |
| 40 | + |
| 41 | + // Click load more |
| 42 | + await page.getByText("Load More").click() |
| 43 | + |
| 44 | + /* Project Options: |
| 45 | +
|
| 46 | + Other |
| 47 | + Denial of Service |
| 48 | + Malware |
| 49 | + Customer Data |
| 50 | + Employee Investigation |
| 51 | + Vulnerability |
| 52 | + */ |
| 53 | + |
| 54 | + // Click a type to select it |
| 55 | + await page.getByText(type, { exact: true }).click() |
| 56 | + |
| 57 | + // Priority |
| 58 | + await page.getByRole("button", { name: "Priority" }).click() |
| 59 | + await page.getByText("Low").click() |
| 60 | + |
| 61 | + // Open the dropdown selection for the Tags field |
| 62 | + await page.getByRole("combobox").filter({ hasText: "Tags" }).locator("i").click() |
| 63 | + await page.getByText("default/ExampleTag").click() |
| 64 | + |
| 65 | + // Click out the dialog |
| 66 | + await page |
| 67 | + .locator("span") |
| 68 | + .filter({ |
| 69 | + hasText: "Report Incident If you suspect an incident and need help, please fill out this f", |
| 70 | + }) |
| 71 | + .click() |
| 72 | + |
| 73 | + // Submit the form |
| 74 | + await page.getByRole("button", { name: "Submit" }).click() |
| 75 | + |
| 76 | + // Wait for the incident to be created |
| 77 | + await page.waitForLoadState("networkidle") |
| 78 | + |
| 79 | + // Soft validate that we get redirected to the incident submission form |
| 80 | + await expect |
| 81 | + .soft(page) |
| 82 | + .toHaveURL( |
| 83 | + encodeURI( |
| 84 | + `./default/incidents/report?project=${project}&incident_priority=${priority}&incident_type=${type}` |
| 85 | + ) |
| 86 | + ) |
| 87 | + |
| 88 | + // Soft validate that we recieve the report form. |
| 89 | + await expect |
| 90 | + .soft( |
| 91 | + page.getByText("Incident Report"), |
| 92 | + "'Incident Report' text not visible on page after submission of incident report." |
| 93 | + ) |
| 94 | + .toBeVisible() |
| 95 | + |
| 96 | + // Soft validate that we recieve the report form. |
| 97 | + await expect |
| 98 | + .soft( |
| 99 | + page.getByText( |
| 100 | + "This page will be populated with incident resources as they are created (if available). If you have any questions, please feel free to review the Frequently Asked Questions (FAQ) document linked below, and/or reach out to the listed Incident Commander." |
| 101 | + ), |
| 102 | + "'Incident Report: Description' not visible on page after submission of incident report." |
| 103 | + ) |
| 104 | + .toBeVisible() |
| 105 | + }) |
| 106 | +}) |
0 commit comments