Skip to content

Commit

Permalink
Build assets before integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Nov 27, 2024
1 parent d029e1b commit d9a5c4e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 45 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
python -m pip install --upgrade pip
pip install -r tests/requirements/${{ matrix.requirements-file }}
python setup.py install
npm install
npx webpack
playwright install --with-deps
- name: Run coverage
Expand Down
93 changes: 50 additions & 43 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,56 @@

from tests.fixtures import DJANGO_CMS4

if DJANGO_CMS4:

@pytest.fixture(scope="session")
def live_server():
server = LiveServer("127.0.0.1:9090")
yield server
server.stop()

@pytest.fixture(scope="session")
def browser_context():
with sync_playwright() as p:
browser = p.chromium.launch()
context = browser.new_context()
yield context
context.close()
browser.close()

@pytest.fixture(scope="session")
def page(browser_context):
page = browser_context.new_page()
yield page
page.close()

@pytest.fixture
def user(db):
from django.contrib.auth import get_user_model

User = get_user_model()
return User.objects.create_user(username="admin", password="admin", is_staff=True, is_superuser=True)

@pytest.fixture
def cms_page(db, user):
from cms.api import create_page

return create_page("Test Page", "page.html", "en", created_by=user)

@pytest.fixture
def text_plugin(db, cms_page):
from cms.api import add_plugin

page_content = cms_page.pagecontent_set(manager="admin_manager").current_content(language="en").first()
placeholder = page_content.get_placeholders().first()
return add_plugin(placeholder, "TextPlugin", "en", body="<p>Test content</p>")

@pytest.fixture(scope="session")
def live_server():
server = LiveServer("127.0.0.1:9090")
yield server
server.stop()


@pytest.fixture(scope="session")
def browser_context():
with sync_playwright() as p:
browser = p.chromium.launch()
context = browser.new_context()
yield context
context.close()
browser.close()


@pytest.fixture(scope="session")
def page(browser_context):
page = browser_context.new_page()
yield page
page.close()


@pytest.fixture
def user(db):
from django.contrib.auth import get_user_model

User = get_user_model()
return User.objects.create_user(username="admin", password="admin", is_staff=True, is_superuser=True)


@pytest.fixture
def cms_page(db, user):
from cms.api import create_page

return create_page("Test Page", "page.html", "en", created_by=user)


@pytest.fixture
def text_plugin(db, cms_page):
if not DJANGO_CMS4:
return None

from cms.api import add_plugin

page_content = cms_page.pagecontent_set(manager="admin_manager").current_content(language="en").first()
placeholder = page_content.get_placeholders().first()
return add_plugin(placeholder, "TextPlugin", "en", body="<p>Test content</p>")


def pytest_configure():
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/test_text_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ def test_editor_loads(live_server, page, text_plugin):
login(page, live_server)

page.goto(f"{live_server.url}{admin_reverse('cms_placeholder_edit_plugin', args=(text_plugin.pk,))}")
editor = page.locator(".ProseMirror.tiptap")

editor = page.locator(".cms-editor-inline-wrapper.fixed")
expect(editor).to_be_visible() # Editor

tiptap = page.locator(".ProseMirror.tiptap")
expect(tiptap).to_be_visible() # Editor

expect(page.locator('div[role="menubar"]')).to_be_visible() # its menu bar
expect(page.locator('button[title="Bold"]')).to_be_visible() # a button in the menu bar

assert editor.inner_text() == "Test content"
assert tiptap.inner_text() == "Test content"


@pytest.mark.django_db
Expand Down

0 comments on commit d9a5c4e

Please sign in to comment.