From dd200cd7a9816470cf3b8a6efd3f45fd4e071c1e Mon Sep 17 00:00:00 2001 From: John Brittain Date: Wed, 9 Oct 2024 09:27:37 +0100 Subject: [PATCH] Add system tests --- .github/workflows/ci.yaml | 7 +++-- .../projects/a_first_project_in_list/touch | 0 .../sample_project/parsers/test_parser2.py | 0 .../projects/z_last_project_in_list/touch | 0 tests/system/utils.py | 28 +++++++++---------- 5 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 tests/system/InsightBoard/projects/a_first_project_in_list/touch create mode 100644 tests/system/InsightBoard/projects/sample_project/parsers/test_parser2.py create mode 100644 tests/system/InsightBoard/projects/z_last_project_in_list/touch diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f427c5b..c013ae9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,12 +24,15 @@ jobs: 3.12 - name: Install the latest version of uv uses: astral-sh/setup-uv@v2 - - name: Run tests + - name: Setup test environment run: | uv sync --all-extras - uv sync --dev uv pip install "adtl[parquet] @ git+https://github.com/globaldothealth/adtl" + - name: Unit tests (and coverage report) + run: | uv run pytest --cov=InsightBoard --cov-report=html tests/unit + - name: System tests + run: | uv run pytest tests/system - name: Upload coverage report uses: actions/upload-artifact@v4 diff --git a/tests/system/InsightBoard/projects/a_first_project_in_list/touch b/tests/system/InsightBoard/projects/a_first_project_in_list/touch new file mode 100644 index 0000000..e69de29 diff --git a/tests/system/InsightBoard/projects/sample_project/parsers/test_parser2.py b/tests/system/InsightBoard/projects/sample_project/parsers/test_parser2.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/system/InsightBoard/projects/z_last_project_in_list/touch b/tests/system/InsightBoard/projects/z_last_project_in_list/touch new file mode 100644 index 0000000..e69de29 diff --git a/tests/system/utils.py b/tests/system/utils.py index 1484151..f94a175 100644 --- a/tests/system/utils.py +++ b/tests/system/utils.py @@ -78,13 +78,7 @@ def driver(): def select_project(driver, project_name): - dropdown = driver.find_element(By.ID, "project-dropdown") - dropdown.click() - option_to_select = driver.find_element(By.XPATH, f'//div[text()="{project_name}"]') - option_to_select.click() - # assert that the project is selected - time.sleep(1) - assert dropdown.text == project_name + dropdown_select(driver, "project-dropdown", project_name) def page_upload(driver): @@ -98,6 +92,17 @@ def page_upload(driver): return PageUpload(driver) +def dropdown_select(driver, dropdown_id, option): + dropdown = driver.find_element(By.ID, dropdown_id) + dropdown.click() + option_to_select = dropdown.find_element( + By.XPATH, f'//div[text()="{option}"]' + ) + option_to_select.click() + dropdown_value = dropdown.find_element(By.CLASS_NAME, "Select-value-label") + assert dropdown_value.text == option + + class PageUpload: def __init__(self, driver): self.driver = driver @@ -111,14 +116,7 @@ def clear_data(self): file.unlink() def select_parser(self, parser_name): - dropdown = self.driver.find_element(By.ID, "parser-dropdown") - dropdown.click() - option_to_select = self.driver.find_element( - By.XPATH, f'//div[text()="{parser_name}"]' - ) - option_to_select.click() - time.sleep(1) - assert dropdown.text == parser_name + dropdown_select(self.driver, "parser-dropdown", parser_name) def select_data_file(self, file_path): input_box = self.driver.find_element(By.XPATH, '//input[@type="file"]')