diff --git a/integration_test/lib/pages/representativesPage.ts b/integration_test/lib/pages/representativesPage.ts new file mode 100644 index 0000000..6112a32 --- /dev/null +++ b/integration_test/lib/pages/representativesPage.ts @@ -0,0 +1,79 @@ +import { Page, expect } from '@playwright/test'; + +const updateDelegateEmail = 'jamejones123@email.com'; +const updatedAlternateEmail = 'sallysue123@email.com'; + +export default class RepresentativesPage { + readonly updateDelegateBtn = this.page.getByTestId( + 'edit-representative-info-2' + ); + readonly saveDelegateInfoBtn = this.page.getByTestId( + 'save-representative-info-2' + ); + readonly updateAlternateBtn = this.page.getByTestId( + 'edit-representative-info-3' + ); + readonly saveAlternateBtn = this.page.getByTestId( + 'save-representative-info-3' + ); + readonly transferVotingPowerBtn = this.page.getByTestId( + 'edit-active-voter-1' + ); + readonly saveUpdatedVotingPowerBtn = this.page.getByTestId( + 'save-active-voter-1' + ); + + constructor(private readonly page: Page) {} + + async goto(): Promise { + await this.page.goto('/representatives/manage'); + } + + async updateDelegateProfile(): Promise { + await this.goto(); + await this.updateDelegateBtn.click(); + await this.page.getByRole('textbox').nth(1).fill(updateDelegateEmail); + await this.saveDelegateInfoBtn.click({ force: true }); + } + + async isDelegateUpdated(): Promise { + const representativeEmailList = await this.page + .locator('[data-field="email"]') + .allInnerTexts(); + expect(representativeEmailList).toContain(updateDelegateEmail); + } + + async updateAlternateProfile(): Promise { + await this.goto(); + await this.updateAlternateBtn.click(); + await this.page.getByRole('textbox').nth(1).fill(updatedAlternateEmail); + await this.saveAlternateBtn.click({ force: true }); + } + + async isAlternateUpdated(): Promise { + const representativeEmailList = await this.page + .locator('[data-field="email"]') + .allInnerTexts(); + expect(representativeEmailList).toContain(updatedAlternateEmail); + } + + async transferVotePowerToAlternate(): Promise { + await this.goto(); + await this.transferVotingPowerBtn.click(); + await this.page.getByRole('combobox').nth(1).click(); + await this.page + .getByRole('option', { name: 'Alternate' }) + .click({ force: true }); + await this.saveUpdatedVotingPowerBtn.click(); + } + + async transferVotePowerToDelegate(): Promise { + await this.goto(); + await this.transferVotingPowerBtn.click(); + await this.page.getByRole('combobox').nth(1).click(); + await this.page + .getByRole('option', { name: 'Delegate' }) + .click({ force: true }); + await this.saveUpdatedVotingPowerBtn.click(); + } +} diff --git a/integration_test/tests/1-convention-organizers/conventionOrganizer.loggedin.spec.ts b/integration_test/tests/1-convention-organizers/conventionOrganizer.loggedin.spec.ts index 7966fd9..0bdf47b 100644 --- a/integration_test/tests/1-convention-organizers/conventionOrganizer.loggedin.spec.ts +++ b/integration_test/tests/1-convention-organizers/conventionOrganizer.loggedin.spec.ts @@ -3,6 +3,7 @@ import { setAllureEpic } from '@helpers/allure'; import { CCVT } from '@mock/index'; import { expect } from '@playwright/test'; import { test } from '@fixtures/walletExtension'; +import RepresentativesPage from '@pages/representativesPage'; test.beforeEach(async () => { await setAllureEpic('1. Convention Organizers'); @@ -54,8 +55,12 @@ test.describe('Delegate and Alternate Profile', () => { test('1F. Must have access to update delegate and alternate profile', async ({ page, }) => { - await page.goto('/'); - await expect(page).toHaveTitle(CCVT.title); + const represntativePage = new RepresentativesPage(page); + await represntativePage.updateDelegateProfile(); + await represntativePage.updateAlternateProfile(); + await page.waitForTimeout(10); + await represntativePage.isDelegateUpdated(); + await represntativePage.isAlternateUpdated(); }); test('1I. Must have access to create delegate and alternate profile', async ({ @@ -70,16 +75,16 @@ test.describe('Voting Power', () => { test('1D. Should transfer voting power from delegate to alternate.', async ({ page, }) => { - await page.goto('/'); - - await expect(page).toHaveTitle(CCVT.title); + const representativePage = new RepresentativesPage(page); + await representativePage.transferVotePowerToAlternate(); + await expect(page.getByText('Active voter updated!')).toBeVisible(); }); test('1E. Should transfer voting power from alternate to delegate.', async ({ page, }) => { - await page.goto('/'); - - await expect(page).toHaveTitle(CCVT.title); + const representativePage = new RepresentativesPage(page); + await representativePage.transferVotePowerToDelegate(); + await expect(page.getByText('Active voter updated!')).toBeVisible(); }); });