Skip to content

Commit

Permalink
enable execution in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
shapiromatron committed Aug 22, 2024
1 parent 503c55c commit 1e777ad
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 139 deletions.
2 changes: 0 additions & 2 deletions tests/integration/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from django.test import TestCase
from playwright.sync_api import Page

CAN_EXECUTE = os.getenv("CI") is None
RUN_INTEGRATION = os.environ.get("INTEGRATION_TESTS") is not None
if RUN_INTEGRATION:
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
Expand All @@ -25,7 +24,6 @@ class PlaywrightTestCase(StaticLiveServerTestCase, TestCase):

@pytest.fixture(autouse=True)
def set_fixtures(self, page: Page):
self.can_execute: bool = CAN_EXECUTE
self.page: Page = page

def url(self, path: str) -> str:
Expand Down
258 changes: 121 additions & 137 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from playwright.sync_api import expect
from playwright.sync_api import Page, expect

from .common import PlaywrightTestCase


class TestContinuousIntegration(PlaywrightTestCase):
def _test_continuous(self, option: str):
page = self.page
page.goto(self.url("/"))
def _create_new_analysis(self) -> Page:
self.page.goto(self.url("/"))
with self.page.expect_navigation():
self.page.get_by_role("button", name="Create a new BMDS analysis").click()
return self.page

with page.expect_navigation():
page.get_by_role("button", name="Create a new BMDS analysis").click()
def _test_continuous(self, option: str):
page = self._create_new_analysis()

# set main input
page.locator("#analysis_name").fill("abc")
Expand All @@ -29,47 +31,45 @@ def _test_continuous(self, option: str):
page.locator('a:has-text("Settings")').click()
page.locator("text=Save Analysis").click()

if self.can_execute:
# execute and wait until complete
page.locator("text=Run Analysis").click()
expect(page.locator("#controlPanel")).to_contain_text("Executing, please wait...")
# execute and wait until complete
page.locator("text=Run Analysis").click()
expect(page.locator("#controlPanel")).to_contain_text("Executing, please wait...")

# view output summary tables
page.locator('a:has-text("Output")').click()
expect(page.locator("#frequentist-model-result tbody tr")).to_have_count(2)
# view output summary tables
page.locator('a:has-text("Output")').click()
expect(page.locator("#frequentist-model-result tbody tr")).to_have_count(2)

# display frequentist modal
page.locator("#freq-result-0").click()
expect(page.locator("#info-table tbody tr")).to_have_count(3)
page.locator("#close-modal").click()
# display frequentist modal
page.locator("#freq-result-0").click()
expect(page.locator("#info-table tbody tr")).to_have_count(3)
page.locator("#close-modal").click()

page.locator("#selection_model").select_option("0")
page.locator("#selection_notes").fill("selected!")
page.locator("#selection_submit").click()
expect(page.locator(".toast")).to_contain_text("Model selection updated.")
page.locator("#selection_model").select_option("0")
page.locator("#selection_notes").fill("selected!")
page.locator("#selection_submit").click()
expect(page.locator(".toast")).to_contain_text("Model selection updated.")

page.locator('a:has-text("Logic")').click()
expect(page.locator("#decision-logic tbody tr")).to_have_count(4)
expect(page.locator("#rule-table tbody tr")).to_have_count(20)

# Read-only
if self.can_execute:
page.get_by_role("button", name="Share").click()
with page.expect_popup() as page2_info:
page.get_by_role("link", name="Open").first.click()
page2 = page2_info.value
page.get_by_role("button", name="Share").click()
with page.expect_popup() as page2_info:
page.get_by_role("link", name="Open").first.click()
page2 = page2_info.value

page2.get_by_role("link", name="Settings").click()
expect(page2.get_by_role("cell", name="abc")).to_be_visible()
page2.get_by_role("link", name="Settings").click()
expect(page2.get_by_role("cell", name="abc")).to_be_visible()

page2.get_by_role("link", name="Data").click()
expect(page2.get_by_text("Dataset Name: Dataset #1")).to_be_visible()
page2.get_by_role("link", name="Data").click()
expect(page2.get_by_text("Dataset Name: Dataset #1")).to_be_visible()

page2.get_by_role("link", name="Output").click()
expect(page2.get_by_text("Dataset Name: Dataset #1")).to_be_visible()
page2.get_by_role("link", name="Output").click()
expect(page2.get_by_text("Dataset Name: Dataset #1")).to_be_visible()

page2.get_by_role("link", name="Logic").click()
expect(page2.get_by_role("cell", name="Decision Logic")).to_be_visible()
page2.get_by_role("link", name="Logic").click()
expect(page2.get_by_role("cell", name="Decision Logic")).to_be_visible()

def test_continuous_summary(self):
self._test_continuous(option="CS")
Expand All @@ -78,11 +78,7 @@ def test_continuous_individual(self):
self._test_continuous(option="I")

def test_dichotomous(self):
page = self.page
page.goto(self.url("/"))

with page.expect_navigation():
page.get_by_role("button", name="Create a new BMDS analysis").click()
page = self._create_new_analysis()

