Skip to content

Commit

Permalink
update smoke tests to use customerdomain instead of domain; add windo…
Browse files Browse the repository at this point in the history
…w-size argument to chrome_options to fix failing selenium test
  • Loading branch information
mitchelbaker-cisa committed Sep 18, 2024
1 parent c208006 commit 228ccb5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run_smoke_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ jobs:
json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }}

- name: Run ScubaGoggles and check for correct output
run: pytest -s -vvv ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}"
run: pytest ./Testing/Functional/SmokeTests/ -s -vvv --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --customerdomain="${{ secrets.GWS_DOMAIN }}"
1 change: 1 addition & 0 deletions Testing/Functional/SmokeTests/selenium_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Browser:
def __init__(self):
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=1200,800")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")

Expand Down
4 changes: 2 additions & 2 deletions Testing/Functional/SmokeTests/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_scubaresults(self):
except (ValueError, Exception) as e:
pytest.fail(f"An error occurred, {e}")

def test_scubagoggles_report(self, browser, domain):
def test_scubagoggles_report(self, browser, customerdomain):
"""
Test if the generated baseline reports are correct,
i.e. BaselineReports.html, CalendarReport.html, ChatReport.html
Expand All @@ -66,7 +66,7 @@ def test_scubagoggles_report(self, browser, domain):
output_path: str = get_output_path()
report_path: str = prepend_file_protocol(os.path.join(output_path, BASELINE_REPORTS))
browser.get(report_path)
run_selenium(browser, domain)
run_selenium(browser, customerdomain)
except (ValueError, AssertionError, Exception) as e:
browser.quit()
pytest.fail(f"An error occurred, {e}")
22 changes: 11 additions & 11 deletions Testing/Functional/SmokeTests/smoke_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ def verify_scubaresults(jsonfile):
if summary["Errors"] != 0:
raise ValueError(f"{product} contains errors in the report")

def run_selenium(browser, domain):
def run_selenium(browser, customerdomain):
"""
Run Selenium tests against the generated reports.
Args:
browser: A Selenium WebDriver instance
domain: The user's domain
customerdomain: The customer domain
"""
verify_navigation_links(browser)
h1 = browser.find_element(By.TAG_NAME, "h1").text
Expand All @@ -149,9 +149,9 @@ def run_selenium(browser, domain):
if len(reports_table) == 10:
for i in range(len(reports_table)):

# Check if domain is present in agency table
# Check if customerdomain is present in agency table
# Skip tool version if assessing the parent report
verify_tenant_table(browser, domain, True)
verify_tenant_table(browser, customerdomain, True)

reports_table = get_reports_table(browser)[i]
baseline_report = reports_table.find_elements(By.TAG_NAME, "td")[0]
Expand All @@ -169,8 +169,8 @@ def run_selenium(browser, domain):
h1 = browser.find_element(By.TAG_NAME, "h1").text
assert h1 == products[product]["title"]

# Check if domain and tool version are present in individual report
verify_tenant_table(browser, domain, False)
# Check if customerdomain and tool version are present in individual report
verify_tenant_table(browser, customerdomain, False)

policy_tables = browser.find_elements(By.TAG_NAME, "table")
for table in policy_tables[1:]:
Expand Down Expand Up @@ -239,14 +239,14 @@ def get_reports_table(browser):
.find_elements(By.TAG_NAME, "tr")
)

def verify_tenant_table(browser, domain, parent):
def verify_tenant_table(browser, customerdomain, parent):
"""
Get the tenant table rows elements from the DOM.
(Table at the top of each report with user domain, baseline/tool version)
(Table at the top of each report with customer domain, baseline/tool version)
Args:
browser: A Selenium WebDriver instance
domain: The user's domain
customerdomain: The customer domain
parent: boolean to determine parent/individual reports
"""
tenant_table_rows = (
Expand All @@ -255,8 +255,8 @@ def verify_tenant_table(browser, domain, parent):
.find_elements(By.TAG_NAME, "tr")
)
assert len(tenant_table_rows) == 2
customer_domain = tenant_table_rows[1].find_elements(By.TAG_NAME, "td")[0].text
assert customer_domain == domain
domain = tenant_table_rows[1].find_elements(By.TAG_NAME, "td")[0].text
assert domain == customerdomain

if not parent:
# Check for correct tool version, e.g. 0.2.0
Expand Down
8 changes: 4 additions & 4 deletions Testing/Functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def pytest_addoption(parser):
parser: An instance of "argparse.ArgumentParser"
"""
parser.addoption("--subjectemail", action="store")
parser.addoption("--domain", action="store")
parser.addoption("--customerdomain", action="store")

@pytest.fixture
def subjectemail(pytestconfig):
Expand All @@ -26,14 +26,14 @@ def subjectemail(pytestconfig):
return pytestconfig.getoption("subjectemail")

@pytest.fixture
def domain(pytestconfig):
def customerdomain(pytestconfig):
"""
Setup code that shares the "domain" parameter across tests.
Setup code that shares the "customerdomain" parameter across tests.
Args:
pytestconfig: Provides access to the "Config" object for a current test session
"""
return pytestconfig.getoption("domain")
return pytestconfig.getoption("customerdomain")

@pytest.fixture
def browser():
Expand Down

0 comments on commit 228ccb5

Please sign in to comment.