fixed applet seeding in 0005 migration; many FTs & ITs now require authentication before they pass; New List & My Lists converted to dash applets; home.html offloaded and _applets.html onboarded w. these applets
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Disco DeDisco
2026-03-06 21:34:43 -05:00
parent 17ee6c1f08
commit 4c502e40f8
9 changed files with 59 additions and 12 deletions

View File

@@ -4,6 +4,8 @@ from django.db import migrations
def set_grid_defaults(apps, schema_editor):
Applet = apps.get_model("dashboard", "Applet")
Applet.objects.filter(slug__in=["username", "palette"]).update(grid_cols=6, grid_rows=3)
Applet.objects.get_or_create(slug="new-list", defaults={"name": "New List", "grid_cols": 9, "grid_rows": 3})
Applet.objects.get_or_create(slug="my-lists", defaults={"name": "My Lists", "grid_cols": 3, "grid_rows": 3})
class Migration(migrations.Migration):
dependencies = [

View File

@@ -14,6 +14,11 @@ from apps.lyric.models import User
class HomePageTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="disco@test.io")
self.client.force_login(self.user)
Applet.objects.get_or_create(slug="new-list", defaults={"name": "New List"})
def test_uses_home_template(self):
response = self.client.get('/')
self.assertTemplateUsed(response, 'apps/dashboard/home.html')
@@ -28,6 +33,10 @@ class HomePageTest(TestCase):
self.assertIn("text", [input.get("name") for input in inputs])
class NewListTest(TestCase):
def setUp(self):
user = User.objects.create(email="disco@test.io")
self.client.force_login(user)
def test_can_save_a_POST_request(self):
self.client.post("/dashboard/new_list", data={"text": "A new list item"})
self.assertEqual(Item.objects.count(), 1)

View File