# set main input
page.locator("#analysis_name").fill("abc")
Expand All @@ -104,65 +100,59 @@ def test_dichotomous(self):
page.locator('a:has-text("Settings")').click()
page.locator("text=Save Analysis").click()

if self.can_execute:
# execute and wait until complete
page.locator("text=Run Analysis").click()
expect(page.locator("#controlPanel")).to_contain_text("Executing, please wait...")
# execute and wait until complete
page.locator("text=Run Analysis").click()
expect(page.locator("#controlPanel")).to_contain_text("Executing, please wait...")

# view output summary tables
page.locator('a:has-text("Output")').click()
expect(page.locator("#frequentist-model-result tbody tr")).to_have_count(2)
expect(page.locator("#bayesian-model-result tbody tr")).to_have_count(2)
# view output summary tables
page.locator('a:has-text("Output")').click()
expect(page.locator("#frequentist-model-result tbody tr")).to_have_count(2)
expect(page.locator("#bayesian-model-result tbody tr")).to_have_count(2)

# display frequentist modal
page.locator("#freq-result-0").click()
expect(page.locator("#info-table tbody tr")).to_have_count(3)
page.locator("#close-modal").click()
# display frequentist modal
page.locator("#freq-result-0").click()
expect(page.locator("#info-table tbody tr")).to_have_count(3)
page.locator("#close-modal").click()

# display bayesian modal
page.locator("#bayesian-result-0").click()
expect(page.locator("#info-table tbody tr")).to_have_count(3)
page.locator("#close-modal").click()
# display bayesian modal
page.locator("#bayesian-result-0").click()
expect(page.locator("#info-table tbody tr")).to_have_count(3)
page.locator("#close-modal").click()

# display bayesian model average modal
page.locator("td", has_text="Model Average").click()
expect(page.locator("#ma-result-summary tbody tr")).to_have_count(3)
page.locator("#close-modal").click()
# display bayesian model average modal
page.locator("td", has_text="Model Average").click()
expect(page.locator("#ma-result-summary tbody tr")).to_have_count(3)
page.locator("#close-modal").click()

page.locator("#selection_model").select_option("0")
page.locator("#selection_notes").fill("selected!")
page.locator("#selection_submit").click()
expect(page.locator(".toast")).to_contain_text("Model selection updated.")
page.locator("#selection_model").select_option("0")
page.locator("#selection_notes").fill("selected!")
page.locator("#selection_submit").click()
expect(page.locator(".toast")).to_contain_text("Model selection updated.")

page.locator('a:has-text("Logic")').click()
expect(page.locator("#decision-logic tbody tr")).to_have_count(4)
expect(page.locator("#rule-table tbody tr")).to_have_count(18)

# Read-only
if self.can_execute:
page.get_by_role("button", name="Share").click()
with page.expect_popup() as page2_info:
page.get_by_role("link", name="Open").first.click()
page2 = page2_info.value
page.get_by_role("button", name="Share").click()
with page.expect_popup() as page2_info:
page.get_by_role("link", name="Open").first.click()
page2 = page2_info.value

page2.get_by_role("link", name="Settings").click()
expect(page2.get_by_role("cell", name="abc")).to_be_visible()
page2.get_by_role("link", name="Settings").click()
expect(page2.get_by_role("cell", name="abc")).to_be_visible()

page2.get_by_role("link", name="Data").click()
expect(page2.get_by_text("Dataset Name: Dataset #1")).to_be_visible()
page2.get_by_role("link", name="Data").click()
expect(page2.get_by_text("Dataset Name: Dataset #1")).to_be_visible()

page2.get_by_role("link", name="Output").click()
expect(page2.get_by_text("Dataset Name: Dataset #1")).to_be_visible()
page2.get_by_role("link", name="Output").click()
expect(page2.get_by_text("Dataset Name: Dataset #1")).to_be_visible()

page2.get_by_role("link", name="Logic").click()
expect(page2.get_by_role("cell", name="Decision Logic")).to_be_visible()
page2.get_by_role("link", name="Logic").click()
expect(page2.get_by_role("cell", name="Decision Logic")).to_be_visible()

def test_nested_dichotomous(self):
page = self.page
page.goto(self.url("/"))

with page.expect_navigation():
page.get_by_role("button", name="Create a new BMDS analysis").click()
page = self._create_new_analysis()

# set main input
page.locator("#analysis_name").fill("abc")
Expand All @@ -180,45 +170,40 @@ def test_nested_dichotomous(self):
page.locator('a:has-text("Settings")').click()
page.get_by_role("button", name="Save Analysis").click()

if self.can_execute:
# execute and wait until complete
page.locator("text=Run Analysis").click()
expect(page.locator("#controlPanel")).to_contain_text("Executing, please wait...")
# execute and wait until complete
page.locator("text=Run Analysis").click()
expect(page.locator("#controlPanel")).to_contain_text("Executing, please wait...")

