Skip to content

Commit

Permalink
fix(#3372): Add test for pipeline users
Browse files Browse the repository at this point in the history
  • Loading branch information
tenthe committed Dec 18, 2024
1 parent 8bdb9d4 commit 5ccba5f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ui/cypress/support/utils/pipeline/PipelineBtns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
*/

export class PipelineBtns {
public static statusPipeline() {
return cy.dataCy('status-pipeline-green', { timeout: 10000 });
}

public static stopPipeline() {
return cy.dataCy('stop-pipeline-button', { timeout: 10000 });
}

public static deletePipeline() {
return cy.dataCy('delete-pipeline', { timeout: 10000 });
}
Expand Down
2 changes: 1 addition & 1 deletion ui/cypress/support/utils/pipeline/PipelineUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class PipelineUtils {
cy.wait(1000);
cy.dataCy('no-table-entries').should('be.visible');
} else {
PipelineBtns.deletePipeline().should('have.length', amount);
PipelineBtns.statusPipeline().should('have.length', amount);
}
}

Expand Down
23 changes: 23 additions & 0 deletions ui/cypress/tests/userManagement/testUserRolePipeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
import { PipelineUtils } from '../../support/utils/pipeline/PipelineUtils';
import { GeneralUtils } from '../../support/utils/GeneralUtils';
import { PermissionUtils } from '../../support/utils/user/PermissionUtils';
import { PipelineBtns } from '../../support/utils/pipeline/PipelineBtns';

describe('Test User Roles for Pipelines', () => {
beforeEach('Setup Test', () => {
Expand Down Expand Up @@ -79,4 +80,26 @@ describe('Test User Roles for Pipelines', () => {
PipelineUtils.goToPipelines();
PipelineUtils.checkAmountOfPipelinesPipeline(1);
});

it(' Pipeline user should see shared pipelines of other users but not be able to edit them', () => {
const newUser = UserUtils.createUser(
'user',
UserRole.ROLE_PIPELINE_USER,
);

// Add new authorized user to pipeline
PipelineUtils.goToPipelines();
// PermissionUtils.markElementAsPublic();
PermissionUtils.authorizeUser(newUser.email);

// Login as user and check if pipeline is visible to user
UserUtils.switchUser(newUser);

PipelineUtils.goToPipelines();
PipelineUtils.checkAmountOfPipelinesPipeline(1);

// A pipeline user should not be able to stop the pipeline or delete it
PipelineBtns.deletePipeline().should('not.exist');
PipelineBtns.stopPipeline().should('be.disabled');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<div>
<div fxLayout="row" fxLayoutAlign="start center" fxFlex="150px">
<div
data-cy="status-pipeline-green"
*ngIf="
pipeline.running && pipeline.healthStatus === 'OK'
"
Expand Down Expand Up @@ -116,6 +117,7 @@
mat-icon-button
matTooltip="Stop pipeline"
matTooltipPosition="above"
data-cy="stop-pipeline-button"
(click)="
pipelineOperationsService.stopPipeline(
pipeline._id,
Expand Down

0 comments on commit 5ccba5f

Please sign in to comment.