From 982d8a352be8ec1dc40d0e788eb5d7f9c76486ff Mon Sep 17 00:00:00 2001 From: Raju Udava Date: Mon, 15 Nov 2021 20:27:22 +0530 Subject: [PATCH] test(cypress): URL path trim & baseUrl configured as NULL for full URL access Signed-off-by: Raju Udava --- .../integration/common/4b_table_view_share.js | 18 +++++++++----- .../common/4c_form_view_detailed.js | 4 +++- .../integration/common/4e_form_view_share.js | 14 +++++++---- .../integration/common/4f_grid_view_share.js | 24 ++++++++++++------- .../integration/common/5a_user_role.js | 4 +++- .../integration/common/6c_swagger_api.js | 4 +++- .../integration/common/6f_attachments.js | 4 +++- .../integration/common/6g_base_share.js | 6 +++-- .../cypress/support/page_objects/mainPage.js | 2 +- 9 files changed, 54 insertions(+), 26 deletions(-) diff --git a/scripts/cypress/integration/common/4b_table_view_share.js b/scripts/cypress/integration/common/4b_table_view_share.js index f3fffb747c..a9cffa3507 100644 --- a/scripts/cypress/integration/common/4b_table_view_share.js +++ b/scripts/cypress/integration/common/4b_table_view_share.js @@ -2,7 +2,7 @@ import { mainPage } from "../../support/page_objects/mainPage" import { loginPage } from "../../support/page_objects/navigation" import { isTestSuiteActive } from "../../support/page_objects/projectConstants" -let baseURL = '' +let storedURL = '' let linkText = '' const generateLinkWithPwd = () => { @@ -24,7 +24,7 @@ const generateLinkWithPwd = () => { cy.getActiveModal().find('.share-link-box') .then(($obj) => { - linkText = $obj.text() + linkText = $obj.text().trim() cy.log(linkText) }) } @@ -40,7 +40,7 @@ export const genTest = (type, xcdb) => { cy.openTableTab('City') // store base URL- to re-visit and delete form view later cy.url().then((url) => { - baseURL = url + storedURL = url }) generateLinkWithPwd() @@ -55,7 +55,9 @@ export const genTest = (type, xcdb) => { }) it('Share view with incorrect password', () => { - cy.visit(linkText) + cy.visit(linkText, { + baseUrl: null + }) // wait for share view page to load! cy.wait(1000) // feed password @@ -69,7 +71,9 @@ export const genTest = (type, xcdb) => { // fallover test- use previously opened view & continue verification instead of opening again it('Share view with correct password', () => { - // cy.visit(linkText) + // cy.visit(linkText, { + // baseUrl: null + // }) // // wait for share view page to load! // cy.wait(1000) // feed password @@ -82,7 +86,9 @@ export const genTest = (type, xcdb) => { }) it('Delete view', () => { - cy.visit(baseURL) + cy.visit(storedURL, { + baseUrl: null + }) mainPage.deleteCreatedViews() }) diff --git a/scripts/cypress/integration/common/4c_form_view_detailed.js b/scripts/cypress/integration/common/4c_form_view_detailed.js index 4a1bd7495e..122cec4511 100644 --- a/scripts/cypress/integration/common/4c_form_view_detailed.js +++ b/scripts/cypress/integration/common/4c_form_view_detailed.js @@ -281,7 +281,9 @@ export const genTest = (type, xcdb) => { it(`Validate ${viewType}: URL validation after re-access`, () => { // visit URL cy.log(formViewURL) - cy.visit(formViewURL) + cy.visit(formViewURL, { + baseUrl: null + }) // New form appeared? Header & description should exist cy.get('.nc-form', { timeout: 10000 }) diff --git a/scripts/cypress/integration/common/4e_form_view_share.js b/scripts/cypress/integration/common/4e_form_view_share.js index 9dc2148105..e490cb0239 100644 --- a/scripts/cypress/integration/common/4e_form_view_share.js +++ b/scripts/cypress/integration/common/4e_form_view_share.js @@ -2,7 +2,7 @@ import { loginPage } from "../../support/page_objects/navigation" import { isTestSuiteActive } from "../../support/page_objects/projectConstants" import { mainPage } from "../../support/page_objects/mainPage" -let baseURL = '' +let storedURL = '' export const genTest = (type, xcdb) => { if(!isTestSuiteActive(type, xcdb)) return; @@ -63,7 +63,7 @@ export const genTest = (type, xcdb) => { // store base URL- to re-visit and delete form view later cy.url().then((url) => { - baseURL = url + storedURL = url }) }) @@ -79,9 +79,11 @@ export const genTest = (type, xcdb) => { .contains('/nc/form/', {timeout: 10000}) .then(($obj) => { - let linkText = $obj.text() + let linkText = $obj.text().trim() cy.log(linkText) - cy.visit(linkText) + cy.visit(linkText, { + baseUrl: null + }) // wait for share view page to load! cy.wait(5000) @@ -137,7 +139,9 @@ export const genTest = (type, xcdb) => { it(`Delete ${viewType} view`, () => { // go back to base page - cy.visit(baseURL) + cy.visit(storedURL, { + baseUrl: null + }) // number of view entries should be 2 before we delete cy.get('.nc-view-item').its('length').should('eq', 2) diff --git a/scripts/cypress/integration/common/4f_grid_view_share.js b/scripts/cypress/integration/common/4f_grid_view_share.js index 296437da6d..1ab5e22216 100644 --- a/scripts/cypress/integration/common/4f_grid_view_share.js +++ b/scripts/cypress/integration/common/4f_grid_view_share.js @@ -2,7 +2,7 @@ import { loginPage } from "../../support/page_objects/navigation" import { isTestSuiteActive } from "../../support/page_objects/projectConstants" import { mainPage } from "../../support/page_objects/mainPage" -let baseURL = '' +let storedURL = '' // 0: all enabled // 1: field hide @@ -31,7 +31,7 @@ export const genTest = (type, xcdb) => { .then(($obj) => { cy.get('body').type('{esc}') // viewURL.push($obj.text()) - viewURL[viewName] = $obj.text() + viewURL[viewName] = $obj.text().trim() cy.wait(1000) }) } @@ -88,7 +88,7 @@ export const genTest = (type, xcdb) => { // store base URL- to re-visit and delete form view later cy.url().then((url) => { - baseURL = url + storedURL = url }) }) @@ -127,7 +127,9 @@ export const genTest = (type, xcdb) => { it(`Share ${viewType.toUpperCase()} view : Visit URL, Verify title`, () => { // visit public view - cy.visit(viewURL['combined']) + cy.visit(viewURL['combined'], { + baseUrl: null + }) // wait for public view page to load! cy.wait(5000) @@ -374,7 +376,9 @@ export const genTest = (type, xcdb) => { it(`Delete ${viewType.toUpperCase()} view`, () => { // go back to base page - cy.visit(baseURL) + cy.visit(storedURL, { + baseUrl: null + }) // number of view entries should be 2 before we delete cy.get('.nc-view-item').its('length').should('eq', 2) @@ -483,7 +487,7 @@ export const genTest = (type, xcdb) => { cy.saveLocalStorage() // store base URL- to re-visit and delete form view later cy.url().then((url) => { - baseURL = url + storedURL = url generateViewLink('rowColUpdate') }) }) @@ -491,7 +495,9 @@ export const genTest = (type, xcdb) => { after(() => { // close table cy.restoreLocalStorage(); - cy.visit(baseURL) + cy.visit(storedURL, { + baseUrl: null + }) // delete row mainPage.getPagination(5).click() @@ -527,7 +533,9 @@ export const genTest = (type, xcdb) => { // visit public view cy.log(viewURL['rowColUpdate']) cy.restoreLocalStorage(); - cy.visit(viewURL['rowColUpdate']) //5 + cy.visit(viewURL['rowColUpdate'], { + baseUrl: null + }) //5 // wait for public view page to load! cy.wait(5000) }) diff --git a/scripts/cypress/integration/common/5a_user_role.js b/scripts/cypress/integration/common/5a_user_role.js index c752cc7ee8..6002b24ad4 100644 --- a/scripts/cypress/integration/common/5a_user_role.js +++ b/scripts/cypress/integration/common/5a_user_role.js @@ -45,7 +45,9 @@ export const genTest = (type, xcdb) => { if (roleType != 'owner') { it(`[${roles[roleType].name}] SignIn, Open project`, () => { cy.log(mainPage.roleURL[roleType]) - cy.visit(mainPage.roleURL[roleType]) + cy.visit(mainPage.roleURL[roleType], { + baseUrl: null + }) cy.wait(3000) // Redirected to new URL, feed details diff --git a/scripts/cypress/integration/common/6c_swagger_api.js b/scripts/cypress/integration/common/6c_swagger_api.js index 533186949f..85a22c0cc3 100644 --- a/scripts/cypress/integration/common/6c_swagger_api.js +++ b/scripts/cypress/integration/common/6c_swagger_api.js @@ -57,7 +57,9 @@ export const genTest = (type, xcdb) => { let URL = jsonPayload.SWAGGER_URL Token = jsonPayload.AUTH_TOKEN - cy.visit(URL).then(() => { + cy.visit(URL, { + baseUrl: null + }).then(() => { // wait to allow time for SWAGGER Library loading to finish cy.wait(5000) diff --git a/scripts/cypress/integration/common/6f_attachments.js b/scripts/cypress/integration/common/6f_attachments.js index 0f1a4507d5..2e9b51fe11 100644 --- a/scripts/cypress/integration/common/6f_attachments.js +++ b/scripts/cypress/integration/common/6f_attachments.js @@ -54,7 +54,9 @@ export const genTest = (type, xcdb) => { let linkText = $obj.text().trim() cy.log(linkText) - cy.visit(linkText) + cy.visit(linkText, { + baseUrl: null + }) // wait for share view page to load! cy.wait(5000) diff --git a/scripts/cypress/integration/common/6g_base_share.js b/scripts/cypress/integration/common/6g_base_share.js index a1ae4bc2ea..6948d71b04 100644 --- a/scripts/cypress/integration/common/6g_base_share.js +++ b/scripts/cypress/integration/common/6g_base_share.js @@ -41,7 +41,7 @@ export const genTest = (type, xcdb) => { .find('.nc-url') .then(($obj) => { cy.log($obj[0]) - linkText = $obj[0].innerText + linkText = $obj[0].innerText.trim() }) }) @@ -49,7 +49,9 @@ export const genTest = (type, xcdb) => { cy.log(linkText) // visit URL & wait for page load to complete - cy.visit(linkText) + cy.visit(linkText, { + baseUrl: null + }) projectsPage.waitHomePageLoad() }) diff --git a/scripts/cypress/support/page_objects/mainPage.js b/scripts/cypress/support/page_objects/mainPage.js index 95b50e4982..b6ee454a51 100644 --- a/scripts/cypress/support/page_objects/mainPage.js +++ b/scripts/cypress/support/page_objects/mainPage.js @@ -99,7 +99,7 @@ export class _mainPage { // get URL, invoke cy.getActiveModal().find('.v-alert').then(($obj) => { - linkText = $obj.text() + linkText = $obj.text().trim() cy.log(linkText) this.roleURL[roleType] = linkText