Skip to content

Commit

Permalink
test: Fix failing organization settings tests after new changes
Browse files Browse the repository at this point in the history
Signed-off-by: Yordan Iliev <[email protected]>
  • Loading branch information
yiliev0 authored and SvetBorislavov committed Jan 21, 2025
1 parent e13932d commit d9491b9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 46 deletions.
34 changes: 5 additions & 29 deletions automation/pages/OrganizationPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class OrganizationPage extends BasePage {
this.users = []; // List to store user credentials
this.transactions = []; // List to store transactions
this.organizationRecoveryWords = []; // List to store recovery phrase words for organization
this.badOrganizationList = []; // List to store bad organizations
this.complexAccountId = []; // List to store complex account ids
this.complexFileId = []; // List to store complex file ids
this.registrationPage = new RegistrationPage(window);
Expand All @@ -72,7 +71,6 @@ class OrganizationPage extends BasePage {
dropdownSelectModeSelector = 'dropdown-select-mode';
dropdownSelectedModeSelector = 'dropdown-selected-mode';
editNicknameOrganizationButtonSelector = 'button-edit-nickname';
closeErrorModalButtonSelector = 'button-close-modal';
logoutButtonSelector = 'button-logout';
contactListButton = 'button-contact-list';
deleteNextButtonSelector = 'button-delete-next';
Expand All @@ -88,6 +86,7 @@ class OrganizationPage extends BasePage {
signTransactionButtonSelector = 'button-sign-org-transaction';
nextTransactionButtonSelector = 'button-next-org-transaction';
signAllTransactionsButtonSelector = 'button-sign-all-tx';
cancelAddingOrganizationButtonSelector = 'button-cancel-adding-org';

// Inputs
organizationNicknameInputSelector = 'input-organization-nickname';
Expand All @@ -98,7 +97,6 @@ class OrganizationPage extends BasePage {
editOrganizationNicknameInputSelector = 'input-edit-nickname';

// Texts
organizationErrorMessageSelector = 'p-organization-error-message';
organizationNicknameTextSelector = 'span-organization-nickname';
transactionDetailsIdSelector = 'p-transaction-details-id';
transactionValidStartSelector = 'p-transaction-details-valid-start';
Expand Down Expand Up @@ -177,7 +175,6 @@ class OrganizationPage extends BasePage {
const serverUrl = process.env.ORGANIZATION_URL + Math.floor(Math.random() * 10);
await this.clickOnAddNewOrganizationButton();
await this.fillOrganizationDetailsAndContinue(organizationNickname, serverUrl);
this.badOrganizationList.push(organizationNickname);
}

/**
Expand Down Expand Up @@ -319,31 +316,10 @@ class OrganizationPage extends BasePage {
return checks.every(isTrue => isTrue);
}

async getOrganizationErrorMessage() {
return await this.getText(this.organizationErrorMessageSelector);
}

async clickOnCloseErrorModalButton() {
await this.click(this.closeErrorModalButtonSelector);
}

async clickOnDeleteSecondOrganization() {
await this.click(this.deleteOrganizationButtonSelector, 1);
}

async clickOnDeleteFirstOrganization() {
await this.click(this.deleteOrganizationButtonSelector, 0);
}

async ensureBadOrganizationExists() {
if (this.badOrganizationList.length === 0) {
await this.settingsPage.clickOnSettingsButton();
await this.settingsPage.clickOnOrganisationsTab();
await this.setupWrongOrganization();
await this.clickOnCloseErrorModalButton();
}
}

async clickOnSelectModeDropdown() {
await this.click(this.dropdownSelectModeSelector);
}
Expand Down Expand Up @@ -1466,10 +1442,6 @@ class OrganizationPage extends BasePage {
return await this.getText(this.observerIndexSelector + index);
}

async getNotificationNumberText() {
return await this.getText(this.spanNotificationNumberSelector);
}

async isNotificationNumberVisible() {
return await this.isElementVisible(this.spanNotificationNumberSelector);
}
Expand Down Expand Up @@ -1505,6 +1477,10 @@ class OrganizationPage extends BasePage {
async isNextTransactionButtonVisible() {
return await this.isElementVisible(this.nextTransactionButtonSelector);
}

async clickOnCancelAddingOrganizationButton() {
await this.click(this.cancelAddingOrganizationButtonSelector);
}
}

module.exports = OrganizationPage;
34 changes: 18 additions & 16 deletions automation/tests/organizationSettingsTests.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,11 @@ test.describe('Organization Settings tests', () => {
});

test('Verify error message when user adds non-existing organization', async () => {
await organizationPage.setupWrongOrganization();
const errorMessage = (await organizationPage.getOrganizationErrorMessage()).trim();
expect(errorMessage).toBe('Organization server is not reachable');
await organizationPage.clickOnCloseErrorModalButton();
});

test('Verify user can delete an organization', async () => {
await organizationPage.ensureBadOrganizationExists();
await settingsPage.clickOnSettingsButton();
await settingsPage.clickOnOrganisationsTab();
await loginPage.waitForToastToDisappear();
await organizationPage.clickOnDeleteSecondOrganization();

await organizationPage.setupWrongOrganization();
const toastMessage = await registrationPage.getToastMessage();
expect(toastMessage).toBe('Connection deleted successfully');

const isDeletedFromDb = await organizationPage.verifyOrganizationExists('Bad Organization');
expect(isDeletedFromDb).toBe(false);
expect(toastMessage).toBe('Organization does not exist. Please check the server URL');
await organizationPage.clickOnCancelAddingOrganizationButton();
});

test('Verify user is prompted for mnemonic phrase and can recover account when resetting organization', async () => {
Expand Down Expand Up @@ -212,4 +199,19 @@ test.describe('Organization Settings tests', () => {
await transactionPage.clickOnTransactionsMenuButton();
expect(await organizationPage.returnAllTabsVisible()).toBe(true);
});

test('Verify user can delete an organization', async () => {
await organizationPage.selectPersonalMode();
await settingsPage.clickOnSettingsButton();
await settingsPage.clickOnOrganisationsTab();
await loginPage.waitForToastToDisappear();
await organizationPage.clickOnDeleteFirstOrganization();

const toastMessage = await registrationPage.getToastMessage();
expect(toastMessage).toBe('Connection deleted successfully');

const orgName = await organizationPage.getOrganizationNicknameText();
const isDeletedFromDb = await organizationPage.verifyOrganizationExists(orgName);
expect(isDeletedFromDb).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ watch(
<hr class="separator my-5" />

<div class="flex-between-centered gap-4">
<AppButton color="borderless" type="button" @click="$emit('update:show', false)"
<AppButton
data-testid="button-cancel-adding-org"
color="borderless"
type="button"
@click="$emit('update:show', false)"
>Cancel</AppButton
>
<AppButton color="primary" data-testid="button-add-organization-in-modal" type="submit"
Expand Down

0 comments on commit d9491b9

Please sign in to comment.