Skip to content

Commit

Permalink
feat: Add test 0-5A Update wallet after switching wallet
Browse files Browse the repository at this point in the history
Update Wallet and Role After Switching Wallets in Extension
  • Loading branch information
Sital999 committed Nov 26, 2024
1 parent 2f5266e commit 90b0e19
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 4 deletions.
46 changes: 46 additions & 0 deletions integration_test/tests/0-common/comon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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,
});
});
});
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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');
Expand Down Expand Up @@ -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);
});
});
5 changes: 4 additions & 1 deletion src/components/buttons/connectWalletButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ export function ConnectWalletButton(): JSX.Element {
alignItems="center"
>
<PersonRounded color="success"></PersonRounded>
<Typography color={theme.palette.success.main}>
<Typography
data-testid="representative-name"
color={theme.palette.success.main}
>
{user?.name}
</Typography>
</Box>
Expand Down

0 comments on commit 90b0e19

Please sign in to comment.