Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5e7e4da

Browse files
committedMay 24, 2023
insights test: give up on failing requests in insights mode
copy insights tests, add before each with uncaught drop api mocks No-Issue
1 parent 0e31a92 commit 5e7e4da

15 files changed

+931
-164
lines changed
 

‎config/webpack.base.config.js

-35
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,6 @@ const defaultConfigs = [
4545
{ name: 'API_PROXY_TARGET', default: undefined, scope: 'webpack' },
4646
];
4747

48-
const insightsMockAPIs = ({ app }) => {
49-
// GET
50-
[
51-
{
52-
url: '/api/chrome-service/v1/user',
53-
response: {
54-
data: {
55-
lastVisited: [],
56-
favoritePages: [],
57-
visitedBundles: {},
58-
},
59-
},
60-
},
61-
{ url: '/api/featureflags/v0', response: { toggles: [] } },
62-
{ url: '/api/quickstarts/v1/progress', response: { data: [] } },
63-
{ url: '/api/rbac/v1/access', response: { data: [] } },
64-
{ url: '/api/rbac/v1/cross-account-requests', response: { data: [] } },
65-
].forEach(({ url, response }) =>
66-
app.get(url, (_req, res) => res.send(response)),
67-
);
68-
69-
// POST
70-
[
71-
{ url: '/api/chrome-service/v1/last-visited', response: { data: [] } },
72-
{
73-
url: '/api/chrome-service/v1/user/visited-bundles',
74-
response: { data: [] },
75-
},
76-
{ url: '/api/featureflags/v0/client/metrics', response: {} },
77-
].forEach(({ url, response }) =>
78-
app.post(url, (_req, res) => res.send(response)),
79-
);
80-
};
81-
8248
module.exports = (inputConfigs) => {
8349
const customConfigs = {};
8450
const globals = {};
@@ -137,7 +103,6 @@ module.exports = (inputConfigs) => {
137103
rbac,
138104
...defaultServices,
139105
},
140-
registry: [insightsMockAPIs],
141106
}),
142107

143108
// insights deployments from master

‎test/cypress/e2e/collections/collection_upload.js

+66-75
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const apiPrefix = Cypress.env('apiPrefix');
22
const uiPrefix = Cypress.env('uiPrefix');
3-
const insightsLogin = Cypress.env('insightsLogin');
43

