forked from enviPath/enviPy
## Major Changes - Implement a REST style API app in epapi - Currently implements a GET method for all entity types in the browse menu (both package level and global) - Provides paginated results per default with query style filtering for reviewed vs unreviewed. - Provides new paginated templates with thin wrappers per entity types for easier maintainability - Implements e2e tests for the API ## Minor changes - Added more comprehensive gitignore to cover coverage reports and other test/node.js etc. data. - Add additional CI file for API tests that only gets triggered on API relevant changes. ## ⚠️ Currently only works with session-based authentication. Token based will be added in new PR. Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Co-authored-by: jebus <lorsbach@envipath.com> Reviewed-on: enviPath/enviPy#243 Co-authored-by: Tobias O <tobias.olenyi@envipath.com> Co-committed-by: Tobias O <tobias.olenyi@envipath.com>
68 lines
3.2 KiB
Python
68 lines
3.2 KiB
Python
import re
|
|
from django.test import tag
|
|
from playwright.sync_api import expect
|
|
|
|
from .frontend_base import EnviPyStaticLiveServerTestCase
|
|
|
|
|
|
class TestPackagePage(EnviPyStaticLiveServerTestCase):
|
|
@tag("frontend")
|
|
def test_create_package(self):
|
|
page = self.login()
|
|
page = self.create_package(page)
|
|
# Check the package name is correct
|
|
expect(page.locator("h2")).to_contain_text("test package")
|
|
|
|
@tag("frontend")
|
|
def test_package_permissions(self):
|
|
page = self.login()
|
|
page = self.create_package(page)
|
|
page.get_by_role("button", name="Actions").click()
|
|
page.get_by_role("button", name="Edit Permissions").click()
|
|
# Add read and write permission to enviPath Users group
|
|
page.locator("#select_grantee").select_option(label="enviPath Users")
|
|
page.locator("#read_new").check()
|
|
page.locator("#write_new").check()
|
|
page.get_by_role("button", name="+", exact=True).click()
|
|
page.get_by_role("button", name="Actions").click()
|
|
page.get_by_role("button", name="Edit Permissions").click()
|
|
# Check the permissions saved when re-opening the permissions box
|
|
expect(page.get_by_text("enviPath Users")).to_be_visible()
|
|
|
|
@tag("frontend")
|
|
def test_predict_in_package(self):
|
|
page = self.login()
|
|
page = self.create_package(page)
|
|
pathway_button = page.get_by_role("link", name="Pathways")
|
|
# Find number of current pathways by extracting it from pathway button
|
|
num_pathways = int(re.search(r"Pathways \((\d+)\)", pathway_button.inner_text()).group(1))
|
|
pathway_button.click()
|
|
page.get_by_role("link", name="New Pathway").click()
|
|
# Check that the predict page 'in [package_name]' text shows the current package
|
|
expect(page.get_by_role("strong").get_by_text("test package")).to_be_visible()
|
|
page.get_by_role("textbox", name="Name").click()
|
|
page.get_by_role("textbox", name="Name").fill("Test Pathway")
|
|
page.get_by_role("textbox", name="Description").click()
|
|
page.get_by_role("textbox", name="Description").fill("Test description")
|
|
page.get_by_role("textbox", name="SMILES").click()
|
|
page.get_by_role("textbox", name="SMILES").fill("OCCCN")
|
|
page.locator("#predict-submit-button").click()
|
|
# Check a pathway is visible
|
|
expect(page.locator("rect")).to_be_visible()
|
|
page.get_by_role("link", name="test package").click()
|
|
# Check that the package now has one more pathway than initially
|
|
expect(page.locator("#docContent")).to_contain_text(f"Pathways ({num_pathways + 1})")
|
|
|
|
@staticmethod
|
|
def create_package(page):
|
|
"""Make a new empty package with name 'test package'"""
|
|
page.get_by_role("button", name="Browse").click()
|
|
page.get_by_role("link", name="Package", exact=True).click()
|
|
page.locator("#new-package-button").click()
|
|
page.get_by_role("textbox", name="Name").click()
|
|
page.get_by_role("textbox", name="Name").fill("test package")
|
|
page.get_by_role("textbox", name="Description").click()
|
|
page.get_by_role("textbox", name="Description").fill("test description")
|
|
page.get_by_role("button", name="Submit").click()
|
|
return page
|