diff --git a/web/pgadmin/feature_tests/connect_to_server_feature_test.py b/web/pgadmin/feature_tests/connect_to_server_feature_test.py index 3999c6e..84ac925 100644 --- a/web/pgadmin/feature_tests/connect_to_server_feature_test.py +++ b/web/pgadmin/feature_tests/connect_to_server_feature_test.py @@ -23,6 +23,7 @@ class ConnectsToServerFeatureTest(BaseFeatureTest): ] def before(self): + test_utils.zoom_out(self.driver) connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], @@ -50,6 +51,7 @@ class ConnectsToServerFeatureTest(BaseFeatureTest): self.server['host'], self.server['port']) test_utils.drop_database(connection, "acceptance_test_db") + test_utils.zoom_in(self.driver) def _connects_to_server(self): self.page.find_by_xpath("//*[@class='aciTreeText' and .='Servers']").click() diff --git a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py index 338e5f7..3a2b762 100644 --- a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py +++ b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py @@ -27,6 +27,7 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest): ] def before(self): + test_utils.zoom_out(self.driver) connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], @@ -83,3 +84,4 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest): self.server['host'], self.server['port']) test_utils.drop_database(connection, "acceptance_test_db") + test_utils.zoom_in(self.driver) diff --git a/web/pgadmin/feature_tests/pg_datatype_validation_test.py b/web/pgadmin/feature_tests/pg_datatype_validation_test.py index fdc65a5..b0d7492 100644 --- a/web/pgadmin/feature_tests/pg_datatype_validation_test.py +++ b/web/pgadmin/feature_tests/pg_datatype_validation_test.py @@ -27,6 +27,7 @@ class PGDataypeFeatureTest(BaseFeatureTest): ] def before(self): + test_utils.zoom_out(self.driver) connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], @@ -52,6 +53,7 @@ class PGDataypeFeatureTest(BaseFeatureTest): self.server['host'], self.server['port']) test_utils.drop_database(connection, "acceptance_test_db") + test_utils.zoom_in(self.driver) def _connects_to_server(self): self.page.find_by_xpath("//*[@class='aciTreeText' and .='Servers']").click() @@ -78,20 +80,29 @@ class PGDataypeFeatureTest(BaseFeatureTest): self.page.toggle_open_tree_item('public') def _check_datatype(self): - query = """SELECT -32767::smallint, 32767::smallint, -2147483647::integer, 2147483647::integer, -9223372036854775807::bigint, 9223372036854775807::bigint,922337203685.4775807::decimal, 92203685.477::decimal, -922337203685.922337203685::numeric,-92233720368547758.08::numeric;""" - # TODO :: Currently there is an issue with ARRAY[1, 2, 'nan']::float[] == "1, 2, 'nan'" datatype, + query = """ +SELECT -32767::smallint, 32767::smallint, -2147483647::integer, + 2147483647::integer, 9223372036854775807::bigint, + 9223372036854775807::bigint, 922337203685.4775807::decimal, + 92203685.477::decimal, 922337203685.922337203685::numeric, + -92233720368547758.08::numeric; +""" + # TODO :: Currently there is an issue with + # ARRAY[1, 2, 'nan']::float[] == "1, 2, 'nan'" datatype, # so ignoring this, will add once the issue will be fixed. - expected_output = ['-32767', '32767', '-2147483647', '2147483647', '9223372036854775807', '9223372036854775807', - '922337203685.4775807', '92203685.477', '922337203685.922337203685', '-92233720368547758.08' - ] + expected_output = [ + '-32767', '32767', '-2147483647', '2147483647', + '9223372036854775807', '9223372036854775807', + '922337203685.4775807', '92203685.477', + '922337203685.922337203685', '-92233720368547758.08' + ] self.page.driver.find_element_by_link_text("Tools").click() self.page.find_by_partial_link_text("Query Tool").click() wait = WebDriverWait(self.page.driver, 5) - element = wait.until(EC.frame_to_be_available_and_switch_to_it((By.TAG_NAME, 'iframe'))) + element = wait.until(EC.frame_to_be_available_and_switch_to_it(( + By.TAG_NAME, 'iframe'))) if element: self.page.fill_codemirror_area_with(query) diff --git a/web/pgadmin/feature_tests/table_ddl_feature_test.py b/web/pgadmin/feature_tests/table_ddl_feature_test.py index a29995e..13adf3a 100644 --- a/web/pgadmin/feature_tests/table_ddl_feature_test.py +++ b/web/pgadmin/feature_tests/table_ddl_feature_test.py @@ -19,6 +19,7 @@ class TableDdlFeatureTest(BaseFeatureTest): ] def before(self): + test_utils.zoom_out(self.driver) connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], @@ -53,3 +54,4 @@ class TableDdlFeatureTest(BaseFeatureTest): self.server['host'], self.server['port']) test_utils.drop_database(connection, "acceptance_test_db") + test_utils.zoom_in(self.driver) diff --git a/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py b/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py index 526d4e7..3162171 100644 --- a/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py +++ b/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py @@ -32,6 +32,7 @@ class CheckForXssFeatureTest(BaseFeatureTest): ] def before(self): + test_utils.zoom_out(self.driver) connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], @@ -69,6 +70,7 @@ class CheckForXssFeatureTest(BaseFeatureTest): self.server['host'], self.server['port']) test_utils.drop_database(connection, "acceptance_test_db") + test_utils.zoom_in(self.driver) def _connects_to_server(self): self.page.find_by_xpath("//*[@class='aciTreeText' and .='Servers']").click() diff --git a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py index 17bc7bf..f8c2fba 100644 --- a/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py +++ b/web/pgadmin/feature_tests/xss_checks_pgadmin_debugger_test.py @@ -20,6 +20,7 @@ class CheckDebuggerForXssFeatureTest(BaseFeatureTest): ] def before(self): + test_utils.zoom_out(self.driver) with test_utils.Database(self.server) as (connection, _): if connection.server_version < 90100: self.skipTest("Functions tree node is not present in pgAdmin below PG v9.1") @@ -39,6 +40,7 @@ class CheckDebuggerForXssFeatureTest(BaseFeatureTest): test_utils.drop_debug_function(self.server, "postgres", "test_function") self.page.remove_server(self.server) + test_utils.zoom_in(self.driver) def _connects_to_server(self): self.page.find_by_xpath("//*[@class='aciTreeText' and .='Servers']").click() diff --git a/web/regression/feature_utils/app_starter.py b/web/regression/feature_utils/app_starter.py index 96cc516..6d7eecc 100644 --- a/web/regression/feature_utils/app_starter.py +++ b/web/regression/feature_utils/app_starter.py @@ -10,7 +10,7 @@ import os import subprocess import signal import random - +import tkinter as tk class AppStarter: """ Helper for starting the full pgadmin4 app and loading the page via @@ -39,7 +39,57 @@ class AppStarter: env=env ) - self.driver.set_window_size(1024, 1024) + test_screen_width = 1024 + test_screen_height = 1024 + zoom_level_width = "100" + zoom_level_height = "100" + is_width_zooming_required = False + is_height_zooming_required = False + + root = tk.Tk() + monitor_width_px = root.winfo_screenwidth() + monitor_height_px = root.winfo_screenheight() + print("Monitor: ", monitor_width_px, 'x', monitor_height_px) + + if monitor_width_px < test_screen_width: + test_screen_width = monitor_width_px + is_width_zooming_required = True + + if monitor_height_px < test_screen_height: + test_screen_height = monitor_height_px + is_height_zooming_required = True + + if is_width_zooming_required: + # Set the zoom level here + screen_difference_ratio = int( + int(test_screen_width)/int(monitor_width_px) + ) + if screen_difference_ratio == 1: + zoom_level_width = "75" + elif screen_difference_ratio >= 2: + zoom_level_width = "50" + + if is_height_zooming_required: + # Set the zoom level here + screen_difference_ratio = int( + int(test_screen_height)/int(monitor_height_px) + ) + if screen_difference_ratio == 1: + zoom_level_height = "75" + elif screen_difference_ratio >= 2: + zoom_level_height = "50" + + if is_width_zooming_required or is_height_zooming_required: + os.environ["ZOOM_LEVEL"] = zoom_level_width if \ + int(zoom_level_width) < int(zoom_level_height) else \ + zoom_level_height + + print("SET BROWSER:", test_screen_width, 'x', test_screen_height) + # Set the browser window size + self.driver.set_window_size( + test_screen_width, test_screen_height + ) + self.driver.get( "http://" + self.app_config.DEFAULT_SERVER + ":" + random_server_port) diff --git a/web/regression/feature_utils/base_feature_test.py b/web/regression/feature_utils/base_feature_test.py index 8995429..e645cae 100644 --- a/web/regression/feature_utils/base_feature_test.py +++ b/web/regression/feature_utils/base_feature_test.py @@ -60,6 +60,9 @@ class BaseFeatureTest(BaseTestGenerator): self._screenshot() self.after() + # Clear the env variable + if 'ZOOM_LEVEL' in os.environ: + del os.environ['ZOOM_LEVEL'] def any_step_failed(self): for step in self._outcome.errors: @@ -98,4 +101,4 @@ class BaseFeatureTest(BaseTestGenerator): if e.errno == errno.EEXIST: pass else: - raise + raise \ No newline at end of file diff --git a/web/regression/python_test_utils/test_utils.py b/web/regression/python_test_utils/test_utils.py index 2b7c695..a18d717 100644 --- a/web/regression/python_test_utils/test_utils.py +++ b/web/regression/python_test_utils/test_utils.py @@ -611,3 +611,23 @@ class Database: def __exit__(self, type, value, traceback): self.connection.close() drop_database(self.maintenance_connection, self.name) + + +def zoom_in(driver, default_zoom_level=100): + if 'ZOOM_LEVEL' in os.environ: + zoom_level = os.environ.get('ZOOM_LEVEL') + if zoom_level is None or int(zoom_level) == 100: + return + driver.execute_script( + "document.body.style.zoom='{0}%'".format(default_zoom_level) + ) + + +def zoom_out(driver, zoom_level=100): + if 'ZOOM_LEVEL' in os.environ: + zoom_level = os.environ.get('ZOOM_LEVEL') + if zoom_level is None or int(zoom_level) == 100: + return + driver.execute_script( + "document.body.style.zoom='{0}%'".format(zoom_level) + )