Skip to content

Commit

Permalink
add gassless vote test (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler17 committed Jun 1, 2024
1 parent 4b8b924 commit 0009b3e
Showing 1 changed file with 77 additions and 1 deletion.
78 changes: 77 additions & 1 deletion playwright/polling.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './forkVnet';
test('Adds polls to review and navigates to review page and votes with the legacy system', async ({ page }) => {
await page.goto('/polling');

await expect(page.getByRole('heading', { name: 'Active Polls' })).toBeVisible();
await expect(page.getByRole('heading', { name: 'Ended Polls' })).toBeVisible();

await connectWallet(page);

Expand Down Expand Up @@ -77,3 +77,79 @@ test('Adds polls to review and navigates to review page and votes with the legac
await expect(page.locator('[data-testid="poll-overview-card"]')).toHaveCount(1);

});

test.only('Adds polls to review and navigates to review page and votes with the gasless system', async ({ page }) => {
await page.goto('/polling');

await expect(page.getByRole('heading', { name: 'Ended Polls' })).toBeVisible();

await connectWallet(page);

const selectedPollId = 1107;
const selectChoice = page.locator('[data-testid="single-select"]');

await selectChoice.first().click();

// click on option
await page.locator('[data-testid="single-select-option-Yes"]').first().click();

const buttonsVote = page.locator('[data-testid="button-add-vote-to-ballot"]');

// Click the button
await expect(buttonsVote.first()).toBeEnabled();

await buttonsVote.first().click();

// Check the ballot count has increased
await expect(page.locator('text=/1 of .* available poll(s)? added to ballot/')).toBeVisible();

// Click on the navigate
await page.locator('text=Review & Submit Your Ballot').click();

await expect(page).toHaveURL('/polling/review');

// Poll card should display poll IDs
await expect(page.locator(`text=Poll ID ${selectedPollId}`)).toBeVisible();

// It can edit a choice
await page.locator('[data-testid="edit-poll-choice"]').click();

// Opens the select
await selectChoice.first().click();

// Clicks on "No"
await page.locator('[data-testid="single-select-option-No"]').click({ force: true });

// Clicks on update vote
await page.locator('text=Update vote').click();

// Move to submit ballot screen
await page.locator('[data-testid="submit-ballot-button"]').click();

await expect(page.locator('text=Gasless voting via Arbitrum')).toBeVisible();

// vote via gasless
await page.locator('[data-testid="submit-ballot-gasless-button"]').click();

await expect(page.locator(
'text=Submit your vote by creating a transaction and sending it to the polling contract on Ethereum Mainnet.'
)).toBeVisible();

// Click legacy voting submit button
await page.locator('[data-testid="submit-ballot-legacy-button"]').click();

await expect(page.locator('text=Please use your wallet to sign')).toBeVisible();

//await expect(page.locator('text=Transaction Pending')).toBeVisible();

await expect(page.locator('text=Share all your votes')).toBeVisible();

// After finishing voting, there should be a message with the sharing info
await expect(page.locator(
'text=Share your votes to the Forum or Twitter below, or go back to the polls page to edit your votes'
)).toBeVisible();

// And the same amount of poll cards
await expect(page.locator('[data-testid="poll-overview-card"]')).toHaveCount(1);

});

0 comments on commit 0009b3e

Please sign in to comment.