54
describe('Collection Upload Tests', () => {
65
const userName = 'testUser';
@@ -9,61 +8,57 @@ describe('Collection Upload Tests', () => {
98
before(() => {
109
cy.deleteNamespacesAndCollections();
1110

12-
if (!insightsLogin) {
13-
cy.login();
14-
cy.deleteTestGroups();
15-
cy.deleteTestUsers();
16-
cy.createUser(userName, userPassword);
17-
}
11+
cy.login();
12+
cy.deleteTestGroups();
13+
cy.deleteTestUsers();
14+
cy.createUser(userName, userPassword);
1815
cy.createApprovedCollection('testspace', 'testcollection');
1916
});
2017

21-
if (!insightsLogin) {
22-
it('should not upload new collection version in collection list when user does not have permissions', () => {
23-
cy.login(userName, userPassword);
24-
cy.visit(
25-
`${uiPrefix}collections?page_size=10&view_type=list&keywords=testcollection`,
26-
);
27-
cy.contains('testcollection');
28-
cy.contains('Upload new version').should('not.exist');
29-
});
30-
31-
it('should not upload new collection version in collection list/cards when user does not have permissions', () => {
32-
cy.login(userName, userPassword);
33-
cy.visit(
34-
`${uiPrefix}collections?page_size=10&view_type=card&keywords=testcollection`,
35-
);
36-
cy.contains('testcollection');
37-
cy.get('[aria-label="Actions"]').should('not.exist');
38-
});
39-
40-
it('should not upload new collection version in collection detail when user does not have permissions', () => {
41-
cy.login(userName, userPassword);
42-
cy.visit(`${uiPrefix}repo/published/testspace/testcollection`);
43-
cy.contains('testcollection');
44-
cy.get('button[aria-label="Actions"]').click();
45-
cy.contains('Upload new version').click();
46-
cy.contains("You don't have rights to do this operation.");
47-
});
48-
49-
it('should see upload new collection version in collection list when user does have permissions', () => {
50-
cy.login();
51-
cy.visit(
52-
`${uiPrefix}collections?page_size=10&view_type=list&keywords=testcollection`,
53-
);
54-
cy.contains('testcollection');
55-
cy.contains('Upload new version').click();
56-
cy.contains('New version of testcollection');
57-
58-
cy.visit(
59-
`${uiPrefix}collections?page_size=10&view_type=card&keywords=testcollection`,
60-
);
61-
cy.contains('testcollection');
62-
cy.get('button[aria-label="Actions"]').click();
63-
cy.contains('Upload new version').click();
64-
cy.contains('New version of testcollection');
65-
});
66-
}
18+
it('should not upload new collection version in collection list when user does not have permissions', () => {
19+
cy.login(userName, userPassword);
20+
cy.visit(
21+
`${uiPrefix}collections?page_size=10&view_type=list&keywords=testcollection`,
22+
);
23+
cy.contains('testcollection');
24+
cy.contains('Upload new version').should('not.exist');
25+
});
26+
27+
it('should not upload new collection version in collection list/cards when user does not have permissions', () => {
28+
cy.login(userName, userPassword);
29+
cy.visit(
30+
`${uiPrefix}collections?page_size=10&view_type=card&keywords=testcollection`,
31+
);
32+
cy.contains('testcollection');
33+
cy.get('[aria-label="Actions"]').should('not.exist');
34+
});
35+
36+
it('should not upload new collection version in collection detail when user does not have permissions', () => {
37+
cy.login(userName, userPassword);
38+
cy.visit(`${uiPrefix}repo/published/testspace/testcollection`);
39+
cy.contains('testcollection');
40+
cy.get('button[aria-label="Actions"]').click();
41+
cy.contains('Upload new version').click();
42+
cy.contains("You don't have rights to do this operation.");
43+
});
44+
45+
it('should see upload new collection version in collection list when user does have permissions', () => {
46+
cy.login();
47+
cy.visit(
48+
`${uiPrefix}collections?page_size=10&view_type=list&keywords=testcollection`,
49+
);
50+
cy.contains('testcollection');
51+
cy.contains('Upload new version').click();
52+
cy.contains('New version of testcollection');
53+
54+
cy.visit(
55+
`${uiPrefix}collections?page_size=10&view_type=card&keywords=testcollection`,
56+
);
57+
cy.contains('testcollection');
58+
cy.get('button[aria-label="Actions"]').click();
59+
cy.contains('Upload new version').click();
60+
cy.contains('New version of testcollection');
61+
});
6762

6863
it('should see upload new collection version in collection detail when user does have permissions', () => {
6964
cy.login();
@@ -74,20 +69,18 @@ describe('Collection Upload Tests', () => {
7469
cy.contains('New version of testcollection');
7570
});
7671

77-
if (!insightsLogin) {
78-
it('user should not be able to upload new collection without permissions', () => {
79-
cy.login(userName, userPassword);
80-
cy.intercept(
81-
'GET',
82-
`${apiPrefix}v3/plugin/ansible/search/collection-versions/?namespace=*`,
83-
).as('upload');
84-
cy.galaxykit('-i namespace create', 'ansible');
85-
cy.menuGo('Collections > Namespaces');
86-
87-
cy.get(`a[href="${uiPrefix}namespaces/ansible/"]`).click();
88-
cy.contains('Upload collection').should('not.exist');
89-
});
90-
}
72+
it('user should not be able to upload new collection without permissions', () => {
73+
cy.login(userName, userPassword);
74+
cy.intercept(
75+
'GET',
76+
`${apiPrefix}v3/plugin/ansible/search/collection-versions/?namespace=*`,
77+
).as('upload');
78+
cy.galaxykit('-i namespace create', 'ansible');
79+
cy.menuGo('Collections > Namespaces');
80+
81+
cy.get(`a[href="${uiPrefix}namespaces/ansible/"]`).click();
82+
cy.contains('Upload collection').should('not.exist');
83+
});
9184

9285
it('collection should be uploaded', () => {
9386
cy.login();
@@ -120,15 +113,13 @@ describe('Collection Upload Tests', () => {
120113
cy.get('.pf-c-label__content').contains('Completed').should('exist');
121114
});
122115

123-
if (!insightsLogin) {
124-
it('should not upload new collection version when user does not have permissions', () => {
125-
cy.login(userName, userPassword);
126-
cy.visit(`${uiPrefix}namespaces/testspace`);
116+
it('should not upload new collection version when user does not have permissions', () => {
117+
cy.login(userName, userPassword);
118+
cy.visit(`${uiPrefix}namespaces/testspace`);
127119

128-
cy.get('[data-cy="CollectionList-name"]').contains('testcollection');
129-
cy.contains('Upload new version').should('not.exist');
130-
});
131-
}
120+
cy.get('[data-cy="CollectionList-name"]').contains('testcollection');
121+
cy.contains('Upload new version').should('not.exist');
122+
});
132123

133124
it('should deprecate let user deprecate and undeprecate collections', () => {
134125
cy.login();

‎test/cypress/e2e/collections/collections_list.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { range } from 'lodash';
22

33
const apiPrefix = Cypress.env('apiPrefix');
44
const uiPrefix = Cypress.env('uiPrefix');
5-
const insightsLogin = Cypress.env('insightsLogin');
65

76
describe('Collections list Tests', () => {
87
function deprecate(list) {
@@ -64,11 +63,9 @@ describe('Collections list Tests', () => {
6463
cy.contains('Collections');
6564
});
6665

67-
if (!insightsLogin) {
68-
it('checks if its deprecated and if yes, undeprecate it', () => {
69-
undeprecateIfDeprecated();
70-
});
71-
}
66+
it('checks if its deprecated and if yes, undeprecate it', () => {
67+
undeprecateIfDeprecated();
68+
});
7269

7370
it('can deprecate', () => {
7471
cy.get('[data-cy="view_type_list"] svg').click();

‎test/cypress/e2e/insights/menu.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ describe('Insights Menu Tests', () => {
3030
});
3131

3232
beforeEach(() => {
33+
cy.on('uncaught:exception', () => false);
3334
cy.login();
3435
cy.visit(uiPrefix);
3536
cy.wait(2000);
@@ -71,12 +72,6 @@ describe('Insights Menu Tests', () => {
7172
});
7273

7374
it('can navigate to Connect to Hub', () => {
74-
cy.on('uncaught:exception', () => {
75-
return false;
76-
// this is needed, otherwise it fails on (fetch)POST 404 /api/featureflags/v0/client/metrics
77-
// it seems that cy on duration is valid inside it, it does not catch api calls outisde
78-
});
79-
8075
menuClick('Connect to Hub');
8176
cy.contains('main', 'Connect Private Automation Hub');
8277
cy.contains('main .body', 'Connect Private Automation Hub');

‎test/cypress/e2e/insights/namespace_delete.js

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const apiPrefix = Cypress.env('apiPrefix');
2+
const uiPrefix = Cypress.env('uiPrefix');
3+
4+
describe('Delete a namespace', () => {
5+
before(() => {
6+
cy.deleteNamespacesAndCollections();
7+
});
8+
9+
beforeEach(() => {
10+
cy.on('uncaught:exception', () => false);
11+
cy.login();
12+
});
13+
14+
it('deletes a namespace', () => {
15+
cy.galaxykit('-i namespace create', 'testns1');
16+
cy.goToNamespaces();
17+
18+
cy.intercept('GET', `${apiPrefix}_ui/v1/namespaces/?sort=name*`).as(
19+
'reload',
20+
);
21+
cy.get(`a[href*="${uiPrefix}namespaces/testns1"]`).click();
22+
cy.get('[data-cy="ns-kebab-toggle"]').click();
23+
cy.contains('Delete namespace').click();
24+
cy.get('input[id=delete_confirm]').click();
25+
cy.get('button').contains('Delete').click();
26+
cy.wait('@reload');
27+
cy.contains('Namespace "testns1" has been successfully deleted.');
28+
});
29+
30+
it('cannot delete a non-empty namespace', () => {
31+
//create namespace
32+
cy.intercept('GET', `${apiPrefix}_ui/v1/namespaces/?sort=name*`).as(
33+
'reload',
34+
);
35+
cy.galaxykit('-i namespace create', 'ansible');
36+
cy.goToNamespaces();
37+
cy.wait('@reload');
38+
39+
cy.get(`a[href*="${uiPrefix}namespaces/ansible"]`).click();
40+
41+
//upload a collection
42+
cy.createApprovedCollection('ansible', 'network');
43+
44+
// wait for imports to finish successfully
45+
46+
cy.wait(10000);
47+
48+
// attempt deletion
49+
cy.intercept(
50+
'GET',
51+
`${apiPrefix}_ui/v1/namespaces/?sort=name&offset=0&limit=20`,
52+
).as('namespaces');
53+
cy.goToNamespaces();
54+
cy.wait('@namespaces');
55+
cy.contains('ansible').parent().contains('View collections').click();
56+
cy.get('[data-cy=ns-kebab-toggle]').click();
57+
cy.contains('Delete namespace')
58+
.invoke('attr', 'aria-disabled')
59+
.should('eq', 'true');
60+
});
61+
});

‎test/cypress/e2e/insights/namespace_detail.js

-1
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.