browsertrix/frontend/tests/login.spec.ts
Emma Segal-Grossman b5fe5551c5
Ensure linting & formatting runs in CI (#1512)
Makes sure code quality stays high by checking that code is linted &
formatted in CI.

### Reason

Frustration — so that [things like
this](https://github.com/webrecorder/browsertrix-cloud/pull/1500#issuecomment-1920087667)
don't happen in the future. I tried to merge `main` into a branch to get
it up to date with main, and main isn't totally formatted or linted
properly, and then formatting the codebase introduced a whole bunch of
unrelated changes. Running a formatter or linter shouldn't cause
unrelated code changes, and `main` should always be in a correct state
in terms of linting and formatting.

### Testing

- [x] Test run with failing lint checks errors:
https://github.com/webrecorder/browsertrix-cloud/actions/runs/7733354321/job/21085236200
- [x] Test run with failing formatting check errors:
https://github.com/webrecorder/browsertrix-cloud/actions/runs/7733501666/job/21085717519
- [x] Test run with both passing lint & formatting checks passes:
https://github.com/webrecorder/browsertrix-cloud/actions/runs/7733529142/job/21085796727
2024-01-31 18:25:44 -05:00

28 lines
906 B
TypeScript

import { chromium } from "playwright";
import { test } from "@playwright/test";
test("test", async ({ baseURL }) => {
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext();
const page = await context.newPage();
try {
await page.goto(baseURL!);
await page.waitForLoadState("load");
await page.waitForSelector('input[name="username"]');
await page.click('input[name="username"]');
await page.fill('input[name="username"]', "dev@webrecorder.net");
await page.click('input[name="password"]');
const devPassword = process.env.DEV_PASSWORD;
if (!devPassword) {
throw new Error(
"DEV_PASSWORD environment variable is not defined or null."
);
}
await page.fill('input[name="password"]', devPassword);
await page.click('a:has-text("Log In")');
} finally {
await browser.close();
}
});