|
| 1 | +import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'; |
| 2 | +import { detailsPage } from '@console/cypress-integration-tests/views/details-page'; |
| 3 | +import { listPage } from '@console/cypress-integration-tests/views/list-page'; |
| 4 | +import { modal } from '@console/cypress-integration-tests/views/modal'; |
| 5 | +import { devNavigationMenu } from '@console/dev-console/integration-tests/support/constants'; |
| 6 | +import { |
| 7 | + navigateTo, |
| 8 | + yamlEditor, |
| 9 | + createGitWorkloadIfNotExistsOnTopologyPage, |
| 10 | + topologyHelper, |
| 11 | + gitPage, |
| 12 | + devFilePage, |
| 13 | + topologyPage, |
| 14 | +} from '@console/dev-console/integration-tests/support/pages'; |
| 15 | +import { topologyPO } from '@console/topology/integration-tests/support/page-objects/topology-po'; |
| 16 | +import * as yamlView from '../../../../../integration-tests-cypress/views/yaml-editor'; |
| 17 | + |
| 18 | +const deteleResourceQuota = (resourceQuotaName: string) => { |
| 19 | + listPage.filter.byName(resourceQuotaName); |
| 20 | + listPage.rows.clickRowByName(resourceQuotaName); |
| 21 | + detailsPage.isLoaded(); |
| 22 | + detailsPage.clickPageActionFromDropdown('Delete ResourceQuota'); |
| 23 | + modal.shouldBeOpened(); |
| 24 | + modal.submit(); |
| 25 | + modal.shouldBeClosed(); |
| 26 | +}; |
| 27 | + |
| 28 | +Given('user is at the Topology page', () => { |
| 29 | + navigateTo(devNavigationMenu.Topology); |
| 30 | +}); |
| 31 | + |
| 32 | +Given('user is at the Add page', () => { |
| 33 | + navigateTo(devNavigationMenu.Add); |
| 34 | +}); |
| 35 | + |
| 36 | +When('user right clicks on topology empty graph', () => { |
| 37 | + cy.get(topologyPO.graph.emptyGraph).rightclick(1, 1); |
| 38 | +}); |
| 39 | + |
| 40 | +When('user selects {string} option from Add to Project context menu', (option: string) => { |
| 41 | + cy.get(topologyPO.graph.contextMenuOptions.addToProject) |
| 42 | + .focus() |
| 43 | + .trigger('mouseover'); |
| 44 | + cy.byTestActionID(option).click({ force: true }); |
| 45 | +}); |
| 46 | + |
| 47 | +Given('user has created workload with resource type deployment', () => { |
| 48 | + createGitWorkloadIfNotExistsOnTopologyPage( |
| 49 | + 'https://github.com/sclorg/nodejs-ex.git', |
| 50 | + 'ex-node-js', |
| 51 | + 'deployment', |
| 52 | + 'nodejs-ex-git-app', |
| 53 | + ); |
| 54 | + topologyHelper.verifyWorkloadInTopologyPage('ex-node-js'); |
| 55 | +}); |
| 56 | + |
| 57 | +When('user enters Git Repo URL as {string} in Import from Git form', (gitUrl: string) => { |
| 58 | + gitPage.enterGitUrl(gitUrl); |
| 59 | + devFilePage.verifyValidatedMessage(gitUrl); |
| 60 | +}); |
| 61 | + |
| 62 | +When('user enters workload name as {string}', (name: string) => { |
| 63 | + gitPage.enterWorkloadName(name); |
| 64 | +}); |
| 65 | + |
| 66 | +When('user clicks Create button on Add page', () => { |
| 67 | + gitPage.clickCreate(); |
| 68 | +}); |
| 69 | + |
| 70 | +Then('user will be redirected to Topology page', () => { |
| 71 | + topologyPage.verifyTopologyPage(); |
| 72 | +}); |
| 73 | + |
| 74 | +Then('user is able to see workload {string} in topology page', (workloadName: string) => { |
| 75 | + topologyPage.verifyWorkloadInTopologyPage(workloadName); |
| 76 | +}); |
| 77 | + |
| 78 | +Given('user clicks on import YAML button', () => { |
| 79 | + cy.get('[data-test="import-yaml"]').click(); |
| 80 | + cy.get('.yaml-editor').should('be.visible'); |
| 81 | +}); |
| 82 | + |
| 83 | +When('user clicks Create button to create ResourceQuota', () => { |
| 84 | + cy.get('[data-test="save-changes"]').click(); |
| 85 | +}); |
| 86 | + |
| 87 | +When('user enters the {string} file data to YAML Editor', (yamlFile: string) => { |
| 88 | + yamlEditor.isLoaded(); |
| 89 | + yamlEditor.clearYAMLEditor(); |
| 90 | + yamlEditor.setEditorContent(yamlFile); |
| 91 | +}); |
| 92 | + |
| 93 | +When('user clicks on link to view resource quota details', () => { |
| 94 | + cy.byTestID('resource-quota-warning').click(); |
| 95 | +}); |
| 96 | + |
| 97 | +Then('user is redirected to resource quota details page', () => { |
| 98 | + cy.get('h2').should('contain.text', 'ResourceQuota details'); |
| 99 | +}); |
| 100 | + |
| 101 | +Then('user is redirected to resource quota list page', () => { |
| 102 | + listPage.rows.shouldBeLoaded(); |
| 103 | +}); |
| 104 | + |
| 105 | +When('user deletes resource quotas created', () => { |
| 106 | + deteleResourceQuota('resourcequota1'); |
| 107 | + deteleResourceQuota('resourcequota2'); |
| 108 | +}); |
| 109 | + |
| 110 | +When('user clicks on Delete application', () => { |
| 111 | + cy.get('.odc-topology-context-menu') |
| 112 | + .contains('Delete application') |
| 113 | + .click(); |
| 114 | +}); |
| 115 | + |
| 116 | +When( |
| 117 | + 'user enters the name {string} in the Delete application modal and clicks on Delete button', |
| 118 | + (appName: string) => { |
| 119 | + topologyPage.deleteApplication(appName); |
| 120 | + }, |
| 121 | +); |
| 122 | + |
| 123 | +When('user right clicks on Application Grouping {string}', (appName: string) => { |
| 124 | + topologyPage.rightClickOnApplicationGroupings(appName); |
| 125 | +}); |
| 126 | + |
| 127 | +When( |
| 128 | + 'user creates resource quota {string} by entering {string} file data', |
| 129 | + (resourceQuotaName: string, yamlLocation: string) => { |
| 130 | + cy.readFile(yamlLocation).then((str) => { |
| 131 | + const myArray = str.split('---'); |
| 132 | + resourceQuotaName === 'resourcequota1' |
| 133 | + ? yamlView.setEditorContent(myArray[0]) |
| 134 | + : yamlView.setEditorContent(myArray[1]); |
| 135 | + }); |
| 136 | + }, |
| 137 | +); |
| 138 | + |
| 139 | +Then( |
| 140 | + 'user should not be able to see the resource quotas {string} and {string}', |
| 141 | + (resourcequota1: string, resourcequota2: string) => { |
| 142 | + listPage.rows.shouldNotExist(resourcequota1); |
| 143 | + listPage.rows.shouldNotExist(resourcequota2); |
| 144 | + }, |
| 145 | +); |
0 commit comments