diff --git a/.gitignore b/.gitignore index b1816690d..4360c9a37 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ _static .env.development.local .env.test.local .env.production.local +.env npm-debug.log* yarn-debug.log* diff --git a/tests/e2e/submit-testimony.spec.ts b/tests/e2e/submit-testimony.spec.ts new file mode 100644 index 000000000..0b7f21e20 --- /dev/null +++ b/tests/e2e/submit-testimony.spec.ts @@ -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() + }) +}) diff --git a/tests/integration/exportedTestData/auth_export/accounts.json b/tests/integration/exportedTestData/auth_export/accounts.json index f932a8f3b..df84363a9 100644 --- a/tests/integration/exportedTestData/auth_export/accounts.json +++ b/tests/integration/exportedTestData/auth_export/accounts.json @@ -1 +1 @@ -{"kind":"identitytoolkit#DownloadAccountResponse","users":[{"localId":"05lcy6YQrPvPRvVPlZFbCA0O81TF","lastLoginAt":"1682192783216","emailVerified":true,"email":"testadmin@example.com","salt":"fakeSaltQ0CeYd5UyEmOq5MWLcnP","passwordHash":"fakeHash:salt=fakeSaltQ0CeYd5UyEmOq5MWLcnP:password=password","passwordUpdatedAt":1682192769498,"validSince":"1682192769","createdAt":"1682192575545","providerUserInfo":[{"providerId":"password","email":"testadmin@example.com","federatedId":"testadmin@example.com","rawId":"testadmin@example.com","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":"test@example.com","federatedId":"test@example.com","rawId":"test@example.com","displayName":"test1","photoUrl":""}],"validSince":"1682192348","email":"test@example.com","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":"test3@example.com","federatedId":"test3@example.com","rawId":"test3@example.com","displayName":"test2","photoUrl":""}],"validSince":"1682192348","email":"test3@example.com","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":"test2@example.com","federatedId":"test2@example.com","rawId":"test2@example.com","displayName":"test3","photoUrl":""}],"validSince":"1682192348","email":"test2@example.com","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":"test4@example.com","federatedId":"test4@example.com","rawId":"test4@example.com","displayName":"test4","photoUrl":""}],"validSince":"1682192348","email":"test4@example.com","emailVerified":false,"disabled":false,"customAttributes":"{\"role\":\"user\"}"}]} \ No newline at end of file +{"kind":"identitytoolkit#DownloadAccountResponse","users":[{"localId":"05lcy6YQrPvPRvVPlZFbCA0O81TF","lastLoginAt":"1682192783216","emailVerified":true,"email":"testadmin@example.com","salt":"fakeSaltQ0CeYd5UyEmOq5MWLcnP","passwordHash":"fakeHash:salt=fakeSaltQ0CeYd5UyEmOq5MWLcnP:password=password","passwordUpdatedAt":1682192769498,"validSince":"1682192769","createdAt":"1682192575545","providerUserInfo":[{"providerId":"password","email":"testadmin@example.com","federatedId":"testadmin@example.com","rawId":"testadmin@example.com","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":"test@example.com","federatedId":"test@example.com","rawId":"test@example.com","displayName":"test1","photoUrl":""}],"validSince":"1682192348","email":"test@example.com","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":"test3@example.com","federatedId":"test3@example.com","rawId":"test3@example.com","displayName":"test2","photoUrl":""}],"validSince":"1682192348","email":"test3@example.com","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":"test2@example.com","federatedId":"test2@example.com","rawId":"test2@example.com","displayName":"test3","photoUrl":""}],"validSince":"1682192348","email":"test2@example.com","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":"test4@example.com","federatedId":"test4@example.com","rawId":"test4@example.com","displayName":"test4","photoUrl":""}],"validSince":"1682192348","email":"test4@example.com","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":"verifieduser@example.com","federatedId":"verifieduser@example.com","rawId":"verifieduser@example.com","displayName":"verified","photoUrl":""}],"validSince":"1682192348","email":"verifieduser@example.com","emailVerified":true,"disabled":false,"customAttributes":"{\"role\":\"user\"}"}]} \ No newline at end of file