Skip to content

Commit

Permalink
fix(#3372): Extract method to validate sidebar entries
Browse files Browse the repository at this point in the history
  • Loading branch information
tenthe committed Dec 16, 2024
1 parent 4661538 commit e44d670
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 48 deletions.
7 changes: 7 additions & 0 deletions ui/cypress/support/utils/GeneralUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ export class GeneralUtils {
public static tab(identifier: string) {
return cy.dataCy(`tab-${identifier}`).click();
}

public static validateAmountOfNavigationIcons(expected: number) {
cy.dataCy('navigation-icon', { timeout: 10000 }).should(
'have.length',
expected,
);
}
}
11 changes: 3 additions & 8 deletions ui/cypress/tests/userManagement/testGroupManagement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
import { PipelineUtils } from '../../support/utils/pipeline/PipelineUtils';
import { PipelineElementBuilder } from '../../support/builder/PipelineElementBuilder';
import { PipelineBuilder } from '../../support/builder/PipelineBuilder';
import { GeneralUtils } from '../../support/utils/GeneralUtils';

describe('Test Group Management for Pipelines', () => {
beforeEach('Setup Test', () => {
Expand Down Expand Up @@ -102,10 +103,7 @@ describe('Test Group Management for Pipelines', () => {
// Login as first user which belongs to user group with pipeline admin role
UserUtils.switchUser(user);

cy.dataCy('navigation-icon', { timeout: 10000 }).should(
'have.length',
4,
);
GeneralUtils.validateAmountOfNavigationIcons(4);

// Check if pipeline is visible
PipelineUtils.goToPipelines();
Expand All @@ -121,10 +119,7 @@ describe('Test Group Management for Pipelines', () => {
// Login as user2
UserUtils.switchUser(user2);

cy.dataCy('navigation-icon', { timeout: 10000 }).should(
'have.length',
3,
);
GeneralUtils.validateAmountOfNavigationIcons(3);

// Check if pipeline is invisible to user2
PipelineUtils.goToPipelines();
Expand Down
16 changes: 4 additions & 12 deletions ui/cypress/tests/userManagement/testUserRoleConnect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { UserRole } from '../../../src/app/_enums/user-role.enum';
import { UserUtils } from '../../support/utils/UserUtils';
import { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
import { ConnectBtns } from '../../support/utils/connect/ConnectBtns';
import { GeneralUtils } from '../../support/utils/GeneralUtils';

describe('Test User Roles for Connect', () => {
beforeEach('Setup Test', () => {
Expand All @@ -39,20 +40,11 @@ describe('Test User Roles for Connect', () => {
// Login as user and check if connect is visible to user
UserUtils.switchUser(connect_admin);

cy.dataCy('navigation-icon', { timeout: 10000 }).should(
'have.length',
3,
);
GeneralUtils.validateAmountOfNavigationIcons(3);

ConnectUtils.goToConnect();
cy.dataCy('all-adapters-table', { timeout: 10000 }).should(
'have.length',
1,
);
cy.dataCy('all-adapters-table', { timeout: 10000 }).should(
'contain',
'simulator',
);

ConnectUtils.checkAmountOfAdapters(1);

// validate that adapter can be stopped and edited
ConnectBtns.stopAdapter().click();
Expand Down
6 changes: 2 additions & 4 deletions ui/cypress/tests/userManagement/testUserRolePipeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
import { PipelineUtils } from '../../support/utils/pipeline/PipelineUtils';
import { PipelineElementBuilder } from '../../support/builder/PipelineElementBuilder';
import { PipelineBuilder } from '../../support/builder/PipelineBuilder';
import { GeneralUtils } from '../../support/utils/GeneralUtils';

describe('Test User Roles for Pipelines', () => {
beforeEach('Setup Test', () => {
Expand Down Expand Up @@ -81,10 +82,7 @@ describe('Test User Roles for Pipelines', () => {
// Login as user and check if pipeline is visible to user
UserUtils.switchUser(user);

cy.dataCy('navigation-icon', { timeout: 10000 }).should(
'have.length',
3,
);
GeneralUtils.validateAmountOfNavigationIcons(3);

PipelineUtils.goToPipelines();
cy.dataCy('all-pipelines-table', { timeout: 10000 }).should(
Expand Down
31 changes: 7 additions & 24 deletions ui/cypress/tests/userManagement/testVariousUserRoles.smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { UserBuilder } from '../../support/builder/UserBuilder';
import { UserRole } from '../../../src/app/_enums/user-role.enum';
import { UserUtils } from '../../support/utils/UserUtils';
import { GeneralUtils } from '../../support/utils/GeneralUtils';

const testedRoles = [
UserRole.ROLE_PIPELINE_ADMIN,
Expand All @@ -38,10 +39,7 @@ for (var i = 0; i < testedRoles.length; i++) {
it('Perform Test', () => {
// Add new user
UserUtils.goToUserConfiguration();
cy.dataCy('navigation-icon', { timeout: 10000 }).should(
'have.length',
8,
);
GeneralUtils.validateAmountOfNavigationIcons(8);

cy.dataCy('user-accounts-table-row', { timeout: 10000 }).should(
'have.length',
Expand All @@ -68,30 +66,15 @@ for (var i = 0; i < testedRoles.length; i++) {

// Check if every role displays correct navigation menu
if (testRole == UserRole.ROLE_PIPELINE_ADMIN) {
cy.dataCy('navigation-icon', { timeout: 10000 }).should(
'have.length',
4,
);
GeneralUtils.validateAmountOfNavigationIcons(4);
} else if (testRole == UserRole.ROLE_DASHBOARD_ADMIN) {
cy.dataCy('navigation-icon', { timeout: 10000 }).should(
'have.length',
4,
);
GeneralUtils.validateAmountOfNavigationIcons(4);
} else if (testRole == UserRole.ROLE_DATA_EXPLORER_ADMIN) {
cy.dataCy('navigation-icon', { timeout: 10000 }).should(
'have.length',
4,
);
GeneralUtils.validateAmountOfNavigationIcons(4);
} else if (testRole == UserRole.ROLE_CONNECT_ADMIN) {
cy.dataCy('navigation-icon', { timeout: 10000 }).should(
'have.length',
3,
);
GeneralUtils.validateAmountOfNavigationIcons(3);
} else if (testRole == UserRole.ROLE_ASSET_ADMIN) {
cy.dataCy('navigation-icon', { timeout: 10000 }).should(
'have.length',
3,
);
GeneralUtils.validateAmountOfNavigationIcons(3);
}

// Login as admin and delete user
Expand Down

0 comments on commit e44d670

Please sign in to comment.