-
Notifications
You must be signed in to change notification settings - Fork 605
/
resource-quota-warning.ts
94 lines (82 loc) · 3.25 KB
/
resource-quota-warning.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { Given, When, Then, And } from 'cypress-cucumber-preprocessor/steps';
import { detailsPage } from '@console/cypress-integration-tests/views/details-page';
import { guidedTour } from '@console/cypress-integration-tests/views/guided-tour';
import { listPage } from '@console/cypress-integration-tests/views/list-page';
import { modal } from '@console/cypress-integration-tests/views/modal';
import * as yamlView from '@console/cypress-integration-tests/views/yaml-editor';
import { devNavigationMenu } from '@console/dev-console/integration-tests/support/constants';
import {
navigateTo,
createGitWorkloadIfNotExistsOnTopologyPage,
topologyHelper,
topologyPage,
app,
topologySidePane,
} from '@console/dev-console/integration-tests/support/pages';
import { topologyPO } from '../../page-objects/topology-po';
const deteleResourceQuota = () => {
detailsPage.isLoaded();
detailsPage.clickPageActionFromDropdown('Delete ResourceQuota');
modal.shouldBeOpened();
modal.submit();
modal.shouldBeClosed();
};
Given('user has created workload with resource type deployment', () => {
createGitWorkloadIfNotExistsOnTopologyPage(
'https://github.com/sclorg/nodejs-ex.git',
'ex-node-js',
'deployment',
'nodejs-ex-git-app',
);
topologyHelper.verifyWorkloadInTopologyPage('ex-node-js');
});
Given('user has created two resource quotas using {string} file', (yamlLocation) => {
cy.exec(`oc apply -f ${yamlLocation} -n ${Cypress.env('NAMESPACE')}`).then(function (result) {
cy.log(result.stdout);
});
app.waitForDocumentLoad();
});
When('user navigates to Topology page', () => {
navigateTo(devNavigationMenu.Topology);
topologyPage.verifyTopologyPage();
});
When('user clicks on link to view resource quota details', () => {
cy.reload();
app.waitForLoad();
guidedTour.close();
cy.byTestID('resource-quota-warning').click();
});
Then('user is redirected to resource quota details page', () => {
cy.get('h2').should('contain.text', 'ResourceQuota details');
deteleResourceQuota();
});
Then('user is redirected to resource quota list page', () => {
listPage.rows.shouldBeLoaded();
});
When(
'user creates resource quota {string} by entering {string} file data',
(resourceQuotaName: string, yamlLocation: string) => {
cy.get('[data-test="import-yaml"]').click();
cy.get('.yaml-editor').should('be.visible');
cy.readFile(yamlLocation).then((str) => {
const myArray = str.split('---');
resourceQuotaName === 'resourcequota1'
? yamlView.setEditorContent(myArray[0])
: yamlView.setEditorContent(myArray[1]);
});
cy.get('[data-test="save-changes"]').click();
cy.get('h2').should('contain.text', 'ResourceQuota details');
},
);
Then('user is able to see resource quota alert', () => {
topologySidePane.verifyResourceQuotaAlert();
});
And('user is able to see yellow border around {string} workload', (workloadName: string) => {
topologyPage.verifyNodeAlert(workloadName);
});
And('user continously clicks on zoom-out button until it gets maximum zoomed out', () => {
topologyPage.clickMaxZoomOut();
});
Then('user is able to see yellow background on workload for resource quota alert', () => {
cy.byLegacyTestID('ex-node-js1').get(topologyPO.graph.warningBackground).should('be.visible');
});