From fcf4450a3d9338c56f40199b13b07b3513eeb1af Mon Sep 17 00:00:00 2001 From: "lalitdeore12@gmail.com" Date: Mon, 24 Feb 2025 14:14:37 +0530 Subject: [PATCH] Improved automated page testing script on onprem --- frontend/frontend-testing.sh | 48 ++++++------------------------------ frontend/package.json | 2 +- frontend/selenium-test.js | 5 ++-- frontend/src/App.jsx | 1 + 4 files changed, 13 insertions(+), 43 deletions(-) diff --git a/frontend/frontend-testing.sh b/frontend/frontend-testing.sh index b0e41848..c25c3618 100644 --- a/frontend/frontend-testing.sh +++ b/frontend/frontend-testing.sh @@ -1,51 +1,21 @@ SERVER_URL="http://localhost:3000" -declare -a Routes=() +declare -a Routes=($(grep -oP '(?<=path=")[^"]*' src/App.jsx | grep -E '^[a-zA-Z0-9/_:-]+$' | grep -vE '^/$')) -# Add all cloud routes here -if [[ "$SERVER_URL" == "http://localhost:3001" || "$SERVER_URL" == "http://localhost:3002" || "$SERVER_URL" == "https://sandbox.shuffler.io" || "$SERVER_URL" == "https://shuffler.io" ]]; then -Routes+=( -'homepage' -'home' -'contact' -'workflows/fa9314a7-bb9b-4b41-8885-1d02b199f04d' -'services' -'debug' -'creator' -'articles' -'partners' -'pricing' -'pricing2' -'training' -'professional-services' -'detections' -) -fi +for i in "${!Routes[@]}"; do + Routes[$i]="${Routes[$i]#/}" +done -# Add all common routes here +# # Add all tab routes and unique routes here Routes+=( -'workflows' 'workflows?tab=org_workflows' 'workflows?tab=my_workflows' 'workflows?tab=all_workflows' -'workflows/debug' -'debug' -'usecases' -'usecases2' -'getting-started' -'welcome' -'health' -'docs' -'settings' -'apps/new' 'apps/gmail' 'apis/gmail' -'forms' -'apps' 'apps?tab=my_apps' 'apps?tab=all_apps' -'search' 'search?tab=org_apps' 'search?tab=my_apps' 'search?tab=workflows' @@ -67,13 +37,11 @@ Routes+=( "admin?admin_tab=branding(beta)" ) -ALL_ROUTES=("${Routes[@]}") - # Stop frontend container so it test unpushed changes docker stop shuffle-frontend -# Install all frontend dependencies -yarn install +# # Install all frontend dependencies +yarn add selenium-webdriver --dev && yarn install echo "Starting frontend..." BROWSER=none yarn start & @@ -86,7 +54,7 @@ sleep 60 echo "Server is up! Starting Selenium tests..." echo "Starting frontend tests..." -node selenium-test.js "$SERVER_URL" "${ALL_ROUTES[@]}" +node selenium-test.js "$SERVER_URL" "${Routes[@]}" TEST_EXIT_CODE=$? diff --git a/frontend/package.json b/frontend/package.json index 3616274c..2255f955 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -88,7 +88,6 @@ "remark-rehype": "^11.0.0", "rsuite": "^5.23.0", "search-insights": "^2.2.1", - "selenium-webdriver": "^4.28.1", "shellwords": "^1.0.1", "simplebar": "^4.2.3", "styled-components": "^4.4.1", @@ -129,6 +128,7 @@ "babel-preset-es2015": "^6.24.1", "postcss": "^8.4.38", "promise-window": "^1.2.1", + "selenium-webdriver": "^4.29.0", "webpack-cli": "^5.1.4" } } diff --git a/frontend/selenium-test.js b/frontend/selenium-test.js index eb9b731e..d371f4d5 100644 --- a/frontend/selenium-test.js +++ b/frontend/selenium-test.js @@ -34,8 +34,9 @@ console.log('Starting Selenium script for testing pages...'); if (isCloud) { // Login Credentials const LOGIN_URL = `${frontendURL}/login`; - const USERNAME = 'shuffle-testing@gmail.com'; - const PASSWORD = 'testing@123'; + // put your login credentials here + const USERNAME = ''; + const PASSWORD = ''; console.log('Logging in...'); await driver.get(LOGIN_URL); diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 03d4c77e..6c7d7120 100755 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -297,6 +297,7 @@ const App = (message, props) => { element={