From 82e4fdd79172ab5bd4ca082119d3078618332f66 Mon Sep 17 00:00:00 2001 From: nhamza Date: Sun, 12 May 2024 11:59:53 +0300 Subject: [PATCH 1/2] [RFR] added report open validations to run analysis test Signed-off-by: nhamza --- src/images/intellij/Report_logo.png | Bin 0 -> 799 bytes src/models/IDE/Intellij.py | 11 +++-------- src/tests/intellij/test_analysis.py | 25 ++++++++++++------------- 3 files changed, 15 insertions(+), 21 deletions(-) create mode 100644 src/images/intellij/Report_logo.png diff --git a/src/images/intellij/Report_logo.png b/src/images/intellij/Report_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..19aef7e3d6d9a949d9ecddbee0a3e8574796a209 GIT binary patch literal 799 zcmV+)1K|9LP)ZgXgFbngSdJ^%m!Ep$a#bVG7w zVRUJ4ZXi@?ZDjycb#5RrG9XQ1c_1<{GBhADF*-9hIx{vPK}{e@L{vjZ+mtEUxb%=+Y|TMxc6Ug$ok?aF_FSFk`#zrEdEXD-Pj~ua z{RVriq`d|LB(E#udk+04mHvnRRVDA_uJqCk7YkLPan?0edgetY!>{L`#($d^SYHAw! z`T4vVdksKw$vI|c-{SX=;dHtHn4X^68j_U8$x9bFVM@}j)Mzx}sHw%{X+xG}ELIDX zlN0Lx@p#&B)YM`$nzjb%4r94q#`)ui(3wx2i8}^w-nd0^Nr~3KZPK{k z&y%N*H!tdsQTga02Yafu+j}G@2eGurs*gsaq@);B9||oXisGL^cU3w8YgMB*R8bT%GqY45 zi>)9Cg6ai9AQoFueP(7BilS^Ew(*@$ff4OH{Ww35+ugWnt+TUx%ejGpXX^L3-~XGm zRh0JuZRpVOAZM)>TAG`XWtpmK2g;Jd=;#OlrKQ&p(?xvVJ|sz^;og0Qh6m$jYPL5L z3DeixgVX6kk|csNK?)0t)cwN3B7!qPBuT>QbkWz_LnIQ8o2eJmGu&F>P-ubWuc-e9?ivUHiJ$_S$R4AKJWI^2w>wY??#>z`20hAIQ**J8u&Yc?w0n? dBffv2KLH|c(5#cVe~thE002ovPDHLkV1j@jY(oG5 literal 0 HcmV?d00001 diff --git a/src/models/IDE/Intellij.py b/src/models/IDE/Intellij.py index 13d9ac1..5c81566 100644 --- a/src/models/IDE/Intellij.py +++ b/src/models/IDE/Intellij.py @@ -127,14 +127,9 @@ def run_simple_analysis(self, app_name, wait_for_analysis_finish=True): time.sleep(2) wait_for_element(self.image_locator("analysis_complete_terminal.png"), 120) - def open_report_page(self, app_name): - self.click(self.config_run_region) - self.type_text(app_name) - self.press_keys("enter") - self.press_keys("enter") - self.click_element(locator_type="image", locator="report_selector.png") - # Verify the report page is opened - self.wait_find_element(locator_type="image", locator="report_page_header.png") + def open_report_page(self): + coordinates = find_on_screen(self.image_locator("Report_logo.png")) + pyautogui.click(coordinates) def refresh_configuration(self): """ diff --git a/src/tests/intellij/test_analysis.py b/src/tests/intellij/test_analysis.py index c921163..12bdf4e 100644 --- a/src/tests/intellij/test_analysis.py +++ b/src/tests/intellij/test_analysis.py @@ -4,28 +4,27 @@ import pytest +from src.models.chrome import Chrome + +chrome = Chrome() DATA_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) + "/data/" @pytest.mark.parametrize("app_name", json.load(open(DATA_DIR + "analysis.json"))) @pytest.mark.parametrize("ide", ["intellij"]) @pytest.mark.intellij -def test_analysis_intellij(configurations, setup_intellij, app_name, analysis_data, ide): +def test_analysis_intellij(configurations, setup_intellij, app_name, analysis_data, ide, intellij_config): """ Analysis tests for intellij using various migration paths """ intellij = setup_intellij - application_data = analysis_data[app_name] - expected_story_points = application_data["story_points"] - - # Intellij freezes without this sleep + # TODO: add story point verification and report opening time.sleep(3) intellij.run_simple_analysis(app_name) - intellij.open_report_page(app_name) - - _, html_file_location = configurations - if "skip_reports" not in application_data["options"]: - intellij.verify_story_points( - html_file_location=html_file_location, - expected_story_points=expected_story_points, - ) + _, report_file_path, id = configurations + intellij.open_report_page() + chrome.focus_tab(id) + active_url = chrome.get_chrome_focused_tab_url() + assert id in active_url, "The report that was opened is not for this analysis run" + chrome.close_tab(id) + intellij.set_focus() From aedbaca3199e75faa7d722872cfdc7e324de766c Mon Sep 17 00:00:00 2001 From: nhamza Date: Sun, 12 May 2024 13:05:03 +0300 Subject: [PATCH 2/2] add seperate test for report opened Signed-off-by: nhamza --- src/models/IDE/Intellij.py | 2 +- src/tests/intellij/test_analysis.py | 11 -------- src/tests/intellij/test_report_opened.py | 33 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 src/tests/intellij/test_report_opened.py diff --git a/src/models/IDE/Intellij.py b/src/models/IDE/Intellij.py index 5c81566..7f7df76 100644 --- a/src/models/IDE/Intellij.py +++ b/src/models/IDE/Intellij.py @@ -125,7 +125,7 @@ def run_simple_analysis(self, app_name, wait_for_analysis_finish=True): # Wait for analysis to be completed in IDE terminal if wait_for_analysis_finish: time.sleep(2) - wait_for_element(self.image_locator("analysis_complete_terminal.png"), 120) + wait_for_element(self.image_locator("analysis_complete_terminal.png"), 160) def open_report_page(self): coordinates = find_on_screen(self.image_locator("Report_logo.png")) diff --git a/src/tests/intellij/test_analysis.py b/src/tests/intellij/test_analysis.py index 12bdf4e..d244f88 100644 --- a/src/tests/intellij/test_analysis.py +++ b/src/tests/intellij/test_analysis.py @@ -4,9 +4,6 @@ import pytest -from src.models.chrome import Chrome - -chrome = Chrome() DATA_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) + "/data/" @@ -18,13 +15,5 @@ def test_analysis_intellij(configurations, setup_intellij, app_name, analysis_da Analysis tests for intellij using various migration paths """ intellij = setup_intellij - # TODO: add story point verification and report opening time.sleep(3) intellij.run_simple_analysis(app_name) - _, report_file_path, id = configurations - intellij.open_report_page() - chrome.focus_tab(id) - active_url = chrome.get_chrome_focused_tab_url() - assert id in active_url, "The report that was opened is not for this analysis run" - chrome.close_tab(id) - intellij.set_focus() diff --git a/src/tests/intellij/test_report_opened.py b/src/tests/intellij/test_report_opened.py new file mode 100644 index 0000000..0f4fc72 --- /dev/null +++ b/src/tests/intellij/test_report_opened.py @@ -0,0 +1,33 @@ +import time + +import pytest + +from src.models.chrome import Chrome + +APP_NAME = "report opened" + +chrome = Chrome() + + +@pytest.mark.parametrize("app_name", [APP_NAME]) +@pytest.mark.parametrize( + "analysis_data", + [ + { + APP_NAME: {"options": {"target": ["eap8"]}}, + }, + ], +) +@pytest.mark.parametrize("ide", ["intellij"]) +@pytest.mark.intellij +def test_report_opened(configurations, setup_intellij, app_name, analysis_data, ide, intellij_config): + intellij = setup_intellij + time.sleep(3) + intellij.run_simple_analysis(app_name) + _, report_file_path, id = configurations + intellij.open_report_page() + chrome.focus_tab(id) + active_url = chrome.get_chrome_focused_tab_url() + assert id in active_url, "The report that was opened is not for this analysis run" + chrome.close_tab(id) + intellij.set_focus()