Skip to content

Commit

Permalink
test: Add poll creation test
Browse files Browse the repository at this point in the history
  • Loading branch information
mesudip committed Nov 14, 2024
1 parent 2988359 commit 12a26f5
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 45 deletions.
1 change: 0 additions & 1 deletion integration_test/lib/fixtures/loadExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
import environments from '@constants/environments';
import { Page } from '@playwright/test';


// eslint-disable-next-line @typescript-eslint/no-require-imports
import path = require('path');

Expand Down
31 changes: 30 additions & 1 deletion integration_test/lib/helpers/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { importWallet } from '@fixtures/importWallet';
import LoginPage from '@pages/loginPage';
import { BrowserContext, Page } from '@playwright/test';
import { Browser, BrowserContext, Page } from '@playwright/test';
import { StaticWallet } from '@types';
import loadEternlExtension from '@fixtures/loadExtension';

interface CreateUserProps {
page: Page;
Expand All @@ -24,3 +25,31 @@ export async function createAuth({

await context.storageState({ path: auth });
}

interface NewPageConfig {
storageState?: string;
wallet: StaticWallet;
enableStakeSigning?: boolean;
supportedExtensions?: Record<string, number>[];
}

export async function createNewPageWithWallet(
browser: Browser,
newPageConfig: NewPageConfig
): Promise<Page> {
const { storageState, wallet, ...extensionConfig } = newPageConfig;

const context = await browser.newContext({
storageState,
});
const newPage = await context.newPage();

await loadEternlExtension(
newPage,
extensionConfig.enableStakeSigning,
extensionConfig.supportedExtensions
);
await importWallet(newPage, wallet);

return newPage;
}
1 change: 0 additions & 1 deletion integration_test/lib/helpers/mobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ export function isMobile(page: Page): boolean {

return false;
}

1 change: 0 additions & 1 deletion integration_test/lib/pages/representativesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Page, expect } from '@playwright/test';
const updateDelegateEmail = '[email protected]';
const updatedAlternateEmail = '[email protected]';
const representativeUpdatedToast = 'User info updated!';

export default class RepresentativesPage {
readonly updateDelegateBtn = this.page.getByTestId(
'edit-representative-info-2'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { organizerWallet } from '@constants/staticWallets';
import { delegateWallet, organizerWallet } from '@constants/staticWallets';
import { setAllureEpic } from '@helpers/allure';
import { CCVT } from '@mock/index';
import { expect } from '@playwright/test';
Expand All @@ -21,6 +21,24 @@ test.describe('Recognise a Convention Organiser', () => {
});
});

test.describe('Polls', () => {
test('1XX, Can create poll with valid data', async ({ page, browser }) => {
await page.goto('/polls/new');
await page
.locator('[data-testid="poll-name-input"] input')
.fill('Dummy Test Poll');
await page
.locator('[data-testid="poll-description-input"] textarea')
.first()
.fill('Test Poll Description');
await page.getByTestId('create-poll-button').click();

await expect(page.getByText('Dummy Test Poll')).toBeVisible();
await expect(
page.getByTestId('poll-status-chip').getByText('Pending')
).toBeVisible();
});
});
test.describe('Invitation', () => {
test('1B. Could invite delegates', async ({ page }) => {
await page.goto('/');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ test.beforeEach(async () => {
});

test.describe('Delegate Registration', () => {
test('2E. Must be able to view their registration status', async ({ page }) => {
test('2E. Must be able to view their registration status', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});

});

Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ test.beforeEach(async () => {
});

test.describe('Delegate View Vote', () => {

test('2F. Must be able to view vote result and its count', async ({ page }) => {
test('2F. Must be able to view vote result and its count', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});

test('2G. Must be able to view own vote during open poll', async ({ page }) => {
test('2G. Must be able to view own vote during open poll', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});

test('2I. Should not be able to view poll result before poll closing', async ({ page }) => {
test('2I. Should not be able to view poll result before poll closing', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});
});

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ test.describe('Delegate Vote', () => {
await expect(page).toHaveTitle(CCVT.title);
});

test('2H. Should be able to change vote during open poll', async ({ page }) => {
test('2H. Should be able to change vote during open poll', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});
Expand All @@ -35,6 +37,4 @@ test.describe('Delegate Vote', () => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});

});

Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ test.beforeEach(async () => {
});

test.describe('Alternate Registration', () => {

test('3A. Must be able to view their registration status', async ({ page }) => {
test('3A. Must be able to view their registration status', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});

});

11 changes: 6 additions & 5 deletions integration_test/tests/3-alternates/alternates.viewvote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ test.beforeEach(async () => {
});

test.describe('Alternate View Vote', () => {

test('3C. Must be able to view vote result and its count.', async ({ page }) => {
test('3C. Must be able to view vote result and its count.', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});

test('3D. Must be able to view own vote during open poll', async ({ page }) => {
test('3D. Must be able to view own vote during open poll', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});

});

10 changes: 6 additions & 4 deletions integration_test/tests/3-alternates/alternates.vote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ test.beforeEach(async () => {
});

test.describe('Alternate Vote', () => {

test('3A. Must not be able to vote while delegate is present.', async ({ page }) => {
test('3A. Must not be able to vote while delegate is present.', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});

test('3E. Should be able to change vote during open poll', async ({ page }) => {
test('3E. Should be able to change vote during open poll', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});
Expand All @@ -23,4 +26,3 @@ test.describe('Alternate Vote', () => {
await expect(page).toHaveTitle(CCVT.title);
});
});

Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ test.beforeEach(async () => {
});

test.describe('View Poll Status', () => {

test('4G. Must be able to view vote result and its count.', async ({ page }) => {
test('4G. Must be able to view vote result and its count.', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});

});

Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@ test.beforeEach(async () => {
});

test.describe('View Voter Profile', () => {

test('4C. Must be able to view voters profile.', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});


test('4D. Must be able to view delegate workspace name in profile.', async ({ page }) => {
test('4D. Must be able to view delegate workspace name in profile.', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});

test('4E. Could associate email with delegate profiles.', async ({ page }) => {
test('4E. Could associate email with delegate profiles.', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});
Expand All @@ -29,10 +31,10 @@ test.describe('View Voter Profile', () => {
await expect(page).toHaveTitle(CCVT.title);
});

test('4I. Should be able to view public information of voter.', async ({ page }) => {
test('4I. Should be able to view public information of voter.', async ({
page,
}) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});

});

Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ test.beforeEach(async () => {
});

test.describe('View Vote Status', () => {

test('4H. Should be able to view poll status', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(CCVT.title);
});

});

2 changes: 1 addition & 1 deletion integration_test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@pages/*": ["lib/pages/*"],
"@constants/*": ["lib/constants/*"],
"@datafactory/*": ["lib/datafactory/*"],
"@types": ["lib/types.ts"],
"@types": ["lib/types.ts"]
}
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"exclude": ["node_modules","integration_test"]
}

0 comments on commit 12a26f5

Please sign in to comment.