-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Playwright tests to be authenticated
The `GH_TOKEN` environment variable can be used both locally and in CI to avoid testing the GitHub OAuth flow (which is provided by the Octokit library and can therefore be assumed to be well tested). In local development the token can be retrieved by logging into Towtruck and then copying the value of the `Token` cookie. In CI, the correct value is automatically populated by GitHub Actions into a secret.
- Loading branch information
1 parent
cfd0649
commit 1309d80
Showing
6 changed files
with
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { test as setup } from '@playwright/test'; | ||
|
||
const USERNAME = process.env.PLAYWRIGHT_GITHUB_USERNAME; | ||
const PASSWORD = process.env.PLAYWRIGHT_GITHUB_PASSWORD; | ||
|
||
console.log(USERNAME, PASSWORD); | ||
|
||
setup('authenticate', async ({ page, baseURL }, testInfo) => { | ||
await page.goto(baseURL); | ||
await page.getByRole('button', { name: 'Login with GitHub' }).click(); | ||
|
||
await page.waitForURL(/https:\/\/github.com\/login/); | ||
|
||
await page.getByLabel('Username or email address').fill(USERNAME); | ||
await page.getByLabel('Password').fill(PASSWORD); | ||
|
||
await page.getByRole('button', { name: 'Sign in' }).click(); | ||
|
||
await page.waitForURL(baseURL); | ||
|
||
await page.context().storageState({ path: testInfo.outputPath('user.json') }); | ||
}); |
File renamed without changes.
Binary file not shown.
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