63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import {
|
|
captureBrowserFailures,
|
|
gotoLiveView,
|
|
projectEmail,
|
|
registerAndConfirm,
|
|
} from "./helpers";
|
|
|
|
test("request location picker separates approximate, exact, and hidden disclosure", async ({
|
|
browser,
|
|
request,
|
|
}, testInfo) => {
|
|
const user = await registerAndConfirm(
|
|
browser,
|
|
request,
|
|
projectEmail("location-picker", testInfo.project.name),
|
|
"Location Picker",
|
|
);
|
|
const assertBrowserClean = captureBrowserFailures(user.page);
|
|
const origin = new URL(process.env.BASE_URL!).origin;
|
|
|
|
await user.context.grantPermissions(["geolocation"], { origin });
|
|
await user.context.setGeolocation({
|
|
latitude: 50.450123,
|
|
longitude: 30.523456,
|
|
accuracy: 5,
|
|
});
|
|
await gotoLiveView(user.page, "/requests/new");
|
|
|
|
const workspace = user.page.locator("#request-location-workspace");
|
|
const latitude = workspace.locator("#request-latitude");
|
|
const longitude = workspace.locator("#request-longitude");
|
|
|
|
await workspace.getByRole("button", { name: "Use my location" }).click();
|
|
await expect(workspace.locator("#request-location-status")).toHaveText(
|
|
"Approximate area selected. Your exact position is not stored.",
|
|
);
|
|
await expect(latitude).not.toHaveValue("50.450123");
|
|
await expect(longitude).not.toHaveValue("30.523456");
|
|
|
|
await workspace
|
|
.locator('input[name="help_request[location_visibility]"][value="exact_public"]')
|
|
.check();
|
|
await expect(workspace.getByText("This point is public")).toBeVisible();
|
|
await workspace.getByRole("button", { name: "Use my location" }).click();
|
|
await expect(workspace.locator("#request-location-status")).toHaveText(
|
|
"Exact public point selected.",
|
|
);
|
|
await expect(latitude).toHaveValue("50.450123");
|
|
await expect(longitude).toHaveValue("30.523456");
|
|
|
|
await workspace
|
|
.locator('input[name="help_request[location_visibility]"][value="hidden"]')
|
|
.check();
|
|
await expect(workspace.getByRole("heading", { name: "No coordinates will be stored" }))
|
|
.toBeVisible();
|
|
await expect(latitude).toHaveValue("");
|
|
await expect(longitude).toHaveValue("");
|
|
|
|
assertBrowserClean();
|
|
await user.context.close();
|
|
});
|