Skip to content

Commit

Permalink
Write test case for 79 and 80
Browse files Browse the repository at this point in the history
  • Loading branch information
Sital999 committed Nov 12, 2024
1 parent c7872fc commit 4970257
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 8 deletions.
79 changes: 79 additions & 0 deletions integration_test/lib/pages/representativesPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { Page, expect } from '@playwright/test';

const updateDelegateEmail = '[email protected]';
const updatedAlternateEmail = '[email protected]';

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<void> {
await this.page.goto('/representatives/manage');
}

async updateDelegateProfile(): Promise<void> {
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<void> {
const representativeEmailList = await this.page
.locator('[data-field="email"]')
.allInnerTexts();
expect(representativeEmailList).toContain(updateDelegateEmail);
}

async updateAlternateProfile(): Promise<void> {
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<void> {
const representativeEmailList = await this.page
.locator('[data-field="email"]')
.allInnerTexts();
expect(representativeEmailList).toContain(updatedAlternateEmail);
}

async transferVotePowerToAlternate(): Promise<void> {
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<void> {
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 ({
Expand All @@ -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();
});
});

0 comments on commit 4970257

Please sign in to comment.