Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Approval Modal test #3504

Merged
merged 4 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
test:
- 'screenshots'
- 'approval'
- 'approval_modal'
- 'collections'
- 'ee_controller'
- 'execution_environments'
Expand Down
1 change: 1 addition & 0 deletions CHANGES/2248.task
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cypress tests for Approval with multiple repositories
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,9 @@ class CertificationDashboard extends React.Component<RouteProps, IState> {

private renderRow(collectionData: CollectionVersionSearch, index) {
const { collection_version: version, repository } = collectionData;
const data_cy = `CertificationDashboard-row-${collectionData.repository.name}-${collectionData.collection_version.namespace}-${collectionData.collection_version.name}`;
return (
<tr key={index} data-cy='CertificationDashboard-row'>
<tr key={index} data-cy={data_cy}>
<td>{version.namespace}</td>
<td>{version.name}</td>
<td>
Expand Down
6 changes: 3 additions & 3 deletions test/cypress/e2e/approval/approval_dashboard_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ describe('Approval Dashboard list tests for sorting, paging and filtering', () =
cy.get('[data-cy="sort_name"]').click();
cy.get('[data-cy="body"]').contains('approval');

cy.get('[data-cy="CertificationDashboard-row"]:first').contains(
cy.get('[data-cy^="CertificationDashboard-row"]:first').contains(
items[items.length - 1].name,
);
cy.get('[data-cy="CertificationDashboard-row"]').contains(
cy.get('[data-cy^="CertificationDashboard-row"]').contains(
items[items.length - 2].name,
);
cy.get('[data-cy="CertificationDashboard-row"]').contains(
cy.get('[data-cy^="CertificationDashboard-row"]').contains(
items[items.length - 3].name,
);
});
Expand Down
8 changes: 4 additions & 4 deletions test/cypress/e2e/approval/approval_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ describe('Approval Dashboard process', () => {

// should approve
cy.visit(`${uiPrefix}approval-dashboard`);
cy.contains('[data-cy="CertificationDashboard-row"]', 'Needs review');
cy.contains('[data-cy^="CertificationDashboard-row"]', 'Needs review');
cy.contains(
'[data-cy="CertificationDashboard-row"] button',
'[data-cy^="CertificationDashboard-row"] button',
'Sign and approve',
).click();
cy.contains('.body', 'No results found', { timeout: 8000 });
cy.visit(`${uiPrefix}approval-dashboard`);
cy.contains('button', 'Clear all filters').click();
cy.contains(
'[data-cy="CertificationDashboard-row"]',
'[data-cy^="CertificationDashboard-row"]',
'Signed and approved',
);

Expand All @@ -45,7 +45,7 @@ describe('Approval Dashboard process', () => {
{ force: true },
);
cy.contains('Reject').click({ force: true });
cy.contains('[data-cy="CertificationDashboard-row"]', 'Rejected');
cy.contains('[data-cy^="CertificationDashboard-row"]', 'Rejected');

// should not see items in collections
cy.visit(`${uiPrefix}collections`);
Expand Down
4 changes: 2 additions & 2 deletions test/cypress/e2e/approval/collection_approval.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ describe('tests the approval list screen ', () => {
cy.get('button[aria-label="Actions"]:first').click();
cy.contains('Reject').click();
cy.contains(
'[data-cy="CertificationDashboard-row"]:first-child',
'[data-cy^="CertificationDashboard-row"]:first-child',
'Rejected',
);

// approve
cy.get('button[aria-label="Actions"]:first').click();
cy.contains('Sign and approve').click();
cy.contains(
'[data-cy="CertificationDashboard-row"]:first-child',
'[data-cy^="CertificationDashboard-row"]:first-child',
'Signed and approved',
);
});
Expand Down
217 changes: 217 additions & 0 deletions test/cypress/e2e/approval_modal/approval_multiple_repos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
import { range } from 'lodash';

const uiPrefix = Cypress.env('uiPrefix');
const apiPrefix = Cypress.env('apiPrefix');

function openModal(menu) {
cy.visit(`${uiPrefix}approval-dashboard`);
cy.contains('Clear all filters').click();

if (menu) {
cy.get(
'[data-cy^="CertificationDashboard-row"] [aria-label="Actions"]',
).click();
cy.contains('a', 'Sign and approve').click();
} else {
cy.contains(
'[data-cy^="CertificationDashboard-row"] button',
'Sign and approve',
).click();
}

cy.contains('Select repositories');
}

function toggleItem(name) {
cy.get('.modal-body [data-cy="compound_filter"] input')
.clear()
.type(name + '{enter}');
cy.get(`[data-cy="ApproveModal-CheckboxRow-row-${name}"] input`).click();
}

function menuActionClick(repo, action) {
cy.get(
`[data-cy="CertificationDashboard-row-${repo}-namespace-collection1"] [aria-label="Actions"]`,
).click();
cy.contains('[data-cy="kebab-toggle"] a', action).click();
}

function rejectItem(repo) {
menuActionClick(repo, 'Reject');
cy.contains(
'Certification status for collection "namespace collection1 v1.0.0" has been successfully updated.',
{ timeout: 10000 },
);
cy.visit(`${uiPrefix}approval-dashboard`);
cy.contains('Clear all filters').click();
cy.contains(
`[data-cy="CertificationDashboard-row-rejected-namespace-collection1"]`,
'Rejected',
);
}

const reposList = [];

describe('Approval Dashboard process with multiple repos', () => {
before(() => {
cy.deleteNamespacesAndCollections();
cy.galaxykit('-i namespace create', 'namespace');
cy.galaxykit('-i collection upload', 'namespace', 'collection1');

const max = 11;
range(1, max).forEach((i) => {
reposList.push('repo' + i);
});

reposList.push('published');

cy.login();

range(1, max).forEach((i) => {
cy.galaxykit('-i distribution delete', 'repo' + i);
});

cy.galaxykit('-i task wait all');

cy.request(apiPrefix + 'pulp/api/v3/repositories/ansible/ansible/').then(
(data) => {
const list = data.body.results;
list.forEach((repo) => {
if (
repo.pulp_labels?.pipeline == 'approved' &&
repo.name != 'published'
) {
cy.log('deleting repository' + repo.name);
cy.galaxykit('-i repository delete', repo.name);
}
});
cy.galaxykit('-i task wait all');
range(1, max).forEach((i) => {
cy.galaxykit(
`-i repository create`,
'repo' + i,
'--pipeline=approved',
);
cy.galaxykit('-i distribution create', 'repo' + i);
});
cy.galaxykit('-i task wait all');
},
);

// prepare another staging
cy.galaxykit('-i distribution delete', 'staging2');
cy.galaxykit('-i repository delete', 'staging2');

cy.galaxykit('-i repository create', 'staging2', '--pipeline=staging');
cy.galaxykit('-i distribution create', 'staging2');
});

beforeEach(() => {
cy.login();
});

it('should contains no colletctions in list.', () => {
cy.visit(`${uiPrefix}collections`);
cy.contains('No collections yet');
});

it('should approve, reject and reapprove.', () => {
openModal();
toggleItem('repo1');
toggleItem('repo2');
toggleItem('published');
cy.contains('button', 'Select').click();
cy.contains(
'Certification status for collection "namespace collection1 v1.0.0" has been successfully updated.',
{ timeout: 20000 },
);

cy.visit(`${uiPrefix}approval-dashboard`);
cy.contains('No results found');
cy.contains('Clear all filters').click();
cy.contains('[aria-label="Collection versions"]', 'repo1');
cy.contains('[aria-label="Collection versions"]', 'repo2');
cy.contains('[aria-label="Collection versions"]', 'published');

rejectItem('repo1');
rejectItem('published');

// 2 items should be left there
cy.contains('.toolbar', '1 - 2 of 2');
cy.get(
'[data-cy="CertificationDashboard-row-rejected-namespace-collection1"]',
);
cy.get(
'[data-cy="CertificationDashboard-row-repo2-namespace-collection1"]',
);
cy.get(
'[data-cy="CertificationDashboard-row-repo1-namespace-collection1"]',
).should('not.exist');
cy.get(
'[data-cy="CertificationDashboard-row-published-namespace-collection1"]',
).should('not.exist');

// reapprove
menuActionClick('rejected', 'Sign and approve');
cy.contains('Select repositories');
cy.contains('[aria-label="Label group category"]', 'repo2');
toggleItem('repo1');
cy.contains('button', 'Select').click();
cy.contains(
'Certification status for collection "namespace collection1 v1.0.0" has been successfully updated.',
{ timeout: 20000 },
);

cy.visit(`${uiPrefix}approval-dashboard`);
cy.contains('Clear all filters').click();
cy.contains('.toolbar', '1 - 2 of 2');
cy.get(
'[data-cy="CertificationDashboard-row-repo2-namespace-collection1"]',
);
cy.get(
'[data-cy="CertificationDashboard-row-repo1-namespace-collection1"]',
);
cy.get(
'[data-cy="CertificationDashboard-row-published-namespace-collection1"]',
).should('not.exist');
cy.get(
'[data-cy="CertificationDashboard-row-rejected-namespace-collection1"]',
).should('not.exist');
});

it('should be able to approve from different staging repo', () => {
cy.deleteNamespacesAndCollections();
cy.galaxykit('-i namespace create', 'namespace');
cy.galaxykit('-i collection upload', 'namespace', 'collection1');
cy.galaxykit(
'-i collection move',
'namespace',
'collection1',
'1.0.0',
'staging',
'staging2',
);

cy.visit(`${uiPrefix}approval-dashboard`);
cy.get(
'[data-cy="CertificationDashboard-row-staging2-namespace-collection1"]',
);

openModal();
toggleItem('repo1');
toggleItem('repo2');
toggleItem('published');
cy.contains('button', 'Select').click();
cy.contains(
'Certification status for collection "namespace collection1 v1.0.0" has been successfully updated.',
{ timeout: 20000 },
);

cy.visit(`${uiPrefix}approval-dashboard`);
cy.contains('No results found');
cy.contains('Clear all filters').click();
cy.contains('[aria-label="Collection versions"]', 'repo1');
cy.contains('[aria-label="Collection versions"]', 'repo2');
cy.contains('[aria-label="Collection versions"]', 'published');
});
});
Loading