-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OPIK-599 Andrei/tests linting (#881)
* basic experiment items tests * linting * forgot the rest of the files * package bases * fix check again * linting errors * one more f-string * temporary leniency for untyped stuff * oops * more fixes * more * wrong path * running into an interactive prompt * that wasnt working apparently * linter fixes * fixed imports * lint fix --------- Co-authored-by: Andrei Căutișanu <[email protected]>
- Loading branch information
1 parent
2f81aea
commit b7d82d7
Showing
37 changed files
with
977 additions
and
683 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
name: E2E Tests Linter | ||
run-name: "E2E Tests Linter ${{ github.ref_name }} by @${{ github.actor }}" | ||
on: | ||
pull_request: | ||
paths: | ||
- 'tests_end_to_end/**' | ||
push: | ||
branches: | ||
- 'main' | ||
paths: | ||
- 'tests_end_to_end/**' | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: tests_end_to_end | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: install pre-commit | ||
run: pip install pre-commit | ||
- name: linting | ||
run: pre-commit run --all-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v5.0.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
files: ^tests_end_to_end | ||
- id: end-of-file-fixer | ||
files: ^tests_end_to_end | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.4.9 | ||
hooks: | ||
- id: ruff | ||
args: [ --fix, --show-fixes] | ||
files: ^tests_end_to_end | ||
- id: ruff-format | ||
files: ^tests_end_to_end | ||
|
||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.10.0 | ||
hooks: | ||
- id: mypy | ||
files: ^tests_end_to_end | ||
args: [--config-file, tests_end_to_end/pyproject.toml] | ||
additional_dependencies: ['types-PyYAML'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ if [[ $retries -eq $max_retries ]]; then | |
echo "Containers failed to start" | ||
docker compose ps | ||
exit 1 | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from playwright.sync_api import Page, expect | ||
|
||
|
||
def test_app_loads(page: Page): | ||
page.goto("http://localhost:5173/default/projects") | ||
expect(page.get_by_role("heading", name="Projects")).to_be_visible() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,99 @@ | ||
from playwright.sync_api import Page, expect, Locator | ||
from playwright.sync_api import Page | ||
|
||
|
||
class DatasetItemsPage: | ||
def __init__(self, page: Page): | ||
self.page = page | ||
self.next_page_button_locator = self.page.locator("div:has(> button:nth-of-type(4))").locator('button:nth-of-type(3)') | ||
self.next_page_button_locator = self.page.locator( | ||
"div:has(> button:nth-of-type(4))" | ||
).locator("button:nth-of-type(3)") | ||
|
||
def remove_default_columns(self): | ||
self.page.get_by_role('button', name='Columns').click() | ||
created_toggle = self.page.get_by_role('button', name='Created', exact=True).get_by_role('checkbox') | ||
self.page.get_by_role("button", name="Columns").click() | ||
created_toggle = self.page.get_by_role( | ||
"button", name="Created", exact=True | ||
).get_by_role("checkbox") | ||
if created_toggle.is_checked(): | ||
created_toggle.click() | ||
|
||
last_updated_toggle = self.page.get_by_role('button', name='Last updated').get_by_role('checkbox') | ||
|
||
last_updated_toggle = self.page.get_by_role( | ||
"button", name="Last updated" | ||
).get_by_role("checkbox") | ||
if last_updated_toggle.is_checked(): | ||
last_updated_toggle.click() | ||
|
||
created_by_toggle = self.page.get_by_role('button', name='Created by', exact=True).get_by_role('checkbox') | ||
created_by_toggle = self.page.get_by_role( | ||
"button", name="Created by", exact=True | ||
).get_by_role("checkbox") | ||
if created_by_toggle.is_checked(): | ||
created_by_toggle.click() | ||
|
||
self.page.keyboard.press('Escape') | ||
|
||
self.page.keyboard.press("Escape") | ||
|
||
def delete_first_item_on_page_and_return_content(self): | ||
self.remove_default_columns() | ||
keys: list[str] = self.page.locator('th').all_inner_texts()[1:-1] | ||
item={} | ||
keys: list[str] = self.page.locator("th").all_inner_texts()[1:-1] | ||
item = {} | ||
|
||
row = self.page.locator('tr').nth(1) | ||
cells = row.locator('td').all() | ||
row = self.page.locator("tr").nth(1) | ||
cells = row.locator("td").all() | ||
for cell_index, cell in enumerate(cells[1:-1]): | ||
content = '' | ||
content = "" | ||
if cell_index == 0: | ||
cell.get_by_role('button').hover() | ||
row.get_by_role('button').nth(1).click() | ||
content = self.page.evaluate('navigator.clipboard.readText()') | ||
cell.get_by_role("button").hover() | ||
row.get_by_role("button").nth(1).click() | ||
content = self.page.evaluate("navigator.clipboard.readText()") | ||
else: | ||
content = cell.text_content() | ||
item[keys[cell_index]] = content | ||
|
||
row.get_by_role('button', name='Actions menu').click() | ||
self.page.get_by_role('menuitem', name='Delete').click() | ||
self.page.get_by_role('button', name='Delete dataset item').click() | ||
|
||
return item | ||
row.get_by_role("button", name="Actions menu").click() | ||
self.page.get_by_role("menuitem", name="Delete").click() | ||
self.page.get_by_role("button", name="Delete dataset item").click() | ||
|
||
return item | ||
|
||
def insert_dataset_item(self, item: str): | ||
self.page.get_by_role('button', name='Create dataset item').click() | ||
textbox = self.page.get_by_role('textbox') | ||
self.page.get_by_role("button", name="Create dataset item").click() | ||
textbox = self.page.get_by_role("textbox") | ||
textbox.focus() | ||
self.page.keyboard.press('Meta+A') | ||
self.page.keyboard.press('Backspace') | ||
self.page.keyboard.press("Meta+A") | ||
self.page.keyboard.press("Backspace") | ||
textbox.fill(item) | ||
self.page.get_by_role('button', name='Create dataset item').click() | ||
self.page.get_by_role("button", name="Create dataset item").click() | ||
|
||
|
||
def get_all_dataset_items_on_current_page(self): | ||
self.remove_default_columns() | ||
|
||
keys: list[str] = self.page.locator('th').all_inner_texts()[1:-1] | ||
keys: list[str] = self.page.locator("th").all_inner_texts()[1:-1] | ||
items = [] | ||
|
||
rows = self.page.locator('tr').all() | ||
rows = self.page.locator("tr").all() | ||
for row_index, row in enumerate(rows[1:]): | ||
item = {} | ||
cells = row.locator('td').all() | ||
cells = row.locator("td").all() | ||
for cell_index, cell in enumerate(cells[1:-1]): | ||
content = '' | ||
content = "" | ||
if cell_index == 0: | ||
cell.get_by_role('button').hover() | ||
row.get_by_role('button').nth(1).click() | ||
content = self.page.evaluate('navigator.clipboard.readText()') | ||
cell.get_by_role("button").hover() | ||
row.get_by_role("button").nth(1).click() | ||
content = self.page.evaluate("navigator.clipboard.readText()") | ||
else: | ||
content = cell.text_content() | ||
item[keys[cell_index]] = content | ||
items.append(item) | ||
|
||
return items | ||
|
||
|
||
def get_all_items_in_dataset(self): | ||
items = [] | ||
items.extend(self.get_all_dataset_items_on_current_page()) | ||
while self.next_page_button_locator.is_visible() and self.next_page_button_locator.is_enabled(): | ||
while ( | ||
self.next_page_button_locator.is_visible() | ||
and self.next_page_button_locator.is_enabled() | ||
): | ||
self.next_page_button_locator.click() | ||
self.page.wait_for_timeout(500) | ||
items.extend(self.get_all_dataset_items_on_current_page()) | ||
|
||
return items | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,54 @@ | ||
from playwright.sync_api import Page, expect, Locator | ||
from playwright.sync_api import Page, Locator | ||
import re | ||
|
||
class ExperimentItemsPage: | ||
|
||
class ExperimentItemsPage: | ||
def __init__(self, page: Page): | ||
self.page = page | ||
self.next_page_button_locator = self.page.locator("div:has(> button:nth-of-type(4))").locator('button:nth-of-type(3)') | ||
self.next_page_button_locator = self.page.locator( | ||
"div:has(> button:nth-of-type(4))" | ||
).locator("button:nth-of-type(3)") | ||
|
||
def get_pagination_button(self) -> Locator: | ||
return self.page.get_by_role('button', name='Showing') | ||
return self.page.get_by_role("button", name="Showing") | ||
|
||
def get_total_number_of_items_in_experiment(self): | ||
pagination_button_text = self.get_pagination_button().inner_text() | ||
match = re.search(r'of (\d+)', pagination_button_text) | ||
match = re.search(r"of (\d+)", pagination_button_text) | ||
if match: | ||
return int(match.group(1)) | ||
else: | ||
return 0 | ||
|
||
def get_id_of_nth_experiment_item(self, n: int): | ||
row = self.page.locator('tr').nth(n+1) | ||
cell = row.locator('td').first | ||
row = self.page.locator("tr").nth(n + 1) | ||
cell = row.locator("td").first | ||
cell.hover() | ||
cell.get_by_role('button').nth(1).click() | ||
id = self.page.evaluate('navigator.clipboard.readText()') | ||
cell.get_by_role("button").nth(1).click() | ||
id = self.page.evaluate("navigator.clipboard.readText()") | ||
return id | ||
|
||
|
||
|
||
def get_all_item_ids_on_current_page(self): | ||
ids = [] | ||
rows = self.page.locator('tr').all() | ||
rows = self.page.locator("tr").all() | ||
for row_index, row in enumerate(rows[2:]): | ||
item = {} | ||
cells = row.locator('td').all() | ||
cell = row.locator('td').first | ||
cell = row.locator("td").first | ||
cell.hover() | ||
cell.get_by_role('button').nth(1).click() | ||
id = self.page.evaluate('navigator.clipboard.readText()') | ||
cell.get_by_role("button").nth(1).click() | ||
id = self.page.evaluate("navigator.clipboard.readText()") | ||
ids.append(id) | ||
|
||
return ids | ||
|
||
|
||
def get_all_item_ids_in_experiment(self): | ||
ids = [] | ||
ids.extend(self.get_all_item_ids_on_current_page()) | ||
while self.next_page_button_locator.is_visible() and self.next_page_button_locator.is_enabled(): | ||
while ( | ||
self.next_page_button_locator.is_visible() | ||
and self.next_page_button_locator.is_enabled() | ||
): | ||
self.next_page_button_locator.click() | ||
self.page.wait_for_timeout(500) | ||
ids.extend(self.get_all_dataset_items_on_current_page()) | ||
|
||
return ids | ||
return ids |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
from playwright.sync_api import Page, expect | ||
|
||
|
||
class IndividualDatasetPage: | ||
def __init__(self, page: Page): | ||
self.page = page | ||
self.traces_table = page.get_by_role('table') | ||
self.traces_table = page.get_by_role("table") | ||
|
||
def check_cell_exists_by_text(self, text): | ||
expect(self.traces_table.get_by_text(text, exact=True)).to_be_visible() | ||
expect(self.traces_table.get_by_text(text, exact=True)).to_be_visible() |
Oops, something went wrong.