diff --git a/frontend/packages/dev-console/integration-tests/features/addFlow/resource-quota-warning.feature b/frontend/packages/dev-console/integration-tests/features/addFlow/resource-quota-warning.feature new file mode 100644 index 000000000000..bdbe713ea6b8 --- /dev/null +++ b/frontend/packages/dev-console/integration-tests/features/addFlow/resource-quota-warning.feature @@ -0,0 +1,26 @@ +@add-flow @ODC6771 +Feature: Update user in Add page if Quotas has been reached in a namespace + If any resource reached resource quota limit, a warning alert will be displayed for the user in Add page. + + Background: + Given user is at developer perspective + And user has created or selected namespace "aut-add" + + + @regression + Scenario: single resource reached quota: A-15-TC01 + Given user has created workload with resource type deployment + When user creates resource quota 'resourcequota1' by entering "testData/resource-quota/resource-quota.yaml" file data + And user is navigated to Add page + And user clicks on link to view resource quota details + Then user is redirected to resource quota details page + + + @regression + Scenario: multiple resources reached quota: A-15-TC02 + Given user has created workload with resource type deployment + And user creates two resource quotas + When user is navigated to Add page + And user clicks on link to view resource quota details + Then user is redirected to resource quota list page + \ No newline at end of file diff --git a/frontend/packages/dev-console/integration-tests/support/step-definitions/addFlow/resource-quota-warning.ts b/frontend/packages/dev-console/integration-tests/support/step-definitions/addFlow/resource-quota-warning.ts new file mode 100644 index 000000000000..1bbac1f0b0ec --- /dev/null +++ b/frontend/packages/dev-console/integration-tests/support/step-definitions/addFlow/resource-quota-warning.ts @@ -0,0 +1,69 @@ +import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'; +import { detailsPage } from '@console/cypress-integration-tests/views/details-page'; +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, + app, +} from '@console/dev-console/integration-tests/support/pages'; + +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 creates two resource quotas', () => { + cy.exec(`oc apply -f testData/resource-quota/resource-quota.yaml`); + app.waitForDocumentLoad(); +}); + +When('user is navigated to Add page', () => { + app.waitForDocumentLoad(); + navigateTo(devNavigationMenu.Add); +}); + +When('user clicks on link to view resource quota details', () => { + 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'); + }, +); diff --git a/frontend/packages/dev-console/integration-tests/testData/resource-quota/resource-quota.yaml b/frontend/packages/dev-console/integration-tests/testData/resource-quota/resource-quota.yaml new file mode 100644 index 000000000000..ec4e6e8e2580 --- /dev/null +++ b/frontend/packages/dev-console/integration-tests/testData/resource-quota/resource-quota.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: ResourceQuota +metadata: + name: resourcequota1 + namespace: aut-add +spec: + hard: + pods: '1' +--- +apiVersion: v1 +kind: ResourceQuota +metadata: + name: resourcequota2 + namespace: aut-add +spec: + hard: + pods: '1' \ No newline at end of file diff --git a/frontend/packages/topology/integration-tests/features/topology/resource-quota-warning.feature b/frontend/packages/topology/integration-tests/features/topology/resource-quota-warning.feature index a673a6d05dd1..6586df037fcb 100644 --- a/frontend/packages/topology/integration-tests/features/topology/resource-quota-warning.feature +++ b/frontend/packages/topology/integration-tests/features/topology/resource-quota-warning.feature @@ -1,6 +1,6 @@ -@topology @add-flow @ODC6771 -Feature: Update user in topology and add flow if Quotas has been reached in a namespace - If any resource reached resource quota limit, a warning alert will be displayed for the user in Add page and Topology page. +@topology @ODC6771 +Feature: Update user in topology page if Quotas has been reached in a namespace + If any resource reached resource quota limit, a warning alert will be displayed for the user in Topology page. Background: Given user is at developer perspective @@ -8,67 +8,20 @@ Feature: Update user in topology and add flow if Quotas has been reached in a na @regression - Scenario: Deploy git workload with devfile from topology page: T-19-TC01 - Given user is at the Topology page - When user right clicks on topology empty graph - And user selects "Import from Git" option from Add to Project context menu - And user enters Git Repo URL as "https://github.com/nodeshift-starters/devfile-sample" in Import from Git form - And user enters workload name as "node-bulletin-board-1" - And user clicks Create button on Add page - Then user will be redirected to Topology page - And user is able to see workload "node-bulletin-board-1" in topology page - - - @regression - Scenario: user creates a resource quota: T-19-TC02 - Given user clicks on import YAML button + Scenario: single resource reached quota: T-19-TC01 + Given user has created workload with resource type deployment When user creates resource quota 'resourcequota1' by entering "testData/resource-quota/resource-quota.yaml" file data - And user clicks on Create button - Then user is redirected to resource quota details page - - - @regression - Scenario: check resource quota reached warning message in topology page: T-19-TC03 - Given user is at the Topology page - When user clicks on link to view resource quota details - Then user is redirected to resource quota details page - - - @regression - Scenario: check resource quota reached warning message in Add page: T-19-TC04 - Given user is at the Add page - When user clicks on link to view resource quota details - Then user is redirected to resource quota details page - - - @regression - Scenario: user creates another resource quota: T-19-TC05 - Given user clicks on import YAML button - When user creates resource quota 'resourcequota2' by entering "testData/resource-quota/resource-quota.yaml" file data - And user clicks on Create button + And user is navigated to Topology page + And user clicks on link to view resource quota details Then user is redirected to resource quota details page - - - @regression - Scenario: Click on warning message link to see the resource quotas list in toplology page: T-19-TC06 - Given user is at the Topology page - When user clicks on link to view resource quota details + + + @regression + Scenario: multiple resources reached quota: T-19-TC02 + Given user has created workload with resource type deployment + And user creates two resource quotas + When user is navigated to Topology page + And user clicks on link to view resource quota details Then user is redirected to resource quota list page - - - @regression - Scenario: Click on warning message link to see the resource quotas list in Add page: T-19-TC07 - Given user is at the Add page - When user clicks on link to view resource quota details - And user is redirected to resource quota list page - And user deletes resource quotas created - Then user should not be able to see the resource quotas "resourcequota1" and "resourcequota2" - - - @regression - Scenario: Delete the application created: A-04-TC01: T-19-TC08 - Given user is at the Topology page - When user right clicks on Application Grouping "devfile-sample-app" - And user clicks on Delete application - And user enters the name "devfile-sample-app" in the Delete application modal and clicks on Delete button + diff --git a/frontend/packages/topology/integration-tests/support/step-definitions/topology/resource-quota-warning.ts b/frontend/packages/topology/integration-tests/support/step-definitions/topology/resource-quota-warning.ts index 134bd7c6aef3..33d7e71494f4 100644 --- a/frontend/packages/topology/integration-tests/support/step-definitions/topology/resource-quota-warning.ts +++ b/frontend/packages/topology/integration-tests/support/step-definitions/topology/resource-quota-warning.ts @@ -2,22 +2,17 @@ import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'; import { detailsPage } from '@console/cypress-integration-tests/views/details-page'; 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, - yamlEditor, createGitWorkloadIfNotExistsOnTopologyPage, topologyHelper, - gitPage, - devFilePage, topologyPage, + app, } from '@console/dev-console/integration-tests/support/pages'; -import * as yamlView from '../../../../../integration-tests-cypress/views/yaml-editor'; -import { topologyPO } from '../../page-objects/topology-po'; -const deteleResourceQuota = (resourceQuotaName: string) => { - listPage.filter.byName(resourceQuotaName); - listPage.rows.clickRowByName(resourceQuotaName); +const deteleResourceQuota = () => { detailsPage.isLoaded(); detailsPage.clickPageActionFromDropdown('Delete ResourceQuota'); modal.shouldBeOpened(); @@ -25,25 +20,6 @@ const deteleResourceQuota = (resourceQuotaName: string) => { modal.shouldBeClosed(); }; -Given('user is at the Topology page', () => { - navigateTo(devNavigationMenu.Topology); -}); - -Given('user is at the Add page', () => { - navigateTo(devNavigationMenu.Add); -}); - -When('user right clicks on topology empty graph', () => { - cy.get(topologyPO.graph.emptyGraph).rightclick(1, 1); -}); - -When('user selects {string} option from Add to Project context menu', (option: string) => { - cy.get(topologyPO.graph.contextMenuOptions.addToProject) - .focus() - .trigger('mouseover'); - cy.byTestActionID(option).click({ force: true }); -}); - Given('user has created workload with resource type deployment', () => { createGitWorkloadIfNotExistsOnTopologyPage( 'https://github.com/sclorg/nodejs-ex.git', @@ -54,92 +30,42 @@ Given('user has created workload with resource type deployment', () => { topologyHelper.verifyWorkloadInTopologyPage('ex-node-js'); }); -When('user enters Git Repo URL as {string} in Import from Git form', (gitUrl: string) => { - gitPage.enterGitUrl(gitUrl); - devFilePage.verifyValidatedMessage(gitUrl); +Given('user creates two resource quotas', () => { + cy.exec(`oc apply -f testData/resource-quota/resource-quota.yaml`); + app.waitForDocumentLoad(); }); -When('user enters workload name as {string}', (name: string) => { - gitPage.enterWorkloadName(name); -}); - -When('user clicks Create button on Add page', () => { - gitPage.clickCreate(); -}); - -Then('user will be redirected to Topology page', () => { +When('user is navigated to Topology page', () => { + app.waitForDocumentLoad(); + navigateTo(devNavigationMenu.Topology); topologyPage.verifyTopologyPage(); }); -Then('user is able to see workload {string} in topology page', (workloadName: string) => { - topologyPage.verifyWorkloadInTopologyPage(workloadName); -}); - -Given('user clicks on import YAML button', () => { - cy.get('[data-test="import-yaml"]').click(); - cy.get('.yaml-editor').should('be.visible'); -}); - -When('user clicks on Create button', () => { - cy.get('[data-test="save-changes"]').click(); -}); - -When('user enters the {string} file data to YAML Editor', (yamlFile: string) => { - yamlEditor.isLoaded(); - yamlEditor.clearYAMLEditor(); - yamlEditor.setEditorContent(yamlFile); -}); - When('user clicks on link to view resource quota details', () => { 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 deletes resource quotas created', () => { - deteleResourceQuota('resourcequota1'); - deteleResourceQuota('resourcequota2'); -}); - -When('user clicks on Delete application', () => { - cy.get('.odc-topology-context-menu') - .contains('Delete application') - .click(); -}); - -When( - 'user enters the name {string} in the Delete application modal and clicks on Delete button', - (appName: string) => { - topologyPage.deleteApplication(appName); - }, -); - -When('user right clicks on Application Grouping {string}', (appName: string) => { - topologyPage.rightClickOnApplicationGroupings(appName); -}); - 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]); }); - }, -); - -Then( - 'user should not be able to see the resource quotas {string} and {string}', - (resourcequota1: string, resourcequota2: string) => { - listPage.rows.shouldNotExist(resourcequota1); - listPage.rows.shouldNotExist(resourcequota2); + cy.get('[data-test="save-changes"]').click(); + cy.get('h2').should('contain.text', 'ResourceQuota details'); }, );