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

Submit testimony e2e #1630

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ _static
.env.development.local
.env.test.local
.env.production.local
.env

npm-debug.log*
yarn-debug.log*
Expand Down
89 changes: 89 additions & 0 deletions tests/e2e/submit-testimony.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { test, expect } from "@playwright/test"
import { BillPage } from "./page_objects/billPage"
require("dotenv").config()

const testUserEmail = process.env.TEST_USERNAME
const testUserPassword = process.env.TEST_PASSWORD

// Ensure user credentials are set, otherwise throw an error
if (!testUserEmail || !testUserPassword) {
throw new Error(
"Admin credentials are not defined in the environment variables."
)
}

// test.describe("When user is not signed in", ()=>{
// test("should display login/signup button on a bill page", async({page})=>{

// })
// test("should redirect to login/signup when button is clicked", async({page})=>{

// })
// })

test.describe("Submit Testimony Flow for logged in User", () => {
test.beforeEach(async ({ page }) => {
// Log in the user
await page.goto("http://localhost:3000")
await page.getByRole("button", { name: "Log in / Sign up" }).click()
await page.getByRole("button", { name: "Sign In", exact: true }).click()
await page.fill('input[name="email"]', testUserEmail) // Use test user credentials
await page.fill('input[name="password"]', testUserPassword)
await page
.getByLabel("Sign In", { exact: true })
.getByRole("button", { name: "Sign In" })
.click()
const profileIcon = page.getByAltText("profile icon")
await expect(profileIcon).toBeVisible()
})

test("should navigate to a bill", async ({ page }) => {
// click browse bills
await page.getByRole("link", { name: "Browse Bills" }).first().click()

// select the first bill in the list
const firstBillLink = page.locator('a[href*="/bills"]').first()
await firstBillLink.click()
})

test("should successfully submit testimony", async ({
page
}) => {
// go to browse bills page
await page.goto("http://localhost:3000/bills")
await page.waitForSelector("li.ais-Hits-item a")

// click the first bill
const billpage = new BillPage(page)
await billpage.clickFirstBill()

// wait for URL change
await page.waitForURL(/\/bills\/\d+/)
console.log("URL changed to bill detail")
const currentUrl = page.url()
console.log("Current URL:", currentUrl)

// take screenshot
await page.screenshot({ path: "screenshot.png" })
console.log("Screenshot taken")


// click create testimony
await page.getByRole("button", { name: "Create Testimony"}).click()
await page.screenshot({ path: "screenshot.png" })

// expect to see all stance options
// const endorseRadioButton = page.getByLabel("Endorse")
// const neutralRadioButton = page.getByLabel("Neutral")
// const opposeRadioButton = page.getByLabel("Oppose")

// can click any stance option
// await endorseRadioButton.click({ force: true })
// await neutralRadioButton.click()
// await opposeRadioButton.click()

// clicking next with oppose selected
// const nextButton = page.getByRole("button", { name: "Next >>" })
// await nextButton.click()
})
})
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"kind":"identitytoolkit#DownloadAccountResponse","users":[{"localId":"05lcy6YQrPvPRvVPlZFbCA0O81TF","lastLoginAt":"1682192783216","emailVerified":true,"email":"[email protected]","salt":"fakeSaltQ0CeYd5UyEmOq5MWLcnP","passwordHash":"fakeHash:salt=fakeSaltQ0CeYd5UyEmOq5MWLcnP:password=password","passwordUpdatedAt":1682192769498,"validSince":"1682192769","createdAt":"1682192575545","providerUserInfo":[{"providerId":"password","email":"[email protected]","federatedId":"[email protected]","rawId":"[email protected]","displayName":"","photoUrl":""}],"lastRefreshAt":"2023-04-22T19:46:23.216Z","customAttributes":"{\"role\":\"admin\"}","displayName":"","photoUrl":""},{"localId":"PbB7tQy18F9bQXfI3AonVmFfQU1B","createdAt":"1647962671353","lastLoginAt":"1649530941158","displayName":"test1","photoUrl":"","passwordHash":"fakeHash:salt=fakeSaltuknPVwAkolkrDbQLJkUa:password=password","salt":"fakeSaltuknPVwAkolkrDbQLJkUa","passwordUpdatedAt":1682192348137,"providerUserInfo":[{"providerId":"password","email":"[email protected]","federatedId":"[email protected]","rawId":"[email protected]","displayName":"test1","photoUrl":""}],"validSince":"1682192348","email":"[email protected]","emailVerified":false,"disabled":false,"customAttributes":"{\"role\":\"user\"}"},{"localId":"VBN6dg70PGsupNvayJ2TPHPgydHz","createdAt":"1647962690530","lastLoginAt":"1647962870753","displayName":"test2","photoUrl":"","passwordHash":"fakeHash:salt=fakeSalt2x7l7erotVwSgZtSrvE4:password=password","salt":"fakeSalt2x7l7erotVwSgZtSrvE4","passwordUpdatedAt":1682192348137,"providerUserInfo":[{"providerId":"password","email":"[email protected]","federatedId":"[email protected]","rawId":"[email protected]","displayName":"test2","photoUrl":""}],"validSince":"1682192348","email":"[email protected]","emailVerified":false,"disabled":false,"customAttributes":"{\"role\":\"user\"}"},{"localId":"d6ZFKTVH8i4hglyv42wz8QDaKKxw","createdAt":"1647962684429","lastLoginAt":"1647962684429","displayName":"test3","photoUrl":"","passwordHash":"fakeHash:salt=fakeSalt9WTUIwt7hSmUtHEWukrL:password=password","salt":"fakeSalt9WTUIwt7hSmUtHEWukrL","passwordUpdatedAt":1682192348138,"providerUserInfo":[{"providerId":"password","email":"[email protected]","federatedId":"[email protected]","rawId":"[email protected]","displayName":"test3","photoUrl":""}],"validSince":"1682192348","email":"[email protected]","emailVerified":false,"disabled":false,"customAttributes":"{\"role\":\"user\"}"},{"localId":"jLPye8OfwlzAEGO6h10hs5mmVIDE","createdAt":"1647962700251","lastLoginAt":"1647962870743","displayName":"test4","photoUrl":"","passwordHash":"fakeHash:salt=fakeSaltExpNl9RTLBTTOfrDMtdM:password=password","salt":"fakeSaltExpNl9RTLBTTOfrDMtdM","passwordUpdatedAt":1682192348138,"providerUserInfo":[{"providerId":"password","email":"[email protected]","federatedId":"[email protected]","rawId":"[email protected]","displayName":"test4","photoUrl":""}],"validSince":"1682192348","email":"[email protected]","emailVerified":false,"disabled":false,"customAttributes":"{\"role\":\"user\"}"}]}
{"kind":"identitytoolkit#DownloadAccountResponse","users":[{"localId":"05lcy6YQrPvPRvVPlZFbCA0O81TF","lastLoginAt":"1682192783216","emailVerified":true,"email":"[email protected]","salt":"fakeSaltQ0CeYd5UyEmOq5MWLcnP","passwordHash":"fakeHash:salt=fakeSaltQ0CeYd5UyEmOq5MWLcnP:password=password","passwordUpdatedAt":1682192769498,"validSince":"1682192769","createdAt":"1682192575545","providerUserInfo":[{"providerId":"password","email":"[email protected]","federatedId":"[email protected]","rawId":"[email protected]","displayName":"","photoUrl":""}],"lastRefreshAt":"2023-04-22T19:46:23.216Z","customAttributes":"{\"role\":\"admin\"}","displayName":"","photoUrl":""},{"localId":"PbB7tQy18F9bQXfI3AonVmFfQU1B","createdAt":"1647962671353","lastLoginAt":"1649530941158","displayName":"test1","photoUrl":"","passwordHash":"fakeHash:salt=fakeSaltuknPVwAkolkrDbQLJkUa:password=password","salt":"fakeSaltuknPVwAkolkrDbQLJkUa","passwordUpdatedAt":1682192348137,"providerUserInfo":[{"providerId":"password","email":"[email protected]","federatedId":"[email protected]","rawId":"[email protected]","displayName":"test1","photoUrl":""}],"validSince":"1682192348","email":"[email protected]","emailVerified":false,"disabled":false,"customAttributes":"{\"role\":\"user\"}"},{"localId":"VBN6dg70PGsupNvayJ2TPHPgydHz","createdAt":"1647962690530","lastLoginAt":"1647962870753","displayName":"test2","photoUrl":"","passwordHash":"fakeHash:salt=fakeSalt2x7l7erotVwSgZtSrvE4:password=password","salt":"fakeSalt2x7l7erotVwSgZtSrvE4","passwordUpdatedAt":1682192348137,"providerUserInfo":[{"providerId":"password","email":"[email protected]","federatedId":"[email protected]","rawId":"[email protected]","displayName":"test2","photoUrl":""}],"validSince":"1682192348","email":"[email protected]","emailVerified":false,"disabled":false,"customAttributes":"{\"role\":\"user\"}"},{"localId":"d6ZFKTVH8i4hglyv42wz8QDaKKxw","createdAt":"1647962684429","lastLoginAt":"1647962684429","displayName":"test3","photoUrl":"","passwordHash":"fakeHash:salt=fakeSalt9WTUIwt7hSmUtHEWukrL:password=password","salt":"fakeSalt9WTUIwt7hSmUtHEWukrL","passwordUpdatedAt":1682192348138,"providerUserInfo":[{"providerId":"password","email":"[email protected]","federatedId":"[email protected]","rawId":"[email protected]","displayName":"test3","photoUrl":""}],"validSince":"1682192348","email":"[email protected]","emailVerified":false,"disabled":false,"customAttributes":"{\"role\":\"user\"}"},{"localId":"jLPye8OfwlzAEGO6h10hs5mmVIDE","createdAt":"1647962700251","lastLoginAt":"1647962870743","displayName":"test4","photoUrl":"","passwordHash":"fakeHash:salt=fakeSaltExpNl9RTLBTTOfrDMtdM:password=password","salt":"fakeSaltExpNl9RTLBTTOfrDMtdM","passwordUpdatedAt":1682192348138,"providerUserInfo":[{"providerId":"password","email":"[email protected]","federatedId":"[email protected]","rawId":"[email protected]","displayName":"test4","photoUrl":""}],"validSince":"1682192348","email":"[email protected]","emailVerified":false,"disabled":false,"customAttributes":"{\"role\":\"user\"}"},{"localId":"05lcy6YQrPvPRvVPlZFbCA0O81TM","createdAt":"1647962700251","lastLoginAt":"1647962870743","displayName":"verified","photoUrl":"","passwordHash":"fakeHash:salt=fakeSaltExpNl9RTLBTTOfrDMtdM:password=password","salt":"fakeSaltExpNl9RTLBTTOfrDMtdM","passwordUpdatedAt":1682192348138,"providerUserInfo":[{"providerId":"password","email":"[email protected]","federatedId":"[email protected]","rawId":"[email protected]","displayName":"verified","photoUrl":""}],"validSince":"1682192348","email":"[email protected]","emailVerified":true,"disabled":false,"customAttributes":"{\"role\":\"user\"}"}]}
Loading