From 408517de39e3eeb98e9a4da81c21fb3f3bf8a4e0 Mon Sep 17 00:00:00 2001 From: NandanAnantharamu <67676905+NandanAnantharamu@users.noreply.github.com> Date: Mon, 10 May 2021 17:27:54 +0530 Subject: [PATCH] Datasource test with basic profile added (#4374) --- app/client/cypress/fixtures/testdata.json | 3 +- .../DatasourceBasicProfile_spec.js | 22 ++++++++++++++ .../cypress/locators/DatasourcesEditor.json | 5 +++- app/client/cypress/support/commands.js | 29 +++++++++++++------ 4 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/Datasources/DatasourceBasicProfile_spec.js diff --git a/app/client/cypress/fixtures/testdata.json b/app/client/cypress/fixtures/testdata.json index 622aac0aae..61d619d292 100644 --- a/app/client/cypress/fixtures/testdata.json +++ b/app/client/cypress/fixtures/testdata.json @@ -121,5 +121,6 @@ "clientSecret": "505dac16a21681f277b5fde97445be18", "accessTokenUrl": "https://oauth.mocklab.io/oauth/token", "oauthResponse": "169444434892406", - "authorizationURL": "https://oauth.mocklab.io/oauth/authorize" + "authorizationURL": "https://oauth.mocklab.io/oauth/authorize", + "basicURl": "https://envyenksqii9nf3.m.pipedream.net" } diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/Datasources/DatasourceBasicProfile_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/Datasources/DatasourceBasicProfile_spec.js new file mode 100644 index 0000000000..cbfdba5572 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/Datasources/DatasourceBasicProfile_spec.js @@ -0,0 +1,22 @@ +const testdata = require("../../../../fixtures/testdata.json"); +describe("Create a rest datasource", function() { + beforeEach(() => { + cy.startRoutesForDatasource(); + }); + + it("Create a rest datasource", function() { + cy.NavigateToAPI_Panel(); + cy.CreateAPI("Testapi"); + cy.enterDatasource(testdata.basicURl); + cy.get(".t--store-as-datasource").click(); + cy.addBasicProfileDetails("test", "test@123"); + cy.saveDatasource(); + cy.contains(".datasource-highlight", "envyenksqii9nf3.m.pipedream.net"); + cy.SaveAndRunAPI(); + cy.wait(2000); + var encodedStringBtoA = btoa("test:test@123"); + cy.log(encodedStringBtoA); + cy.ResponseStatusCheck(testdata.successStatusCode); + cy.ResponseTextCheck("Basic ".concat(encodedStringBtoA)); + }); +}); diff --git a/app/client/cypress/locators/DatasourcesEditor.json b/app/client/cypress/locators/DatasourcesEditor.json index 47aa855c89..defed053bb 100644 --- a/app/client/cypress/locators/DatasourcesEditor.json +++ b/app/client/cypress/locators/DatasourcesEditor.json @@ -35,5 +35,8 @@ "grantType": "[data-cy='authentication.grantType']", "authorizationURL":"[data-cy='authentication.authorizationUrl'] input", "authorisecode": "//div[contains(@class,'option') and text()='Authorization Code']", - "saveAndAuthorize": "button:contains('Save and Authorize')" + "saveAndAuthorize": "button:contains('Save and Authorize')", + "basic": "//div[contains(@class,'option') and text()='Basic']", + "basicUsername": "input[name='authentication.username']", + "basicPassword": "input[name='authentication.password']" } diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 0404b43bf3..bcf23bfc1a 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -286,6 +286,13 @@ Cypress.Commands.add( }, ); +Cypress.Commands.add("addBasicProfileDetails", (username, password) => { + cy.get(datasource.authType).click(); + cy.xpath(datasource.basic).click(); + cy.get(datasource.basicUsername).type(username); + cy.get(datasource.basicPassword).type(password); +}); + Cypress.Commands.add("firestoreDatasourceForm", () => { cy.get(datasourceEditor.datasourceConfigUrl).type( datasourceFormData["database-url"], @@ -474,6 +481,11 @@ Cypress.Commands.add("ResponseCheck", (textTocheck) => { cy.get(apiwidget.responseText).should("be.visible"); }); +Cypress.Commands.add("ResponseTextCheck", (textTocheck) => { + cy.ResponseCheck(); + cy.get(apiwidget.responseText).contains(textTocheck); +}); + Cypress.Commands.add("NavigateToAPI_Panel", () => { cy.get(pages.addEntityAPI) .should("be.visible") @@ -649,21 +661,20 @@ Cypress.Commands.add("SearchEntityandOpen", (apiname1) => { }); Cypress.Commands.add("enterDatasourceAndPath", (datasource, path) => { - cy.get(apiwidget.resourceUrl) - .first() - .click({ force: true }) - .type(datasource); - /* - cy.xpath(apiwidget.autoSuggest) - .first() - .click({ force: true }); - */ + cy.enterDatasource(datasource); cy.get(apiwidget.editResourceUrl) .first() .click({ force: true }) .type(path, { parseSpecialCharSequences: false }); }); +Cypress.Commands.add("enterDatasource", (datasource) => { + cy.get(apiwidget.resourceUrl) + .first() + .click({ force: true }) + .type(datasource); +}); + Cypress.Commands.add("changeZoomLevel", (zoomValue) => { cy.get(commonlocators.changeZoomlevel) .last()