Skip to content

Commit

Permalink
Update 1-3B "Only active voter able to vote"
Browse files Browse the repository at this point in the history
  • Loading branch information
Sital999 committed Nov 18, 2024
1 parent 8bdcde1 commit bc1d2dd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
5 changes: 4 additions & 1 deletion integration_test/lib/pages/representativesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export default class RepresentativesPage {
await this.goto();
await this.editUserProfileBtn.isVisible();
await this.editUserProfileBtn.click();
await this.page.getByRole('textbox').nth(0).fill(name);
await this.page
.getByRole('textbox')
.nth(0)
.fill('A' + name);
await this.page.getByRole('textbox').nth(1).fill(email);
await this.page.getByRole('textbox').nth(2).fill(stake_address);
await this.saveUserProfileBtn.click({ force: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import RepresentativesPage from '@pages/representativesPage';
import HomePage from '@pages/homePage';
import { faker } from '@faker-js/faker';
import PollPage from '@pages/pollPage';
import { newAlternate1Page, newDelegate1Page } from '@helpers/page';
import {
newAlternate1Page,
newAlternatePage,
newDelegate1Page,
newDelegatePage,
} from '@helpers/page';

test.beforeEach(async () => {
await setAllureEpic('1. Convention Organizers');
Expand Down Expand Up @@ -284,17 +289,21 @@ test.describe('User Control', () => {
*/
test('1-2A. Given connected as CO can update all fields of user', async ({
page,
pollId,
}) => {
// delete exisiting opened polls
const homePage = new HomePage(page);
await homePage.goto();
await homePage.deleteOpenPollCards();

const name = faker.person.lastName();
const email = name.split(' ')[0] + '@email.com';
const email = name + '@email.com';
const stake_address = faker.person.jobArea();
const represntativePage = new RepresentativesPage(page);

await represntativePage.updateUserProfile(name, email, stake_address);

await represntativePage.isRepresentativeUpdated([
name,
'A' + name,
email,
stake_address,
]);
Expand Down Expand Up @@ -370,7 +379,7 @@ test.describe('User Control', () => {
await expect(page.getByRole('status')).toHaveText(
'You cannot change the active voter while a Poll is actively voting.'
);
await page.waitForTimeout(500);
await expect(page.getByRole('row').first()).toBeVisible();
const currentActiveVoterId = await page
.locator('[data-id="1"]')
.locator('[data-field="active_voter_cell"]')
Expand Down Expand Up @@ -402,7 +411,9 @@ test.describe('User Control', () => {
await expect(page.getByRole('status')).toHaveText(
'You cannot update user information while a Poll is actively voting.'
);
await expect(page.getByTestId('edit-representative-info-2')).toBeVisible();
await expect(
page.getByTestId('edit-representative-info-138')
).toBeVisible();
await expect(page.getByText(name)).not.toBeVisible();
});
});
Expand Down Expand Up @@ -468,11 +479,11 @@ test.describe('Voting Power', () => {
// Get Active Voter Status
const representativePage = new RepresentativesPage(page);
await representativePage.goto();
const activeVoterRole = await representativePage.getActiveVoterStatus();
const activeVoterRole = await representativePage.getActiveVoterStatus(6);

// Delegate and Alternate page
const delegatePage = await newDelegate1Page(browser);
const alternatePage = await newAlternate1Page(browser);
const delegatePage = await newDelegatePage(browser, 4);
const alternatePage = await newAlternatePage(browser, 4);

// Get Active voter
const activeVoter =
Expand All @@ -487,12 +498,19 @@ test.describe('Voting Power', () => {
await activeVoter.getByText('Vote recorded').isVisible();

// Assert vote
await expect(activeVoter.getByText('Vote recorded')).toBeVisible();
await expect(activeVoter.getByText('Vote recorded')).toBeVisible({
timeout: 5_000,
});

const inactiveVoterPage = new PollPage(inactiveVoter);
await inactiveVoterPage.goto(pollId);

// Assert not able to vote
await inactiveVoter
.getByRole('heading', {
name: 'You are not the active voter for your workshop. Only the active voter can vote.',
})
.isVisible();
await expect(
inactiveVoter.getByRole('heading', {
name: 'You are not the active voter for your workshop. Only the active voter can vote.',
Expand Down
10 changes: 10 additions & 0 deletions integration_test/tests/auth.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ const authConfigurations = [
authFile: '.auth/alternate4.json',
name: 'Alternate4',
},
{
wallet: delegateWallets[4],
authFile: '.auth/delegate5.json',
name: 'Delegate5',
},
{
wallet: alternateWallets[4],
authFile: '.auth/alternate5.json',
name: 'Alternate5',
},
];

setup.beforeEach(async () => {
Expand Down

0 comments on commit bc1d2dd

Please sign in to comment.