diff --git a/.example.env b/.env.example similarity index 100% rename from .example.env rename to .env.example diff --git a/integration_test/lib/pages/homePage.ts b/integration_test/lib/pages/homePage.ts index c0e699d..3c3fb64 100644 --- a/integration_test/lib/pages/homePage.ts +++ b/integration_test/lib/pages/homePage.ts @@ -40,6 +40,7 @@ export default class HomePage { pollHash: string = '' ): Promise { 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())); @@ -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(); diff --git a/integration_test/tests/0-common/comon.spec.ts b/integration_test/tests/0-common/comon.spec.ts index 295f8ae..16d5aa2 100644 --- a/integration_test/tests/0-common/comon.spec.ts +++ b/integration_test/tests/0-common/comon.spec.ts @@ -31,6 +31,7 @@ test.describe('Polls', () => { browser, pollId, }) => { + test.slow(); const pages = await getUserPages(browser); await Promise.all( @@ -63,6 +64,8 @@ test.describe('Polls', () => { pollId, browser, }) => { + console.log("ok: ",pollId) + const page = await user.loader(browser); await page.goto(`/polls/${pollId}`); @@ -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); @@ -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(); @@ -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'); @@ -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'); diff --git a/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts b/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts index 311bda5..9287be4 100644 --- a/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts +++ b/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts @@ -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'; @@ -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}`; @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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); }); }); diff --git a/integration_test/tests/2-3-constitutional-delegates-alternate/constitutionalDelegateAlternate.spec.ts b/integration_test/tests/2-3-constitutional-delegates-alternate/constitutionalDelegateAlternate.spec.ts index edc2f0b..cc3153a 100644 --- a/integration_test/tests/2-3-constitutional-delegates-alternate/constitutionalDelegateAlternate.spec.ts +++ b/integration_test/tests/2-3-constitutional-delegates-alternate/constitutionalDelegateAlternate.spec.ts @@ -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(), @@ -257,6 +258,7 @@ test.describe('Vote', () => { }); }); }); + test.describe('Representative Status', () => { const users = ['delegate', 'alternate']; users.forEach((user, index) => { @@ -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); }) ); }); diff --git a/integration_test/tests/5-access-control-testing/accessControl.spec.ts b/integration_test/tests/5-access-control-testing/accessControl.spec.ts index 80b45f9..19c8222 100644 --- a/integration_test/tests/5-access-control-testing/accessControl.spec.ts +++ b/integration_test/tests/5-access-control-testing/accessControl.spec.ts @@ -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 { @@ -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 }) => {