# view output summary tables
page.locator('a:has-text("Output")').click()
# num rows in results table
expect(page.locator("#frequentist-model-result tbody tr")).to_have_count(5)
# view output summary tables
page.locator('a:has-text("Output")').click()
# num rows in results table
expect(page.locator("#frequentist-model-result tbody tr")).to_have_count(5)

# check one result
page.get_by_role("link", name="Nested Logistic (lsc+ilc-)").click()
expect(page.get_by_role("dialog")).to_contain_text("Nested Logistic (lsc+ilc-)")
page.locator("#close-modal").click()
# check one result
page.get_by_role("link", name="Nested Logistic (lsc+ilc-)").click()
expect(page.get_by_role("dialog")).to_contain_text("Nested Logistic (lsc+ilc-)")
page.locator("#close-modal").click()

# Read-only
page.get_by_role("button", name="Share").click()
with page.expect_popup() as page2_info:
page.get_by_role("link", name="Open").first.click()
page2 = page2_info.value
# Read-only
page.get_by_role("button", name="Share").click()
with page.expect_popup() as page2_info:
page.get_by_role("link", name="Open").first.click()
page2 = page2_info.value

page2.get_by_role("link", name="Settings").click()
expect(page2.get_by_role("cell", name="abc")).to_be_visible()
page2.get_by_role("link", name="Settings").click()
expect(page2.get_by_role("cell", name="abc")).to_be_visible()

page2.get_by_role("link", name="Data").click()
expect(page2.get_by_text("Dataset Name: Dataset #1")).to_be_visible()
page2.get_by_role("link", name="Data").click()
expect(page2.get_by_text("Dataset Name: Dataset #1")).to_be_visible()

page2.get_by_role("link", name="Output").click()
expect(page2.get_by_text("Dataset Name: Dataset #1")).to_be_visible()
page2.get_by_role("link", name="Output").click()
expect(page2.get_by_text("Dataset Name: Dataset #1")).to_be_visible()

page2.get_by_role("link", name="Logic").click()
expect(page2.get_by_role("cell", name="Decision Logic")).to_be_visible()
page2.get_by_role("link", name="Logic").click()
expect(page2.get_by_role("cell", name="Decision Logic")).to_be_visible()

def test_multi_tumor(self):
page = self.page
page.goto(self.url("/"))

with page.expect_navigation():
page.get_by_role("button", name="Create a new BMDS analysis").click()
page = self._create_new_analysis()

# set main input
page.locator("#analysis_name").fill("abc")
Expand All @@ -243,36 +228,35 @@ def test_multi_tumor(self):
page.locator('a:has-text("Settings")').click()
page.locator("text=Save Analysis").click()

if self.can_execute:
# execute and wait until complete
page.locator("text=Run Analysis").click()
expect(page.locator("#controlPanel")).to_contain_text("Executing, please wait...")
# execute and wait until complete
page.locator("text=Run Analysis").click()
expect(page.locator("#controlPanel")).to_contain_text("Executing, please wait...")

# view output summary tables
page.locator('a:has-text("Output")').click()
# view output summary tables
page.locator('a:has-text("Output")').click()

# check one result (multitumor)
page.get_by_role("link", name="Multitumor").click()
expect(page.get_by_role("dialog")).to_contain_text("MS Combo")
page.locator("#close-modal").click()
# check one result (multitumor)
page.get_by_role("link", name="Multitumor").click()
expect(page.get_by_role("dialog")).to_contain_text("MS Combo")
page.locator("#close-modal").click()

# check one result (individual)
expect(page.get_by_role("link", name="Multistage 2*")).to_have_count(3)
page.get_by_role("link", name="Multistage 2*").nth(1).click()
expect(page.get_by_role("dialog")).to_contain_text("Multistage 2")
page.locator("#close-modal").click()
# check one result (individual)
expect(page.get_by_role("link", name="Multistage 2*")).to_have_count(3)
page.get_by_role("link", name="Multistage 2*").nth(1).click()
expect(page.get_by_role("dialog")).to_contain_text("Multistage 2")
page.locator("#close-modal").click()

# Read-only
page.get_by_role("button", name="Share").click()
with page.expect_popup() as page2_info:
page.get_by_role("link", name="Open").first.click()
page2 = page2_info.value
# Read-only
page.get_by_role("button", name="Share").click()
with page.expect_popup() as page2_info:
page.get_by_role("link", name="Open").first.click()
page2 = page2_info.value

page2.get_by_role("link", name="Settings").click()
expect(page2.get_by_role("cell", name="abc")).to_be_visible()
page2.get_by_role("link", name="Settings").click()
expect(page2.get_by_role("cell", name="abc")).to_be_visible()

page2.get_by_role("link", name="Data").click()
expect(page2.get_by_text("Select existing")).to_be_visible()
page2.get_by_role("link", name="Data").click()
expect(page2.get_by_text("Select existing")).to_be_visible()

page2.get_by_role("link", name="Output").click()
expect(page2.get_by_text("Model Results")).to_be_visible()
page2.get_by_role("link", name="Output").click()
expect(page2.get_by_text("Model Results")).to_be_visible()

0 comments on commit 1e777ad

Please sign in to comment.