-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Add row needs to initialize new editor instances for inline admi…
…ns (#37)
- Loading branch information
Showing
8 changed files
with
82 additions
and
51 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
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
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
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,28 @@ | ||
import pytest | ||
from django.urls import reverse | ||
|
||
from tests.fixtures import DJANGO_CMS4 | ||
from tests.integration.utils import login | ||
|
||
|
||
@pytest.fixture | ||
def pizza(): | ||
from tests.test_app.models import Pizza | ||
|
||
return Pizza.objects.create(description="<p>Test pizza</p>") | ||
|
||
|
||
@pytest.mark.django_db | ||
@pytest.mark.skipif(not DJANGO_CMS4, reason="Integration tests only work on Django CMS 4") | ||
def test_inline_admin_add_row(live_server, page, pizza, superuser): | ||
"""Test that editor loads and initializes properly after user clicks add row button for inline admin""" | ||
login(live_server, page, superuser) | ||
|
||
endpoint = reverse("admin:test_app_pizza_change", args=(pizza.pk,)) | ||
page.goto(f"{live_server.url}{endpoint}") | ||
|
||
assert page.locator(".cms-editor-inline-wrapper.textarea.fixed").count() == 3 | ||
|
||
page.locator(".add-row a").click() | ||
|
||
assert page.locator(".cms-editor-inline-wrapper.textarea.fixed").count() == 4 |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from playwright.sync_api import expect | ||
|
||
|
||
def login(live_server, page, superuser): | ||
page.goto(f"{live_server.url}/en/admin/") | ||
if page.locator("input[name='username']").is_visible(): | ||
page.fill("input[name='username']", superuser.username) | ||
page.fill("input[name='password']", "admin") | ||
page.click("input[type='submit']") | ||
# Ensure success | ||
expect(page.locator("h1", has_text="Site administration")).to_be_visible() | ||
|
||
|
||
def get_pagecontent(cms_page): | ||
return cms_page.pagecontent_set(manager="admin_manager").current_content(language="en").first() |