@@ -8,6 +8,7 @@ from apps.dashboard.models import Applet, Item, List, UserApplet
from apps.lyric.models import User
APPLET_ORDER = ["new-list", "my-lists", "username", "palette"]
UNLOCKED_PALETTES = frozenset(["palette-default"])
PALETTES = [
{"name": "palette-default", "label": "Earthman", "locked": False},
@@ -18,9 +19,11 @@ PALETTES = [
def _applet_context(user):
ua_map = {ua.applet_id: ua.visible for ua in user.user_applets.all()}
applets = {a.slug: a for a in Applet.objects.all()}
return [
{"applet": applet, "visible": ua_map.get(applet.pk, applet.default_visible)}
for applet in Applet.objects.all()
{"applet": applets[slug], "visible": ua_map.get(applets[slug].pk, applets[slug].default_visible)}
for slug in APPLET_ORDER
if slug in applets
]
def home_page(request):
@@ -39,7 +42,10 @@ def new_list(request):
form.save(for_list=nulist)
return redirect(nulist)
else:
return render(request, "apps/dashboard/home.html", {"form": form})
context = {"form": form, "palettes": PALETTES, "page_class": "page-dashboard"}
if request.user.is_authenticated:
context["applets"] = _applet_context(request.user)
return render(request, "apps/dashboard/home.html", context)
def view_list(request, list_id):
our_list = List.objects.get(id=list_id)
@@ -109,5 +115,6 @@ def toggle_applets(request):
return render(request, "apps/dashboard/_partials/_applets.html", {
"applets": _applet_context(request.user),
"palettes": PALETTES,
"form": ItemForm(),
})
return redirect("home")

View File

@@ -12,6 +12,7 @@ from selenium.webdriver.common.keys import Keys
from .container_commands import create_session_on_server, reset_database
from .management.commands.create_session import create_pre_authenticated_session
from apps.dashboard.models import Applet
@@ -44,6 +45,7 @@ class FunctionalTest(StaticLiveServerTestCase):
if self.test_server:
self.live_server_url = 'http://' + self.test_server
reset_database(self.test_server)
Applet.objects.get_or_create(slug="new-list", defaults={"name": "New List"})
def tearDown(self):
if self._test_has_failed():

View File

@@ -7,6 +7,7 @@ from .list_page import ListPage
class LayoutAndStylingTest(FunctionalTest):
def test_layout_and_styling(self):
self.create_pre_authenticated_session("disco@test.io")
self.browser.get(self.live_server_url)
list_page = ListPage(self)

View File

@@ -12,6 +12,7 @@ class ItemValidationTest(FunctionalTest):
# Test methods
def test_cannot_add_empty_list_items(self):
self.create_pre_authenticated_session("disco@test.io")
self.browser.get(self.live_server_url)
list_page = ListPage(self)
list_page.get_item_input_box().send_keys(Keys.ENTER)
@@ -46,6 +47,7 @@ class ItemValidationTest(FunctionalTest):
list_page.wait_for_row_in_list_table("Make tea", 2)
def test_cannot_add_duplicate_items(self):
self.create_pre_authenticated_session("disco@test.io")
self.browser.get(self.live_server_url)
list_page = ListPage(self)
list_page.add_list_item("Witness divinity")
@@ -61,6 +63,7 @@ class ItemValidationTest(FunctionalTest):
)
def test_error_messages_are_cleared_on_input(self):
self.create_pre_authenticated_session("disco@test.io")
self.browser.get(self.live_server_url)
list_page = ListPage(self)
list_page.add_list_item("Gobbledygook")

View File

@@ -8,6 +8,7 @@ from .list_page import ListPage
class NewVisitorTest(FunctionalTest):
# Test methods
def test_can_start_a_todo_list(self):
self.create_pre_authenticated_session("alice@test.io")
self.browser.get(self.live_server_url)
list_page = ListPage(self)
@@ -29,6 +30,7 @@ class NewVisitorTest(FunctionalTest):
list_page.wait_for_row_in_list_table("Buy peacock feathers", 1)
def test_multiple_users_can_start_lists_at_different_urls(self):
self.create_pre_authenticated_session("alice@test.io")
self.browser.get(self.live_server_url)
list_page = ListPage(self)
list_page.add_list_item("Buy peacock feathers")
@@ -41,6 +43,7 @@ class NewVisitorTest(FunctionalTest):
self.browser.delete_all_cookies()
self.create_pre_authenticated_session("disco@test.io")
self.browser.get(self.live_server_url)
list_page = ListPage(self)
page_text = self.browser.find_element(By.TAG_NAME, 'body').text

View File

@@ -24,7 +24,32 @@
{% for entry in applets %}
{% if entry.visible %}
{% if entry.applet.slug == "username" %}
{% if entry.applet.slug == "new-list" %}
<section
id="id_applet_new_list"
style="--applet-cols: {{ entry.applet.grid_cols }}; --applet-rows: {{ entry.applet.grid_rows }};"
>
<h2>Start a new to-do list</h2>
{% url "new_list" as form_action %}
{% include "apps/dashboard/_partials/_form.html" with form=form form_action=form_action %}
</section>
{% elif entry.applet.slug == "my-lists" %}
<section
id="id_applet_my_lists"
style="--applet-cols: {{ entry.applet.grid_cols }}; --applet-rows: {{ entry.applet.grid_rows }};"
>
{% for list in user.lists.all %}
<li>
<a href="{{ list.get_absolute_url }}">{{ list.name }}</a>
</li>
{% endfor %}
{% for list in user.shared_lists.all %}
<li>
<a href="{{ list.get_absolute_url }}">{{ list.name }}</a>
</li>
{% endfor %}
</section>
{% elif entry.applet.slug == "username" %}
<section
id="id_applet_username"
style="--applet-cols: {{ entry.applet.grid_cols }}; --applet-rows: {{ entry.applet.grid_rows }};"

View File

@@ -1,13 +1,8 @@
{% extends "core/base.html" %}
{% load lyric_extras %}
{% block title_text %}Start a new to-do list{% endblock title_text %}
{% block header_text %}Start a new to-do list{% endblock header_text %}
{% block extra_header %}
{% url "new_list" as form_action %}
{% include "apps/dashboard/_partials/_form.html" with form=form form_action=form_action %}
{% endblock extra_header %}
{% block title_text %}Dashboard{% endblock title_text %}
{% block header_text %}Dashboard{% endblock header_text %}
{% block scripts %}
{% include "apps/dashboard/_partials/_scripts.html" %}