Skip to content

Commit

Permalink
Update tests to run with gateway (when CYPRESS_HUB_GATEWAY=true) (#5136)
Browse files Browse the repository at this point in the history
* Update tests to run with gateway (when CYPRESS_HUB_GATEWAY=true)

User Access > Users
  no create, no edit, no delete

User Access > Groups
  no create, no delete
  no add/remove users
  yes add/remove roles

User Access > Roles
  yes add/edit/delete

No-Issue

* add feature flag tests

* prettier

* increase defaltCommandTimeout, remove some custom timeouts

* handle no source.parameter in namespace modal

* more tests as only standalone - where creating users

* community ci: disable signatures

* ignore text in modal
  • Loading branch information
himdel authored Jun 27, 2024
1 parent e1cde29 commit 26e7538
Show file tree
Hide file tree
Showing 24 changed files with 229 additions and 179 deletions.
12 changes: 11 additions & 1 deletion src/components/namespace-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,18 @@ export const NamespaceModal = ({
onCreateSuccess(data);
})
.catch((error) => {
const nofield = [];

for (const e of error.response.data.errors) {
errorMessages[e.source.parameter] = e.detail;
if (e.source) {
errorMessages[e.source.parameter] = e.detail;
} else {
nofield.push(e.detail || e.title);
}
}

if (nofield.length) {
errorMessages.__nofield = nofield.join('\n');
}

setNameValid(!('name' in errorMessages));
Expand Down
1 change: 1 addition & 0 deletions test/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = defineConfig({
viewportWidth: 1280,
viewportHeight: 800,
e2e: {
defaultCommandTimeout: 20000,
setupNodeEvents(on, _config) {
if (process.env.CONSOLE_LOG_TO_TERMINAL) {
return require('./cypress/plugins/console-logger').install(on);
Expand Down
4 changes: 0 additions & 4 deletions test/cypress/e2e/approval-modal/approval-multiple-repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ 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();
Expand Down Expand Up @@ -113,7 +112,6 @@ describe('Approval Dashboard process with multiple repos', () => {
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`);
Expand Down Expand Up @@ -144,7 +142,6 @@ describe('Approval Dashboard process with multiple repos', () => {
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`);
Expand Down Expand Up @@ -183,7 +180,6 @@ describe('Approval Dashboard process with multiple repos', () => {
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`);
Expand Down
21 changes: 21 additions & 0 deletions test/cypress/e2e/approval-modal/feature-flags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const apiPrefix = Cypress.env('apiPrefix');

describe('Feature flags', () => {
it('match expectations', () => {
cy.request(`${apiPrefix}_ui/v1/feature-flags/`).then(({ body }) => {
expect(body._messages).to.be.empty;
expect(body).to.include({ ai_deny_index: false });
expect(body).to.include({ can_create_signatures: true });
expect(body).to.include({ can_upload_signatures: false });
expect(body).to.include({ collection_auto_sign: true });
expect(body).to.include({ collection_signing: true });
expect(body).to.include({ container_signing: true });
expect(body).to.include({ display_repositories: true });
expect(body).to.include({ display_signatures: true });
expect(body).to.include({ execution_environments: true });
expect(body).to.include({ legacy_roles: false });
expect(body).to.include({ require_upload_signatures: false });
expect(body).to.include({ signatures_enabled: true });
});
});
});
4 changes: 2 additions & 2 deletions test/cypress/e2e/approval/approval-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Approval Dashboard process', () => {
cy.visit(`${uiPrefix}approval-dashboard`);
cy.contains('[data-cy^="ApprovalRow"]', 'Needs review');
cy.contains('[data-cy^="ApprovalRow"] button', 'Sign and approve').click();
cy.contains('.body', 'No results found', { timeout: 8000 });
cy.contains('.body', 'No results found');
cy.visit(`${uiPrefix}approval-dashboard`);
cy.contains('button', 'Clear all filters').click();
cy.contains('[data-cy^="ApprovalRow"]', 'Signed and approved');
Expand Down Expand Up @@ -77,7 +77,7 @@ describe('Approval Dashboard process', () => {
cy.wait(10000);
cy.contains('My imports');
cy.get('.pf-v5-c-label__content').contains('Running').should('exist');
cy.wait('@upload', { timeout: 10000 });
cy.wait('@upload');
cy.wait(5000);
cy.get('.pf-v5-c-label__content').contains('Failed').should('not.exist');
cy.get('.pf-v5-c-label__content').contains('Completed').should('exist');
Expand Down
5 changes: 1 addition & 4 deletions test/cypress/e2e/approval/signing.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ describe('signing versions - auto sign on approval', () => {

// Go and check if it is signed in the collections
cy.visit(`${uiPrefix}collections`);
cy.get('[data-cy="signature-badge"]', { timeout: 20000 }).should(
'have.length',
1,
);
cy.get('[data-cy="signature-badge"]').should('have.length', 1);
cy.get('[data-cy="signature-badge"]').first().should('contain', 'Signed');

// Optimization: check the signature button too here
Expand Down
10 changes: 3 additions & 7 deletions test/cypress/e2e/collections/collection-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ describe('Collection detail', () => {
function deprecate() {
cy.openHeaderKebab();
cy.contains('Deprecate').click();
cy.contains('This collection has been deprecated.', { timeout: 10000 });
cy.contains('This collection has been deprecated.');
}

function undeprecate() {
cy.openHeaderKebab();
cy.contains('Undeprecate').click();
cy.contains('This collection has been deprecated.', {
timeout: 10000,
}).should('not.exist');
cy.contains('This collection has been deprecated.').should('not.exist');
}

before(() => {
Expand Down Expand Up @@ -80,9 +78,7 @@ describe('Collection detail', () => {
}

if (tab.name == 'Import log') {
cy.contains('.body', 'Approval status', {
timeout: 10000,
});
cy.contains('.body', 'Approval status');
}

if (tab.name == 'Contents') {
Expand Down
2 changes: 1 addition & 1 deletion test/cypress/e2e/collections/collection-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('Collection Upload Tests', () => {
cy.get('[data-cy="confirm-upload"]').click();
cy.wait('@upload');
cy.contains('My imports');
cy.get('.pf-v5-c-label__content').contains('Completed', { timeout: 15000 });
cy.get('.pf-v5-c-label__content').contains('Completed');
cy.get('.pf-v5-c-label__content').contains('Failed').should('not.exist');
cy.get('.pf-v5-c-label__content').contains('Running').should('not.exist');
});
Expand Down
8 changes: 1 addition & 7 deletions test/cypress/e2e/collections/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('collection tests', () => {
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 });
cy.contains('No collections yet');
});

it('deletes a collection version', () => {
Expand Down Expand Up @@ -113,9 +113,6 @@ describe('collection tests', () => {
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(
Expand Down Expand Up @@ -167,9 +164,6 @@ describe('collection tests', () => {
cy.get('button').contains('Delete').click();
cy.contains(
'Collection "test_repo_collection_version2 v1.0.0" has been successfully deleted.',
{
timeout: 10000,
},
);

cy.visit(
Expand Down
14 changes: 4 additions & 10 deletions test/cypress/e2e/collections/collections-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ describe('Collections list Tests', () => {

cy.get('.collection-container [aria-label="Actions"]').click();
cy.contains('Deprecate').click();
cy.contains('No results found', { timeout: 10000 });
cy.contains('No results found');
}

function undeprecate() {
cy.visit(`${uiPrefix}repo/published/my_namespace/my_collection0`);
cy.contains('This collection has been deprecated.');
cy.openHeaderKebab();
cy.contains('Undeprecate').click();
cy.contains('This collection has been deprecated.', {
timeout: 10000,
}).should('not.exist');
cy.contains('This collection has been deprecated.').should('not.exist');
}

function undeprecateIfDeprecated() {
Expand Down Expand Up @@ -138,9 +136,7 @@ describe('Collections list Tests', () => {
cy.contains('Delete collection from system').click();
cy.get('[data-cy=modal_checkbox] input').click();
cy.get('[data-cy=delete-button] button').click();
cy.contains('Collection "my_collection0" has been successfully deleted.', {
timeout: 15000,
});
cy.contains('Collection "my_collection0" has been successfully deleted.');
cy.contains('No results found');
});

Expand All @@ -156,9 +152,7 @@ describe('Collections list Tests', () => {
cy.get('[data-cy=modal_checkbox] input').click();
cy.get('[data-cy=delete-button] button').click();

cy.contains('Collection "my_collection1" has been successfully deleted.', {
timeout: 15000,
});
cy.contains('Collection "my_collection1" has been successfully deleted.');
cy.contains('No results found');
});
});
5 changes: 4 additions & 1 deletion test/cypress/e2e/community/compose.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
PULP_GALAXY_ENABLE_UNAUTHENTICATED_COLLECTION_ACCESS='true'
PULP_GALAXY_ENABLE_UNAUTHENTICATED_COLLECTION_DOWNLOAD='true'
PULP_GALAXY_REQUIRE_CONTENT_APPROVAL='false'
PULP_GALAXY_FEATURE_FLAGS__ai_deny_index='true'
PULP_GALAXY_FEATURE_FLAGS__collection_signing='false'
PULP_GALAXY_FEATURE_FLAGS__container_signing='false'
PULP_GALAXY_FEATURE_FLAGS__display_repositories='false'
PULP_GALAXY_FEATURE_FLAGS__execution_environments='false'
PULP_GALAXY_FEATURE_FLAGS__legacy_roles='true'
PULP_GALAXY_FEATURE_FLAGS__signatures_enabled='false'
PULP_GALAXY_REQUIRE_CONTENT_APPROVAL='false'
22 changes: 22 additions & 0 deletions test/cypress/e2e/community/feature-flags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const apiPrefix = Cypress.env('apiPrefix');

describe('Feature flags', () => {
it('match expectations', () => {
cy.request(`${apiPrefix}_ui/v1/feature-flags/`).then(({ body }) => {
expect(body._messages).to.be.empty;
expect(body).to.include({ ai_deny_index: true });
expect(body).to.include({ can_create_signatures: false });
expect(body).to.include({ can_upload_signatures: false });
expect(body).to.include({ collection_auto_sign: false });
expect(body).to.include({ collection_signing: false });
expect(body).to.include({ container_signing: false });
expect(body).to.include({ display_repositories: false });
expect(body).to.include({ display_signatures: false });
expect(body).to.include({ execution_environments: false });
expect(body).to.include({ external_authentication: true });
expect(body).to.include({ legacy_roles: true });
expect(body).to.include({ require_upload_signatures: false });
expect(body).to.include({ signatures_enabled: false });
});
});
});
1 change: 0 additions & 1 deletion test/cypress/e2e/namespaces/docs-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ describe('Documentation dropdown', () => {
cy.get('[data-cy="docs-dropdown"]').click();
cy.get('.pf-v5-c-dropdown__menu').contains('About').click();
cy.get('.pf-v5-c-about-modal-box').should('be.visible');
cy.get('h1').contains('Galaxy NG');
cy.get('[aria-label="Close Dialog"]').click();
cy.get('.pf-v5-c-about-modal-box').should('not.exist');
});
Expand Down
4 changes: 2 additions & 2 deletions test/cypress/e2e/namespaces/group-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ describe('Hub Group Management Tests', () => {
cy.login();
});

it('admin user can create/delete a group', () => {
it.standalone('admin user can create/delete a group', () => {
const name = 'testGroup';

createGroupManually(name);
deleteGroupManually(name);
cy.contains('No groups yet').should('exist');
});

it('admin user can add/remove a user to/from a group', () => {
it.standalone('admin user can add/remove a user to/from a group', () => {
const groupName = 'testGroup';
const userName = 'testUser';

Expand Down
17 changes: 10 additions & 7 deletions test/cypress/e2e/namespaces/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ describe('Login helpers', () => {
cy.galaxykit('user create', username, password);
});

it('can login manually and logout as admin or different user', () => {
manualLogin(username, password);
cy.contains(username);
manualLogout();
manualLogin(adminUsername, adminPassword);
cy.contains(adminUsername);
});
it.standalone(
'can login manually and logout as admin or different user',
() => {
manualLogin(username, password);
cy.contains(username);
manualLogout();
manualLogin(adminUsername, adminPassword);
cy.contains(adminUsername);
},
);

it('can use api login', () => {
cy.login();
Expand Down
2 changes: 1 addition & 1 deletion test/cypress/e2e/namespaces/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const helperText = (id) =>
.parents('.pf-v5-c-form__group')
.find('.pf-v5-c-helper-text__item-text');

describe('My Profile Tests', () => {
describe.standalone('My Profile Tests', () => {
const username = 'nopermission';
const password = 'n0permissi0n';

Expand Down
2 changes: 1 addition & 1 deletion test/cypress/e2e/namespaces/rbac-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function testAccessTab({
cy.get(
`[data-cy="RoleListTable-ExpandableRow-row-${role}"] .pf-v5-c-table__toggle button`,
).click();
cy.contains('.pf-v5-c-label', permissionLabel, { timeout: 10000 });
cy.contains('.pf-v5-c-label', permissionLabel);

// role list view, remove
cy.get(
Expand Down
Loading

0 comments on commit 26e7538

Please sign in to comment.