New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create first e2e tests for cert creation #28
Merged
Merged
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9c7f641
Run tests+checks on push/PR to all branches
DavidRV00 fbbd0cc
Allow e2e test retries both locally and in CI
DavidRV00 19e449a
Write e2e tests for cert creation
DavidRV00 fef526c
Ignore my local backup of .env
Telofy 6efa030
Hopefully prevent the first test/s from failing
Telofy 4629b1f
Expose the headless switch for easy switching
Telofy 9cf399e
Remove old sample test
Telofy 673957f
Delete the other sample test
DavidRV00 77556f5
Change test db to be different from normal db
DavidRV00 7bd18d6
Use port 3001 for tests
DavidRV00 45b0b63
Use separate service and network name for test docker
DavidRV00 6d4239c
Automatically use .env.test for running tests
DavidRV00 c26542c
Rename env var
Telofy c39bf96
Optimize .env.example for dev
Telofy e22eea8
Revert/restore Next Auth URL variable
Telofy fab32b4
Condense .env.test
Telofy 58166fa
Upgrade Playwright to fix bug #18865
Telofy d145d3b
Test the production build
Telofy 4487bed
Set more obvious dev defaults
Telofy 6746893
Fix variable name
Telofy 90322eb
Skip one page load
Telofy d5709f2
Remove separate run for PRs
Telofy File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { type Page, expect, test } from '@playwright/test' | ||
|
||
const proofText = 'https://forum.effectivealtruism.org' | ||
const counterfactualText = 'I would be sitting around doing nothing.' | ||
const descriptionText = 'Just a random description.' | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto('http://localhost:3000/') | ||
await page.click('text=Log in') | ||
await page.click('text=Sign in with Mock Login') | ||
}) | ||
|
||
test.describe('Create Certificate', () => { | ||
test('should allow creating new certificate', async ({ page }) => { | ||
const titleText = 'My test project 0001' | ||
|
||
await page.click('text=New project') | ||
await fillInDefaultValues(page, titleText) | ||
await page.locator('button:has-text("Submit")').click() | ||
|
||
// Check we've landed on the cert page. | ||
await expect(page).toHaveTitle(new RegExp('.*' + titleText + '.*')) | ||
}) | ||
|
||
test('should fill in all certificate values', async ({ page }) => { | ||
const titleText = 'My test project 0002' | ||
|
||
await page.click('text=New project') | ||
await fillInDefaultValues(page, titleText) | ||
await page.locator('button:has-text("Submit")').click() | ||
|
||
// Check we've landed on the cert page. | ||
await expect(page).toHaveTitle(new RegExp('.*' + titleText + '.*')) | ||
|
||
// Verify certificate values. | ||
await expect(page.getByRole('heading', { level: 1 })).toContainText( | ||
titleText | ||
) | ||
await expect(page.locator('text=Proof of ownership')).toHaveAttribute( | ||
'href', | ||
proofText | ||
) | ||
await page.locator('text=' + descriptionText).click() // Just clicking to verify it's there. | ||
}) | ||
}) | ||
|
||
async function fillInDefaultValues(page: Page, titleText: string) { | ||
await page.getByRole('textbox', { name: 'title' }).fill(titleText) | ||
await page.getByRole('textbox', { name: 'proof' }).fill(proofText) | ||
|
||
// TODO: start + end dates | ||
//await page.getByRole('textbox', { name: 'actionStart' }).fill(actionStartText) | ||
//await page.getByRole('textbox', { name: 'actionEnd' }).fill(actionEndText) | ||
|
||
await page | ||
.getByRole('textbox', { name: 'counterfactual' }) | ||
.fill(counterfactualText) | ||
|
||
// TODO: Tags | ||
//await page.selectOption('#tags', [{label: tagLabel}]) | ||
|
||
await page.locator(':nth-match(textarea, 1)').fill(descriptionText) | ||
|
||
// TODO: Advanced options | ||
|
||
await page.click('text=I will never sell these rights more than once') | ||
await page.click( | ||
'text=I am happy for this record to be publicly accessible forever' | ||
) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you already notice brittleness or is this just in case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed, pretty frequently, the Chromium browser will just sit and timeout after 30 seconds waiting for the first page to load. Retries have made it work.
Not sure why; Firefox and Webkit have not experienced this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, weird. Thanks!