From 5d1c9cfab8f1b4ee35be41051d538ed48d5bc152 Mon Sep 17 00:00:00 2001 From: binodmx Date: Mon, 5 Dec 2022 18:17:44 +0530 Subject: [PATCH] Add UI test to verify gateway environments --- README.md | 2 +- .../Details/Environments/Environments.jsx | 2 +- .../cypress/fixtures/multipleDeployments.json | 40 ++++++ .../fixtures/multipleEnvironments.json | 132 ++++++++++++++++++ .../02-verify-gateway-environments.spec.js | 62 ++++++++ 5 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 tests/cypress/fixtures/multipleDeployments.json create mode 100644 tests/cypress/fixtures/multipleEnvironments.json create mode 100644 tests/cypress/integration/publisher/015-deployments/02-verify-gateway-environments.spec.js diff --git a/README.md b/README.md index edb87a996b2..1f0237f252a 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Setup build environment > **_Note :-_** > - > You can skip following steps if you don not want to build [product-apim](https://github.com/wso2/product-apim) binaries + > You can skip following steps if you do not want to build [product-apim](https://github.com/wso2/product-apim) binaries > 2. Install Maven from [https://maven.apache.org/download.cgi](https://maven.apache.org/download.cgi). * For Maven 3.8 and up, please check the Troubleshoot section. diff --git a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Environments/Environments.jsx b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Environments/Environments.jsx index 7105fa7c0ad..2c9d9fd2fb4 100644 --- a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Environments/Environments.jsx +++ b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Environments/Environments.jsx @@ -2129,7 +2129,7 @@ export default function Environments() { {allEnvDeployments[row.name].revision != null ? ( <> - +
{api.isWebSocket() ? getGatewayAccessUrl(allEnvDeployments[row.name] diff --git a/tests/cypress/fixtures/multipleDeployments.json b/tests/cypress/fixtures/multipleDeployments.json new file mode 100644 index 00000000000..92b41184919 --- /dev/null +++ b/tests/cypress/fixtures/multipleDeployments.json @@ -0,0 +1,40 @@ +{ + "count": 1, + "list": [ + { + "displayName": "Revision 1", + "id": "1f4733db-2c48-449a-9fea-e5fd7068430a", + "description": "test", + "createdTime": 1670230943000, + "apiInfo": { + "id": "e2e5c296-0569-4074-9794-974131b65363" + }, + "deploymentInfo": [ + { + "revisionUuid": "1f4733db-2c48-449a-9fea-e5fd7068430a", + "name": "Default", + "vhost": "localhost", + "displayOnDevportal": true, + "deployedTime": 1670230943000, + "successDeployedTime": null + }, + { + "revisionUuid": "1f4733db-2c48-449a-9fea-e5fd7068430a", + "name": "WSO2", + "vhost": "wso2.com", + "displayOnDevportal": true, + "deployedTime": 1670230943000, + "successDeployedTime": null + }, + { + "revisionUuid": "1f4733db-2c48-449a-9fea-e5fd7068430a", + "name": "APIM", + "vhost": "apim.com", + "displayOnDevportal": true, + "deployedTime": 1670230943000, + "successDeployedTime": null + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/cypress/fixtures/multipleEnvironments.json b/tests/cypress/fixtures/multipleEnvironments.json new file mode 100644 index 00000000000..cbe1a4e1517 --- /dev/null +++ b/tests/cypress/fixtures/multipleEnvironments.json @@ -0,0 +1,132 @@ +{ + "devportalUrl": "https://localhost:9443/devportal", + "environment": [ + { + "id": "Default", + "name": "Default", + "displayName": "Default", + "type": "hybrid", + "serverUrl": "https://localhost:9443/services/", + "provider": "wso2", + "showInApiConsole": true, + "vhosts": [ + { + "host": "localhost", + "httpContext": "", + "httpPort": 8280, + "httpsPort": 8243, + "wsPort": 9099, + "wssPort": 8099, + "websubHttpPort": 9021, + "websubHttpsPort": 8021 + } + ], + "endpointURIs": [], + "additionalProperties": [] + }, + { + "id": "WSO2", + "name": "WSO2", + "displayName": "WSO2", + "type": "hybrid", + "serverUrl": "https://localhost:9443/services/", + "provider": "wso2", + "showInApiConsole": true, + "vhosts": [ + { + "host": "wso2.com", + "httpContext": "", + "httpPort": -1, + "httpsPort": 443, + "wsPort": 9100, + "wssPort": 8100, + "websubHttpPort": 9022, + "websubHttpsPort": 8022 + } + ], + "endpointURIs": [], + "additionalProperties": [] + }, + { + "id": "APIM", + "name": "APIM", + "displayName": "APIM", + "type": "hybrid", + "serverUrl": "https://localhost:9443/services/", + "provider": "wso2", + "showInApiConsole": true, + "vhosts": [ + { + "host": "apim.com", + "httpContext": "", + "httpPort": 8280, + "httpsPort": -1, + "wsPort": 9100, + "wssPort": 8100, + "websubHttpPort": 9022, + "websubHttpsPort": 8022 + } + ], + "endpointURIs": [], + "additionalProperties": [] + } + ], + "scopes": [ + "apim:admin", + "apim:api_create", + "apim:api_definition_view", + "apim:api_delete", + "apim:api_generate_key", + "apim:api_import_export", + "apim:api_list_view", + "apim:api_manage", + "apim:api_mediation_policy_manage", + "apim:api_product_import_export", + "apim:api_publish", + "apim:api_view", + "apim:app_import_export", + "apim:client_certificates_add", + "apim:client_certificates_manage", + "apim:client_certificates_update", + "apim:client_certificates_view", + "apim:comment_manage", + "apim:comment_view", + "apim:comment_write", + "apim:common_operation_policy_manage", + "apim:common_operation_policy_view", + "apim:document_create", + "apim:document_manage", + "apim:ep_certificates_add", + "apim:ep_certificates_manage", + "apim:ep_certificates_update", + "apim:ep_certificates_view", + "apim:mediation_policy_create", + "apim:mediation_policy_manage", + "apim:mediation_policy_view", + "apim:pub_alert_manage", + "apim:publisher_settings", + "apim:shared_scope_manage", + "apim:subscription_block", + "apim:subscription_manage", + "apim:subscription_view", + "apim:threat_protection_policy_create", + "apim:threat_protection_policy_manage", + "apim:tier_manage", + "apim:tier_view", + "openid" + ], + "monetizationAttributes": [], + "securityAuditProperties": { + "isGlobal": null, + "overrideGlobal": null, + "apiToken": null, + "collectionId": null, + "baseUrl": null + }, + "externalStoresEnabled": false, + "docVisibilityEnabled": false, + "crossTenantSubscriptionEnabled": false, + "defaultAdvancePolicy": "Unlimited", + "defaultSubscriptionPolicy": "Unlimited", + "authorizationHeader": "Authorization" +} \ No newline at end of file diff --git a/tests/cypress/integration/publisher/015-deployments/02-verify-gateway-environments.spec.js b/tests/cypress/integration/publisher/015-deployments/02-verify-gateway-environments.spec.js new file mode 100644 index 00000000000..09bd4fb4769 --- /dev/null +++ b/tests/cypress/integration/publisher/015-deployments/02-verify-gateway-environments.spec.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import Utils from "@support/utils"; + +describe("publisher-015-02 : Verify Gateway Environments", () => { + const { publisher, password, superTenant, testTenant} = Utils.getUserInfo(); + + const verifyGatewayEnvironments = (tenant) => { + cy.loginToPublisher(publisher, password, tenant); + Utils.addAPIWithEndpoints({}).then((apiId) => { + cy.intercept('GET', `/api/am/publisher/v3/settings`, {fixture:'multipleEnvironments.json'}).as('settings'); + cy.intercept('GET', `/api/am/publisher/v3/apis/${apiId}/revisions?query=deployed%3Atrue`, + {fixture:'multipleDeployments.json'}).as('revisions'); + + // Go to overview page + cy.visit(`/publisher/apis/${apiId}/overview`); + + // Go to deployments page + cy.get('#left-menu-itemdeployments').click(); + cy.wait(2000); + + // Deploy API + cy.get('#Default').click({ "force": true }); + cy.get('#add-description-btn').scrollIntoView().click({ "force": true }); + cy.get('#add-description').click({ "force": true }); + cy.get('#add-description').type('test'); + cy.get('#deploy-btn').should('not.have.class', 'Mui-disabled').click(); + cy.get('#undeploy-btn').should('not.have.class', 'Mui-disabled').should('exist'); + cy.wait(2000); + + // Verify environments + cy.get('#gateway-access-url-cell > div').should('have.text', + 'http://localhost:8280https://localhost:8243https://wso2.comhttp://apim.com:8280').should('exist'); + + // Delete API + Utils.deleteAPI(apiId); + }); + } + + it.only("Verify Gateway Environments - super admin", () => { + verifyGatewayEnvironments(superTenant); + }); + it.only("Verify Gateway Environments - tenant user", () => { + verifyGatewayEnvironments(testTenant); + }); +});