Skip to content

Commit

Permalink
Fix failed test cases with latest dev changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sital999 committed Dec 2, 2024
1 parent d35e890 commit e001e99
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 20 deletions.
File renamed without changes.
5 changes: 3 additions & 2 deletions integration_test/lib/pages/homePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default class HomePage {
pollHash: string = ''
): Promise<number> {
await this.createPollBtn.click();
await this.page.waitForSelector('[data-testid="poll-name-input"] textarea');
await this.pollNameInput.fill(pollName);
await this.constitutionLinkInput.fill(faker.internet.url());
const randomHash = blake.hash32(Buffer.from(faker.animal.bear()));
Expand All @@ -49,8 +50,8 @@ export default class HomePage {

await this.submitPollBtn.click();

await this.page.waitForURL(/\/polls\/(?!new)/, {
timeout: 10_000,
await expect(this.beginVoteBtn).toBeVisible({
timeout: 30_000,
});

const currentPageUrl = this.page.url();
Expand Down
26 changes: 19 additions & 7 deletions integration_test/tests/0-common/comon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ test.describe('Polls', () => {
browser,
pollId,
}) => {
test.slow();
const pages = await getUserPages(browser);

await Promise.all(
Expand Down Expand Up @@ -63,6 +64,8 @@ test.describe('Polls', () => {
pollId,
browser,
}) => {
console.log("ok: ",pollId)

const page = await user.loader(browser);
await page.goto(`/polls/${pollId}`);

Expand Down Expand Up @@ -104,7 +107,10 @@ test.describe('Polls', () => {
const delegatePollPage = new PollPage(delegatePage);
await delegatePollPage.goto(pollId);

// vote and assert voting
await delegatePollPage.voteYesBtn.click();
await expect( delegatePage.getByTestId('vote-status')).toBeVisible({timeout:10_000});

await Promise.all(
pages.map(async (userPage) => {
const pollPage = new PollPage(userPage);
Expand Down Expand Up @@ -150,7 +156,7 @@ test.describe('Polls', () => {
pages.map(async (page) => {
await page.goto(`/polls/${pollId}`);
const pollPageStatusChip = page.getByTestId('poll-page-status-chip');
await expect(pollPageStatusChip).toBeVisible();
await expect(pollPageStatusChip).toHaveText('Concluded',{timeout:15_000});

await expect(page.getByTestId('results-yes')).toBeVisible();
await expect(page.getByTestId('results-no')).toBeVisible();
Expand Down Expand Up @@ -220,9 +226,11 @@ test.describe('User profile', () => {
test.slow();
await page.goto('/polls/' + pollId);

const buttons = await page
.locator('[data-testid^="representative-vote-"]')
.all();
// Locate the buttons
const representativeBtns = page
.locator('[data-testid^="representative-vote-"]')
await expect(representativeBtns.first()).toBeVisible({timeout:10_000});
const buttons = await representativeBtns.all();

if (buttons.length === 0) {
throw new Error('No representative vote buttons found');
Expand Down Expand Up @@ -293,12 +301,16 @@ test.describe('User profile', () => {
page,
pollId,
}) => {
test.slow();
await page.goto('polls/' + pollId);

// Locate the buttons
const buttons = await page
.locator('[data-testid^="representative-vote-"]')
.all();
const representativeBtns = page
.locator('[data-testid^="representative-vote-"]')

await expect(representativeBtns.first()).toBeVisible({timeout:10_000});

const buttons = await representativeBtns.all();

if (buttons.length === 0) {
throw new Error('No representative vote buttons found');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { delegateWallets, organizerWallets } from '@constants/staticWallets';
import { organizerWallets } from '@constants/staticWallets';
import { setAllureEpic } from '@helpers/allure';
import { expect } from '@playwright/test';
import { test } from '@fixtures/poll';
Expand Down Expand Up @@ -325,27 +325,27 @@ test.describe('Onchain Poll', () => {
test.slow()
const pollPage = new PollPage(page);
pollPage.goto(pollId);
const waiter= waitForTxSubmit(page)
const waiter = waitForTxSubmit(page)
await pollPage.uploadVoteOnchainBtn.waitFor({ state: 'visible' });
await sleep(1000)

// Click the button and start transaction submission
await pollPage.uploadVoteOnchainBtn.click();
console.log("Upload votes button clicked!!")
const votesTxId=await waiter
const summaryTxWaiter=waitForTxSubmit(page)
const votesTxId = await waiter
const summaryTxWaiter = waitForTxSubmit(page)
await pollTransaction(votesTxId)


const summaryTxId=await summaryTxWaiter
const summaryTxId = await summaryTxWaiter
await pollTransaction(summaryTxId);

// click on viewVote Onchain Button and check the url in new tab

const newPagePopup=page.waitForEvent('popup')
await pollPage.viewTxOnchainBtn.waitFor({state: 'visible'});
const newPagePopup = page.waitForEvent('popup')
await pollPage.viewTxOnchainBtn.waitFor({ state: 'visible' });
await pollPage.viewTxOnchainBtn.click()
const newPage=await newPagePopup
const newPage = await newPagePopup

await newPage.waitForLoadState('domcontentloaded');
const expectedUrl = `/transaction/${summaryTxId}`;
Expand Down Expand Up @@ -505,6 +505,9 @@ test.describe('User Control', () => {
await pollPage.goto(pollId);
await pollPage.beginVoteBtn.click();

// Assert begining of poll
await expect(pollPage.endVotingBtn).toBeVisible({ timeout: 10_000 })

// before switching power while poll is opened for voting
const representativePage = new RepresentativesPage(page);
await representativePage.goto();
Expand Down Expand Up @@ -542,6 +545,9 @@ test.describe('User Control', () => {
await pollPage.goto(pollId);
await pollPage.beginVoteBtn.click();

// Assert begining of poll
await expect(pollPage.endVotingBtn).toBeVisible({ timeout: 10_000 })

// before switching power while poll is opened for voting
const representativePage = new RepresentativesPage(page);
await representativePage.goto();
Expand Down Expand Up @@ -660,6 +666,9 @@ test.describe('Voting Power', () => {
await pollPage.goto(pollId);
await pollPage.beginVoteBtn.click();

// Assert begining of poll
await expect(pollPage.endVotingBtn).toBeVisible({ timeout: 10_000 })

// Get Active Voter Status
const representativePage = new RepresentativesPage(page);
await representativePage.goto();
Expand All @@ -678,6 +687,7 @@ test.describe('Voting Power', () => {
// Vote from activeVoterPage
const voterPollPage = new PollPage(activeVoterPage);
await voterPollPage.goto(pollId);
await expect(voterPollPage.voteYesBtn).toBeVisible({ timeout: 10_000 })
await voterPollPage.voteYesBtn.click();
await expect(activeVoterPage.getByText('Vote recorded')).toBeVisible();

Expand Down Expand Up @@ -722,9 +732,12 @@ test.describe('Create Poll', () => {
await homePage.createPollBtn.click();

await expect(page.getByLabel('Constitution Text Hash')).toBeVisible();
const textareaField = page.locator('textarea:not([readonly])');
const inputFields = page.locator('input');
const inputFieldCounts = await inputFields.count();
const textareaFieldCount = await textareaField.count();

expect(inputFieldCounts).toEqual(3);
expect(inputFieldCounts).toEqual(2);
expect(textareaFieldCount).toEqual(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ test.describe('Vote', () => {
*/

test(`${index + 2}-1A. Given active ${user}, and poll is open, then vote option should be visible`, async () => {
test.slow();
await expect(pollPage.voteYesBtn).toBeVisible({ timeout: 10_000 }),
await Promise.all([
await expect(pollPage.voteYesBtn).toBeVisible(),
Expand Down Expand Up @@ -257,6 +258,7 @@ test.describe('Vote', () => {
});
});
});

test.describe('Representative Status', () => {
const users = ['delegate', 'alternate'];
users.forEach((user, index) => {
Expand Down Expand Up @@ -302,7 +304,7 @@ test.describe('Representative Status', () => {
expect(workshop).toBe('Workshop 05');

// Assert active voter value to be in between delegate and alternate
expect([delegate, alternate]).toContain(active_voter);
expect(['Delegate', 'Alternate']).toContain(active_voter);
})
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { newOrganizer1Page } from '@helpers/page';
import { getUserPages } from '@helpers/userRoles';
import test, { expect, Page } from '@playwright/test';
import test, { expect } from '@playwright/test';
import HomePage from '@pages/homePage';
import { setAllureEpic } from '@helpers/allure';
import {
Expand All @@ -21,6 +21,7 @@ test.describe('Access Control Test', () => {
const homePage = new HomePage(organizerPage);
await homePage.goto();
await homePage.deleteOpenPollCards();
await organizerPage.waitForURL('/')
});

test('5-1A. Only CO can create a new poll', async ({ browser }) => {
Expand Down

0 comments on commit e001e99

Please sign in to comment.