Skip to content

Commit

Permalink
feat: Add test 1-2A-2, 1-2A-3 for profile update
Browse files Browse the repository at this point in the history
CO cannot update existing email or stake address
  • Loading branch information
Sital999 committed Nov 29, 2024
1 parent 2d73f04 commit c8ef9cb
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 29 deletions.
4 changes: 2 additions & 2 deletions integration_test/lib/pages/representativesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class RepresentativesPage {
stake_address: string
): Promise<void> {
await this.goto();
await this.editUserProfileBtn.isVisible();
await expect(this.editUserProfileBtn).toBeVisible({ timeout: 30_000 });
await this.editUserProfileBtn.click();
await this.page
.getByRole('textbox')
Expand All @@ -40,7 +40,7 @@ export default class RepresentativesPage {

async isRepresentativeUpdated(infos: Array<string>): Promise<void> {
await expect(this.page.getByText(representativeUpdatedToast)).toBeVisible();
await this.editUserProfileBtn.isVisible();
await expect(this.editUserProfileBtn).toBeVisible({ timeout: 30_000 });
await Promise.all(
infos.map(
async (info) =>
Expand Down
4 changes: 2 additions & 2 deletions integration_test/tests/0-common/comon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ test.describe('Polls', () => {
await expect(pollPageStatusChip).toBeVisible();

await expect(page.getByTestId('results-yes')).toBeVisible();
await page.getByTestId('results-no').isVisible();
await page.getByTestId('results-abstain').isVisible();
await expect(page.getByTestId('results-no')).toBeVisible();
await expect(page.getByTestId('results-abstain')).toBeVisible();
await page.goto(`/polls/${pollId}`);

const yesCount = page.getByTestId('yes-count');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,10 @@ test.describe('User Control', () => {
* Acceptance Criteria: Given that I am a CO on the page containing the list of user records, I can select the
* record that I want to edit and modify the fields in that record as I see fit.
*/
test('1-2A. Given connected as CO can update all fields of user', async ({
test('1-2A-1. Given connected as CO can update all fields of user', async ({
page,
}) => {
test.slow();
// delete exisiting opened polls
const homePage = new HomePage(page);
await homePage.goto();
Expand All @@ -387,6 +388,52 @@ test.describe('User Control', () => {
]);
});

test('1-2A-2. CO cannot update representative email with existing email', async ({
page,
}) => {
test.slow();
// delete exisiting opened polls
const homePage = new HomePage(page);
await homePage.goto();
await homePage.deleteOpenPollCards();

// Update representative email with existing email
const name = faker.person.lastName();
const email = '[email protected]';
const stake_address = faker.person.jobArea();
const represntativePage = new RepresentativesPage(page);

// Update representative profile
await represntativePage.updateUserProfile(name, email, stake_address);

// Assert error toast msg
await expect(page.getByRole('status')).toBeVisible();
await expect(page.getByRole('status')).toHaveText('Error updating user.');
});

test('1-2A-3. CO cannot update representative stake with existing stake', async ({
page,
}) => {
test.slow();
// delete exisiting opened polls
const homePage = new HomePage(page);
await homePage.goto();
await homePage.deleteOpenPollCards();

// Update representative stake address with existing stake address
const name = faker.person.lastName();
const email = name + '@email.com';
const stake_address = organizerWallets[0].stakeAddress;
const represntativePage = new RepresentativesPage(page);

// Update representative profile
await represntativePage.updateUserProfile(name, email, stake_address);

// Assert error toast msg
await expect(page.getByRole('status')).toBeVisible();
await expect(page.getByRole('status')).toHaveText('Error updating user.');
});

/**
* Description: The table displaying delegates and workshops should follow a default sorting methodology so that it is easy for users to see what is included.
*
Expand Down Expand Up @@ -632,7 +679,7 @@ test.describe('Voting Power', () => {
const voterPollPage = new PollPage(activeVoterPage);
await voterPollPage.goto(pollId);
await voterPollPage.voteYesBtn.click();
await activeVoterPage.getByText('Vote recorded').isVisible();
await expect(activeVoterPage.getByText('Vote recorded')).toBeVisible();

// Assert vote
await expect(activeVoterPage.getByText('Vote recorded')).toBeVisible({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ test.describe('Vote', () => {
* Acceptance Criteria: Given that I am a voter on the page of an open poll and I have already voted, when I vote again, then my vote is counted.
*/
test(`${index + 2}-1C. Given active ${user}, and poll is open, can update casted vote`, async () => {
test.slow();
// yes vote
await pollPage.voteYesBtn.click();
await expect(userPage.getByTestId('poll-page-vote-count')).toHaveText(
Expand All @@ -145,6 +146,7 @@ test.describe('Vote', () => {
*/

test(`${index + 2}-1F. Given active ${user}, can see what they have voted`, async () => {
test.slow();
// yes vote
await pollPage.voteYesBtn.click();
await expect(userPage.getByTestId('vote-status')).toHaveText('YES', {
Expand All @@ -161,6 +163,7 @@ test.describe('Vote', () => {
*/

test(`${index + 2}-1D. Given active ${user}, can choose not to vote`, async () => {
test.slow();
await pollPage.voteAbstainBtn.click();

await expect(userPage.getByTestId('vote-status')).toHaveText(
Expand All @@ -181,6 +184,7 @@ test.describe('Vote', () => {
*/

test(`${index + 2}-1E: Active ${user} should be able to vote Yes, No, or Abstain on a poll`, async () => {
test.slow();
// yes vote
await pollPage.voteYesBtn.click();
await expect(userPage.getByTestId('vote-status')).toHaveText('YES');
Expand Down Expand Up @@ -275,7 +279,6 @@ test.describe('Representative Status', () => {
test(`${index + 2}-1G. Once login ${user} should be able to know their voting right status`, async ({
browser,
}) => {
test.slow();
const delegatePage = await newDelegatePage(browser, 3);
const alternatePage = await newAlternatePage(browser, 3);

Expand All @@ -284,28 +287,22 @@ test.describe('Representative Status', () => {
await Promise.all(
pages.map(async (page) => {
await page.goto('/');
await expect(
page.locator('[data-testid^="active-voter-name-"]').first()
).toBeVisible();
const activeVoter = (
await page
.locator('[data-testid^="active-voter-name-"]')
.allInnerTexts()
)[4];
console.log('active voter: ', activeVoter);
const delegateName = (
await page
.locator('[data-testid^="delegate-name-"]')
.allInnerTexts()
)[4];
const alternateName = (
await page
.locator('[data-testid^="alternate-name-"]')
.allInnerTexts()
)[4];

// Assert active voter is among the delegate and alternate
expect([delegateName, alternateName]).toContain(activeVoter);
await expect(page.locator('[data-id="5"]').first()).toBeVisible({
timeout: 10_000,
});

// Fetch representative list of workshop 5
const representativeList = await page
.locator('[data-id="5"]')
.allInnerTexts();
const [workshop, delegate, alternate, active_voter] =
representativeList[0].split('\n\n');

// Assert workshop name
expect(workshop).toBe('Workshop 05');

// Assert active voter value to be in between delegate and alternate
expect([delegate, alternate]).toContain(active_voter);
})
);
});
Expand Down

0 comments on commit c8ef9cb

Please sign in to comment.