From 90b0e193ba1f02d217ff53506dcbd91a50676346 Mon Sep 17 00:00:00 2001 From: Sital999 Date: Tue, 26 Nov 2024 15:50:00 +0545 Subject: [PATCH] feat: Add test 0-5A Update wallet after switching wallet Update Wallet and Role After Switching Wallets in Extension --- integration_test/tests/0-common/comon.spec.ts | 46 +++++++++++++++++++ .../conventionOrganizer.spec.ts | 35 ++++++++++++-- .../buttons/connectWalletButton.tsx | 5 +- 3 files changed, 82 insertions(+), 4 deletions(-) diff --git a/integration_test/tests/0-common/comon.spec.ts b/integration_test/tests/0-common/comon.spec.ts index da94ad4..f3791de 100644 --- a/integration_test/tests/0-common/comon.spec.ts +++ b/integration_test/tests/0-common/comon.spec.ts @@ -14,6 +14,8 @@ import { newOrganizerPage, } from '@helpers/page'; import HomePage from '@pages/homePage'; +import { delegateWallets, organizerWallets } from '@constants/staticWallets'; +import { importWallet } from '@fixtures/importWallet'; test.beforeEach(async () => { await setAllureEpic('0. All Users'); @@ -451,3 +453,47 @@ test.describe('Constitution Poll Hash', () => { }); }); }); + +test.describe('Wallet switching', () => { + test.use({ + storageState: '.auth/organizer1.json', + wallet: organizerWallets[0], + }); + test('0-5A Update Wallet and Role After Switching Wallets in Extension', async ({ + page, + }) => { + await page.goto('/'); + + //click connect wallet button to view representative name + const connectWalletButton = page + .getByTestId('connect-wallet-button') + .first(); + await connectWalletButton.click(); + + // Assert representative name + await expect(page.getByTestId('disconnect-wallet')).toBeVisible(); + const user = await page.getByTestId('representative-name').innerText(); + expect(user).toEqual('Test organizer 02'); + + // Change wallet + const wallet = delegateWallets[0]; + await importWallet(page, wallet); + + // Assert disconnection + await page.goto('/'); + + await expect(page.getByTestId('connect-wallet-button').first()).toBeVisible( + { timeout: 10_000 } + ); + await page.getByTestId('connect-wallet-button').first().click(); + await page.waitForLoadState('load'); + + await expect(page.getByTestId('connect-wallet-button').first()).toBeVisible( + { timeout: 10_000 } + ); + await page.getByTestId('connect-wallet-button').first().click(); + await expect(page.getByTestId('connect-wallet-Eternl')).toBeVisible({ + timeout: 10_000, + }); + }); +}); diff --git a/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts b/integration_test/tests/1-convention-organizers/conventionOrganizer.spec.ts index 21d7b50..3c531a6 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 { organizerWallets } from '@constants/staticWallets'; +import { delegateWallets, organizerWallets } from '@constants/staticWallets'; import { setAllureEpic } from '@helpers/allure'; import { expect } from '@playwright/test'; import { test } from '@fixtures/poll'; @@ -7,11 +7,13 @@ import HomePage from '@pages/homePage'; import { faker } from '@faker-js/faker'; import PollPage from '@pages/pollPage'; import { + createNewPageWithWallet, newAlternatePage, newDelegate1Page, newDelegate2Page, newDelegatePage, } from '@helpers/page'; +import { importWallet } from '@fixtures/importWallet'; test.beforeEach(async () => { await setAllureEpic('1. Convention Organizers'); @@ -625,6 +627,33 @@ test.describe('Voting Power', () => { }); }); -test.describe('Horizantal Vote Results', () => { - test.use({ pollType: 'CreateAndBeginPoll' }); +test.describe('Create Poll', () => { + /** + * Description + * There are 3 input fields for the creation of a poll: + * 1- Question - The question that is being asked + * 2- Constitution text location - The url location of a file containing a .txt file + * 3- Blake2b-256 hash of the constitution text + * + * User Story: As a CO I want to be able to specify which constitutional document my question refers to, and to prove that I have not tampered with it, + * so that users can be sure of what they are voting on + * + * Acceptance Criteria: Given that I am a CO, when I go to the Create Poll page, then there are 3 input fields for me to enter information into. + * + */ + test('1-1J Given connected as a CO on Create Poll page there are 3 input fields to enter information', async ({ + page, + }) => { + const homePage = new HomePage(page); + await homePage.goto(); + + // create Poll Page + await homePage.createPollBtn.click(); + + await expect(page.getByLabel('Constitution Text Hash')).toBeVisible(); + const inputFields = page.locator('input'); + const inputFieldCounts = await inputFields.count(); + + expect(inputFieldCounts).toEqual(3); + }); }); diff --git a/src/components/buttons/connectWalletButton.tsx b/src/components/buttons/connectWalletButton.tsx index b7fd30f..21b9aff 100644 --- a/src/components/buttons/connectWalletButton.tsx +++ b/src/components/buttons/connectWalletButton.tsx @@ -120,7 +120,10 @@ export function ConnectWalletButton(): JSX.Element { alignItems="center" > - + {user?.name}