Skip to content

Commit

Permalink
Fix failing HUB 2.4 UI tests (#5406)
Browse files Browse the repository at this point in the history
* Fix failing HUB 2.4 UI tests

* add more fixes

* more fixes and trying baseUrl instead of hardcoded localhost

* handling baseurl in a better way

* use containers instead of baseurl

* rbac test fix

* removing hardcode from podman pull

* fixing collection_detail test

* bringing waits back
  • Loading branch information
acruzgon authored Jan 10, 2025
1 parent ef71bc8 commit d5d0091
Show file tree
Hide file tree
Showing 16 changed files with 175 additions and 136 deletions.
6 changes: 4 additions & 2 deletions test/cypress/e2e/approval/approval_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ describe('Approval Dashboard process', () => {
).as('upload');
cy.galaxykit('-i namespace create', 'ansible');
cy.menuGo('Collections > Namespaces');

cy.get(`a[href="${uiPrefix}namespaces/ansible/"]`).click();
cy.contains('ansible')
.parents('.card-wrapper')
.contains('View collections')
.click();
cy.contains('Upload collection').click();
cy.fixture('collections/ansible-posix-1.4.0.tar.gz', 'binary')
.then(Cypress.Blob.binaryStringToBlob)
Expand Down
148 changes: 95 additions & 53 deletions test/cypress/e2e/collections/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ describe('collection tests', () => {
cy.login();
});

it('deletes an entire collection', () => {
it('delete an entire collection', () => {
cy.galaxykit('-i collection upload test_namespace test_collection');
cy.galaxykit('task wait all');

cy.visit(`${uiPrefix}repo/published/test_namespace/test_collection`);

cy.visit(`${uiPrefix}repo/staging/test_namespace/test_collection`);
cy.wait(2000);
cy.openHeaderKebab();
cy.get('[data-cy=delete-collection]').click();
cy.get('input[id=delete_confirm]').click();
cy.get('button').contains('Delete').click();
cy.contains('No collections yet', { timeout: 10000 });
});

it('deletes a collection version', () => {
it('delete a collection version', () => {
cy.galaxykit('-i collection upload my_namespace my_collection');
cy.galaxykit('task wait all');

Expand All @@ -38,9 +38,8 @@ describe('collection tests', () => {
cy.intercept('GET', `${apiPrefix}_ui/v1/namespaces/my_namespace/?*`).as(
'reload',
);
cy.get(
`a[href*="${uiPrefix}repo/published/my_namespace/my_collection"]`,
).click();
cy.visit(`${uiPrefix}repo/staging/my_namespace/my_collection`);
cy.wait(3000);
cy.openHeaderKebab();
cy.get('[data-cy=delete-collection-version]').click();
cy.get('input[id=delete_confirm]').click();
Expand All @@ -60,16 +59,16 @@ describe('collection tests', () => {
const collection = `bar_${rand}`;
cy.galaxykit(`-i collection upload ${namespace} ${collection}`);
cy.galaxykit('task wait all');
cy.visit(`${uiPrefix}repo/published/${namespace}/${collection}`);

cy.visit(`${uiPrefix}repo/staging/${namespace}/${collection}`);
cy.wait(2000);
cy.openHeaderKebab();
cy.get(
'[data-cy="copy-collection-version-to-repository-dropdown"]',
).click();

cy.contains('Select repositories');
cy.get(
'[data-cy="ApproveModal-CheckboxRow-row-published"] .pf-c-table__check input',
'[data-cy="ApproveModal-CheckboxRow-row-staging"] .pf-c-table__check input',
).should('be.disabled');

cy.get("[aria-label='name__icontains']").type('validate{enter}');
Expand All @@ -80,102 +79,145 @@ describe('collection tests', () => {
cy.get('.pf-m-primary').contains('Select').click();

cy.get('[data-cy="AlertList"]').contains(
`Started adding ${namespace}.${collection} v1.0.0 from "published" to repository "validated".`,
`Started adding ${namespace}.${collection} v1.0.0 from "staging" to repository "validated".`,
);
cy.galaxykit('task wait all');
cy.get('[data-cy="AlertList"]').contains('detail page').click();
cy.contains('Completed');
});

it('deletes an collection from repository', () => {
it('delete a collection from repository', () => {
const rand = Math.floor(Math.random() * 9999999);
const namespace = `namespace_${rand}`;
const collection = `collection_${rand}`;
const repo = `repo_${rand}`;
cy.deleteNamespacesAndCollections();
cy.deleteRepositories();
cy.galaxykit('-i collection upload test_namespace test_repo_collection2');
cy.galaxykit('repository create repo2 --pipeline approved');
cy.galaxykit('distribution create repo2');
cy.galaxykit(`-i collection upload ${namespace} ${collection}`);
cy.galaxykit(`repository create ${repo} --pipeline approved`);
cy.galaxykit(`distribution create ${repo}`);

cy.galaxykit('task wait all');
cy.galaxykit(
'collection copy test_namespace test_repo_collection2 1.0.0 published repo2',
cy.visit(`${uiPrefix}repo/staging/${namespace}/${collection}`);
cy.wait(2000);
cy.openHeaderKebab();
cy.get(
'[data-cy="copy-collection-version-to-repository-dropdown"]',
).click();
cy.get("[aria-label='name__icontains']").type(`${repo}{enter}`);
cy.get(
`[data-cy='ApproveModal-CheckboxRow-row-${repo}'] .pf-c-table__check input`,
).check();

cy.get('.pf-m-primary').contains('Select').click();

cy.get('[data-cy="AlertList"]').contains(
`Started adding ${namespace}.${collection} v1.0.0 from "staging" to repository "${repo}".`,
);
cy.galaxykit('task wait all');
cy.get('[data-cy="AlertList"]').contains('detail page').click();
cy.contains('Completed');

cy.visit(`${uiPrefix}collections?view_type=list`);
cy.contains('Collections');
cy.contains('[data-cy="CollectionListItem"]', 'published');
cy.contains('[data-cy="CollectionListItem"]', 'repo2');
cy.contains('[data-cy="CollectionListItem"]', repo);

cy.get('.collection-container [aria-label="Actions"]:first').click({
force: true,
});
cy.contains('Remove collection from repository').click();
cy.get('input[id=delete_confirm]').click();
cy.get('button').contains('Delete').click();
cy.contains(
'Collection "test_repo_collection2" has been successfully deleted.',
{
timeout: 10000,
},
);
cy.contains('[data-cy="CollectionListItem"]', 'repo2');
cy.contains('[data-cy="CollectionListItem"]', 'published').should(
'not.exist',
);

cy.contains(`Collection "${collection}" has been successfully deleted.`, {
timeout: 10000,
});
cy.contains('Collections');
cy.deleteAllCollections();
cy.deleteRepositories();
});

it('deletes an collection version from repository', () => {
it('delete a collection version from repository', () => {
const rand = Math.floor(Math.random() * 9999999);
const namespace = `namespace_${rand}`;
const collection = `collection_${rand}`;
const repo = `repo_${rand}`;
cy.deleteNamespacesAndCollections();
cy.deleteRepositories();
cy.galaxykit('repository create repo2 --pipeline approved');
cy.galaxykit('distribution create repo2');
cy.galaxykit(`repository create ${repo} --pipeline approved`);
cy.galaxykit(`distribution create ${repo}`);

cy.galaxykit(
'-i collection upload test_namespace test_repo_collection_version2 1.0.0',
);
cy.galaxykit(`-i collection upload ${namespace} ${collection} 1.0.0`);
cy.galaxykit('task wait all');
cy.galaxykit(
'collection copy test_namespace test_repo_collection_version2 1.0.0 published repo2',
);

cy.galaxykit(
'-i collection upload test_namespace test_repo_collection_version2 1.0.1',
cy.visit(`${uiPrefix}repo/staging/${namespace}/${collection}`);
cy.wait(3000);
cy.openHeaderKebab();
cy.get(
'[data-cy="copy-collection-version-to-repository-dropdown"]',
).click();
cy.get("[aria-label='name__icontains']").type(`${repo}{enter}`);
cy.get(
`[data-cy='ApproveModal-CheckboxRow-row-${repo}'] .pf-c-table__check input`,
).check();

cy.get('.pf-m-primary').contains('Select').click();

cy.get('[data-cy="AlertList"]').contains(
`Started adding ${namespace}.${collection} v1.0.0 from "staging" to repository "${repo}".`,
);
cy.galaxykit('task wait all');
cy.galaxykit(
'collection copy test_namespace test_repo_collection_version2 1.0.1 published repo2',
cy.get('[data-cy="AlertList"]').contains('detail page').click();
cy.contains('Completed');

cy.galaxykit(`-i collection upload ${namespace} ${collection} 1.0.1`);
cy.galaxykit('task wait all');

cy.visit(`${uiPrefix}repo/staging/${namespace}/${collection}`);
cy.wait(3000);
cy.openHeaderKebab();
cy.get(
'[data-cy="copy-collection-version-to-repository-dropdown"]',
).click();
cy.get("[aria-label='name__icontains']").type(`${repo}{enter}`);
cy.get(
`[data-cy='ApproveModal-CheckboxRow-row-${repo}'] .pf-c-table__check input`,
).check();

cy.get('.pf-m-primary').contains('Select').click();

cy.get('[data-cy="AlertList"]').contains(
`Started adding ${namespace}.${collection} v1.0.1 from "staging" to repository "${repo}".`,
);
cy.galaxykit('task wait all');
cy.get('[data-cy="AlertList"]').contains('detail page').click();
cy.contains('Completed');

cy.visit(`${uiPrefix}collections?view_type=list`);
cy.contains('Collections');
cy.contains('[data-cy="CollectionListItem"]', 'published');
cy.contains('[data-cy="CollectionListItem"]', 'repo2');

cy.contains('[data-cy="CollectionListItem"]', repo);
cy.visit(
`${uiPrefix}repo/repo2/test_namespace/test_repo_collection_version2/?version=1.0.0`,
`${uiPrefix}repo/${repo}/${namespace}/${collection}/?version=1.0.0`,
);

cy.wait(3000);
cy.openHeaderKebab();
cy.contains('Remove version 1.0.0 from repository').click();
cy.get('input[id=delete_confirm]').click();
cy.get('button').contains('Delete').click();
cy.contains(
'Collection "test_repo_collection_version2 v1.0.0" has been successfully deleted.',
`Collection "${collection} v1.0.0" has been successfully deleted.`,
{
timeout: 10000,
},
);

cy.visit(
`${uiPrefix}repo/repo2/test_namespace/test_repo_collection_version2/?version=1.0.0`,
`${uiPrefix}repo/${repo}/${namespace}/${collection}/?version=1.0.0`,
);
cy.contains(`We couldn't find the page you're looking for!`);

cy.visit(
`${uiPrefix}repo/published/test_namespace/test_repo_collection_version2/?version=1.0.0`,
`${uiPrefix}repo/staging/${namespace}/${collection}/?version=1.0.1`,
);
cy.contains('test_repo_collection_version2');
cy.contains(collection);
cy.contains(`We couldn't find the page you're looking for!`).should(
'not.exist',
);
Expand Down
24 changes: 12 additions & 12 deletions test/cypress/e2e/collections/collection_detail.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const uiPrefix = Cypress.env('uiPrefix');

describe('Collection detail', () => {
const baseURL = `${uiPrefix}repo/published/collection_detail_test_namespace/collection_detail_test_collection`;
const baseURL = `${uiPrefix}repo/staging/collection_detail_test_namespace/collection_detail_test_collection`;

function deprecate() {
cy.openHeaderKebab();
Expand All @@ -28,19 +28,19 @@ describe('Collection detail', () => {
cy.login();
});

it('can Deprecate', () => {
it('can Deprecate and then undeprecate', () => {
cy.visit(baseURL);
cy.wait(2000);
deprecate();
});

it('can Undeprecate', () => {
cy.visit(baseURL);
undeprecate();
});

it('should change the url when clicking on the tabs', () => {
cy.visit(baseURL);

cy.get('.title-box').should(
'have.text',
'collection_detail_test_collection',
);
const tabs = [
{
name: 'Documentation',
Expand Down Expand Up @@ -98,15 +98,15 @@ describe('Collection detail', () => {

it('should have working UI on install tab', () => {
cy.visit(baseURL);
cy.get('.title-box').should(
'have.text',
'collection_detail_test_collection',
);
// should have Install, License and Installation strings, and correct docs link
cy.get('.body').contains('Install');
cy.get('.body').contains('License');
cy.get('.body').contains('Installation');

cy.get('.body').contains(
`a[href="${uiPrefix}repo/published/collection_detail_test_namespace/collection_detail_test_collection/docs/"]`,
'Go to documentation',
);
cy.get('[data-cy="toggle-signature-button"]').scrollIntoView();

/*
* This test needs some external library and custom command to test if the download had started.
Expand Down
18 changes: 14 additions & 4 deletions test/cypress/e2e/collections/collection_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('Collection Upload Tests', () => {
cy.deleteTestUsers();
cy.createUser(userName, userPassword);
cy.galaxykit('-i collection upload testspace testcollection');
cy.galaxykit(`-i collection move testspace testcollection`);
});

it('should not upload new collection version in collection list when user does not have permissions', () => {
Expand Down Expand Up @@ -46,6 +47,7 @@ describe('Collection Upload Tests', () => {
cy.visit(
`${uiPrefix}collections?page_size=10&view_type=list&keywords=testcollection`,
);
cy.wait(2000);
cy.contains('testcollection');
cy.contains('Upload new version').click();
cy.contains('New version of testspace.testcollection');
Expand Down Expand Up @@ -76,8 +78,10 @@ describe('Collection Upload Tests', () => {
).as('upload');
cy.galaxykit('-i namespace create', 'ansible');
cy.menuGo('Collections > Namespaces');

cy.get(`a[href="${uiPrefix}namespaces/ansible/"]`).click();
cy.contains('ansible')
.parents('.card-wrapper')
.contains('View collections')
.click();
cy.contains('Upload collection').should('not.exist');
});

Expand All @@ -90,7 +94,11 @@ describe('Collection Upload Tests', () => {
cy.galaxykit('-i namespace create', 'ansible');
cy.menuGo('Collections > Namespaces');

cy.get(`a[href="${uiPrefix}namespaces/ansible/"]`).click();
cy.contains('ansible')
.parents('.card-wrapper')
.contains('View collections')
.click();

cy.contains('Upload collection').click();
cy.fixture('collections/ansible-posix-1.4.0.tar.gz', 'binary')
.then(Cypress.Blob.binaryStringToBlob)
Expand All @@ -113,7 +121,9 @@ describe('Collection Upload Tests', () => {
cy.login(userName, userPassword);
cy.visit(`${uiPrefix}namespaces/testspace`);

cy.get('[data-cy="CollectionList-name"]').contains('testcollection');
cy.get('[data-cy="CollectionList-name"]', { timeout: 3000 }).contains(
'testcollection',
);
cy.contains('Upload new version').should('not.exist');
});

Expand Down
Loading

0 comments on commit d5d0091

Please sign in to comment.