Skip to content
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

[1647] add config for running e2e in ci #1638

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
29 changes: 29 additions & 0 deletions .github/workflows/repo-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,32 @@ jobs:
tests/integration/auth.test.ts
tests/integration/moderation.test.ts
tests/integration/profile.test.ts

e2e_tests:
name: E2E Tests
runs-on: ubuntu-latest
needs: check_code_quality
environment: dev

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-repo

- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: |
node_modules
key: modules-${{ hashFiles('package-lock.json') }}

- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn test:e2e:headless
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 3 additions & 1 deletion components/search/testimony/TestimonyHit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const TestimonyResult = ({ hit }: { hit: Hit<Testimony> }) => {
const isOrg = hit.authorRole === "organization"
const writtenBy =
isOrg || hit.public ? (
<Link href={`/profile?id=${hit.authorUid}`}>{hit.fullName}</Link>
<Link href={`/profile?id=${hit.authorUid}`}>
<span data-testid="author">{hit.fullName}</span>
</Link>
) : (
hit.fullName
)
Expand Down
3 changes: 2 additions & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export default defineConfig({
webServer: {
command: "yarn dev:up",
url: "http://localhost:3000/",
reuseExistingServer: !process.env.CI
reuseExistingServer: !process.env.CI,
timeout: 100000
}
})
7 changes: 7 additions & 0 deletions tests/e2e/adminPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ test.describe.serial("Admin Page", () => {
context = await browser.newContext()
page = await context.newPage()

console.log({
username: process.env.TEST_ADMIN_USERNAME,
pw: process.env.TEST_ADMIN_PASSWORD,
url: process.env.APP_API_URL,
ci: process.env.ci
})

// Fetch the admin credentials and application URL from the environment variables
const adminEmail = process.env.TEST_ADMIN_USERNAME
const adminPassword = process.env.TEST_ADMIN_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/browse-bills.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test.describe("Search result test", () => {

const queryFilter = await billpage.queryFilter

await expect(queryFilter).toContainText("query:")
await expect(queryFilter).toContainText("Query:")
await expect(queryFilter).toContainText(searchTerm)
})

Expand Down
22 changes: 10 additions & 12 deletions tests/e2e/testimony.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test.describe("Testimony Search", () => {
await testimonyPage.search(queryText)

const { queryFilterItem, resultsCountText } = testimonyPage
await expect(queryFilterItem).toContainText("query:")
await expect(queryFilterItem).toContainText("Query:")
await expect(queryFilterItem).toContainText(queryText)
await expect(resultsCountText).toBeVisible()
})
Expand Down Expand Up @@ -129,21 +129,19 @@ test.describe("Testimony Filtering", () => {
})

test("should filter by author", async ({ page }) => {
const writtenByText = await page
.getByText(/Written by/)
.first()
.textContent()
expect(writtenByText).toBeTruthy()

if (writtenByText) {
const authorName = writtenByText.slice(11)
const authorName = await page.getByTestId("author").first().textContent()
expect(authorName).toBeTruthy()

if (authorName) {
await page.getByRole("checkbox", { name: authorName }).check()
const testimonyPage = new TestimonyPage(page)
await expect(testimonyPage.authorFilterItem).toContainText(authorName)
const encodedAuthorName = encodeURIComponent(authorName).replace(
"'",
"%27"
)
await expect(page).toHaveURL(
new RegExp(
`.*authorDisplayName%5D%5B0%5D=${encodeURIComponent(authorName)}`
)
new RegExp(`.*authorDisplayName%5D%5B0%5D=${encodedAuthorName}`)
)
}
})
Expand Down
Loading