Skip to content

Commit

Permalink
[stable-4.6] Fix collections & repo test failures (#4756)
Browse files Browse the repository at this point in the history
* Fix `cy.get()` could not find a registered alias for: `@taskStatus.last`.

No-Issue

* remote_repo_edit: fix delete clear

by removing password from the test
  • Loading branch information
himdel authored Dec 16, 2023
1 parent 51aeb62 commit 0d4e24c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 73 deletions.
34 changes: 3 additions & 31 deletions test/cypress/e2e/collections/collection.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
const waitForTaskToFinish = (task, maxRequests, level = 0) => {
if (level === maxRequests) {
throw `Maximum requests exceeded.`;
}

cy.wait(task).then(({ response }) => {
if (response.body.state !== 'completed') {
cy.wait(1000);
waitForTaskToFinish(task, maxRequests, level + 1);
}
});
};

describe('collection tests', () => {
before(() => {
cy.deleteNamespacesAndCollections();
Expand All @@ -22,30 +9,15 @@ describe('collection tests', () => {

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

cy.visit('/ui/repo/published/test_namespace/test_collection');

cy.get('[data-cy=kebab-toggle]').click();
cy.get('[data-cy=delete-collection-dropdown]').click();
cy.get('input[id=delete_confirm]').click();

cy.intercept(
'DELETE',
Cypress.env('prefix') +
'v3/plugin/ansible/content/published/collections/index/test_namespace/test_collection',
).as('deleteCollection');
cy.intercept('GET', Cypress.env('prefix') + '/v3/tasks/*').as('taskStatus');

cy.get('button').contains('Delete').click();

cy.wait('@deleteCollection').its('response.statusCode').should('eq', 202);

waitForTaskToFinish('@taskStatus', 10);
cy.get('@taskStatus.last').then(() => {
cy.get('h4[class=pf-c-alert__title]').should(
'have.text',
'Success alert:Collection "test_collection" has been successfully deleted.',
);
});
cy.contains('No collections yet', { timeout: 10000 });
});

it('deletes a collection version', () => {
Expand Down
52 changes: 10 additions & 42 deletions test/cypress/e2e/repo/remote_repo_edit.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
describe('edit a remote repository', () => {
let remoteRepoUrl = '/ui/repositories?tab=remote';

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

it(`edits remote repo 'community'`, () => {
cy.visit(remoteRepoUrl);
cy.login();
cy.visit('/ui/repositories?tab=remote');
cy.get('[aria-label="Actions"]:first').click(); // click the kebab menu on the 'community' repo
cy.contains('Edit').click();
cy.get('input[id="name"]').should('be.disabled'); //has a readonly name field
cy.get('input[id="name"]').should('be.disabled'); // has a readonly name field
cy.get('input[id="url"]').clear();
cy.get('button').contains('Save').should('be.disabled'); // Save button disabled when required fields are missing
cy.get('[id="url-helper"]').should(
Expand All @@ -27,11 +22,7 @@ describe('edit a remote repository', () => {

// enter new values
cy.get('input[id="url"]').type('https://galaxy.ansible.com/api/');
cy.get('input[id="username"]').type('test');
cy.get('input[id="password"]').type('test');
cy.get('input[id="proxy_url"]').type('https://example.org');
cy.get('input[id="proxy_username"]').type('test');
cy.get('input[id="proxy_password"]').type('test');
cy.fixture('/yaml/test.yaml')
.then(Cypress.Blob.binaryStringToBlob)
.then((fileContent) => {
Expand All @@ -52,60 +43,47 @@ describe('edit a remote repository', () => {
cy.contains('Edit').click();

cy.contains('Show advanced options').click();
cy.get('input[id="username"]').should('have.value', 'test');
cy.get('input[id="proxy_url"]').should('have.value', 'https://example.org');
cy.get('input[id="proxy_username"]').should('have.value', 'test');
cy.contains('Save').click();
cy.wait('@editCommunityRemote');

// clear all values
cy.get('[aria-label="Actions"]:first').click(); // click the kebab menu on the 'community' repo
cy.contains('Edit').click();
cy.contains('Show advanced options').click();
cy.get('input[id="username"]').clear();
cy.get('input[type="password"]')
.siblings('button')
.click({ multiple: true });
cy.get('input[id="proxy_url"]').clear();
cy.get('input[id="proxy_username"]').clear();
cy.contains('Save').click();
cy.wait('@editCommunityRemote');

//check for clear values
// check for clear values
cy.get('[aria-label="Actions"]:first').click(); // click the kebab menu on the 'community' repo
cy.contains('Edit').click();
cy.contains('Show advanced options').click();
cy.get('input[id="username"]').should('be.empty');
cy.get('input[id="password"]').should('be.empty');
cy.get('input[id="proxy_url"]').should('be.empty');
cy.get('input[id="proxy_username"]').should('be.empty');
cy.contains('Save').click();
cy.wait('@editCommunityRemote');
});

it(`edits remote repo 'rh-certified'`, () => {
cy.visit(remoteRepoUrl);
cy.login();
cy.visit('/ui/repositories?tab=remote');
cy.get('[data-cy="kebab-toggle"]').should('be.visible');
cy.get('[data-cy="kebab-toggle"]').eq(1).click(); // click the kebab menu on the 'rh-certified' repo
cy.contains('Edit').click();
cy.get('input[id="name"]').should('be.disabled'); //has a readonly name field
cy.get('input[id="name"]').should('be.disabled'); // has a readonly name field
cy.get('input[id="url"]').clear();
cy.get('button').contains('Save').should('be.disabled'); // Save button disabled when required fields are missing
cy.get('[id="url-helper"]').should(
'have.text',
`The URL needs to be in 'http(s)://' format.`,
);
cy.contains('Show advanced options').click();

// enter new values
cy.get('input[id="url"]').type(
'https://cloud.redhat.com/api/automation-hub/',
'https://console.redhat.com/api/automation-hub/',
);
cy.get('input[id="username"]').type('test');
cy.get('input[id="password"]').type('test');

cy.get('input[id="proxy_url"]').type('https://example.org');
cy.get('input[id="proxy_username"]').type('test');
cy.get('input[id="proxy_password"]').type('test');
cy.intercept(
'PUT',
Cypress.env('prefix') + 'content/rh-certified/v3/sync/config/',
Expand All @@ -118,9 +96,7 @@ describe('edit a remote repository', () => {
cy.get('[aria-label="Actions"]').eq(1).click(); // click the kebab menu on the 'rh-certified' repo
cy.contains('Edit').click();
cy.contains('Show advanced options').click();
cy.get('input[id="username"]').should('have.value', 'test');
cy.get('input[id="proxy_url"]').should('have.value', 'https://example.org');
cy.get('input[id="proxy_username"]').should('have.value', 'test');
cy.intercept(
'PUT',
Cypress.env('prefix') + 'content/community/v3/sync/config/',
Expand All @@ -133,23 +109,15 @@ describe('edit a remote repository', () => {
cy.get('[aria-label="Actions"]').eq(1).click(); // click the kebab menu on the 'rh-certified' repo
cy.contains('Edit').click();
cy.contains('Show advanced options').click();
cy.get('input[id="username"]').clear();
cy.get('input[type="password"]')
.siblings('button')
.click({ multiple: true });
cy.get('input[id="proxy_url"]').clear();
cy.get('input[id="proxy_username"]').clear();
cy.contains('Save').click();
cy.wait('@editRemote');

//check for clear values
// check for clear values
cy.get('[aria-label="Actions"]').eq(1).click(); // click the kebab menu on the 'rh-certified' repo
cy.contains('Edit').click();
cy.contains('Show advanced options').click();
cy.get('input[id="username"]').should('be.empty');
cy.get('input[id="password"]').should('be.empty');
cy.get('input[id="proxy_url"]').should('be.empty');
cy.get('input[id="proxy_username"]').should('be.empty');
cy.contains('Save').click();
cy.wait('@editRemote');
});
Expand Down

0 comments on commit 0d4e24c

Please sign in to comment.