High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.
JavaScript campaigncampaign-managementemail-marketingemail-subscriptionlistmonkmailing-listnewsletternewsletter-managementnewsletter-softwareself-hostedsms-gatewaysmtptransactional-emails
SSR: Port 'lists' e2e tests from Cypress to Playwright for the new admin UI.
Kailash Nadh76b9345b0265
diff --git a/static/admin/partials/filter-badge.html b/static/admin/partials/filter-badge.htmlindex 190805c1..8e019739 100644--- a/static/admin/partials/filter-badge.html+++ b/static/admin/partials/filter-badge.html@@ -1,5 +1,5 @@{{ define "filter-badge" -}}<span class="filter-tag">- {{ Badge .Label (default "" .Class) (default "" .Variant) }} <a href="{{ .URL }}" title="{{ L.T "globals.buttons.remove" }}">{{ Icon "x" }}</a>+ {{ Badge .Label (default "" .Class) (default "" .Variant) }} <a href="{{ .URL }}" title="{{ L.T "globals.buttons.remove" }}" data-testid="btn-remove-filter">{{ Icon "x" }}</a></span>{{- end }}diff --git a/static/admin/partials/list-form.html b/static/admin/partials/list-form.htmlindex b6fbdcab..b72962c1 100644--- a/static/admin/partials/list-form.html+++ b/static/admin/partials/list-form.html@@ -55,7 +55,7 @@<footer class="dialog-foot hstack gap-3 justify-end"><button type="button" class="outline" @click="onClose">{{ $root.L.T "globals.buttons.close" }}</button>{{- if $canSave }}- <button type="submit" data-variant="primary" data-cy="btn-save" data-spinner="small" :disabled="isLoading('lists.save')" :aria-busy="isLoading('lists.save')">{{ $root.L.T "globals.buttons.save" }}</button>+ <button type="submit" data-variant="primary" data-testid="btn-save" data-spinner="small" :disabled="isLoading('lists.save')" :aria-busy="isLoading('lists.save')">{{ $root.L.T "globals.buttons.save" }}</button>{{- end }}</footer>{{- else }}@@ -71,7 +71,7 @@<div class="hstack gap-3 justify-end"><a href="{{ URI "/admin/lists" }}" class="button outline">{{ $root.L.T "globals.buttons.back" }}</a>{{- if $canSave }}- <button type="submit" data-variant="primary" data-cy="btn-save" data-spinner="small" :disabled="isLoading('lists.save')" :aria-busy="isLoading('lists.save')">{{ $root.L.T "globals.buttons.save" }}</button>+ <button type="submit" data-variant="primary" data-testid="btn-save" data-spinner="small" :disabled="isLoading('lists.save')" :aria-busy="isLoading('lists.save')">{{ $root.L.T "globals.buttons.save" }}</button>{{- end }}</div></footer>diff --git a/static/admin/views/lists.html b/static/admin/views/lists.htmlindex dcc5c622..ee78366d 100644--- a/static/admin/views/lists.html+++ b/static/admin/views/lists.html@@ -29,12 +29,12 @@<form method="get" action="{{ URI "/admin/lists" }}" class="search-form">{{- $d.Page.FormFields "query" -}}<fieldset class="group">- <input name="query" aria-label="Search" data-cy="query" placeholder="Search" value="{{ $d.Page.Query }}" autofocus />- <button type="submit" class="outline" data-cy="btn-query" aria-label="Search">{{ Icon "search" }}</button>+ <input name="query" aria-label="Search" data-testid="query" placeholder="Search" value="{{ $d.Page.Query }}" autofocus />+ <button type="submit" class="outline" data-testid="btn-query" aria-label="Search">{{ Icon "search" }}</button></fieldset></form>{{- if $d.Can "lists:manage_all" }}- <button type="button" data-variant="primary" class="btn-new" data-cy="btn-new" @click="onOpenNew">+ <button type="button" data-variant="primary" class="btn-new" data-testid="btn-new" @click="onOpenNew">{{ Icon "plus" }} {{ .L.T "globals.buttons.new" }}</button>{{- end }}@@ -45,16 +45,16 @@<div class="table-wrapper" x-data="table({ query: {{ ToJSON $d.Page.Query }}, filters: {{ ToJSON $d.Page.QueryParams }}, total: {{ $d.Page.Total }} })" :aria-busy="isLoading('lists')" @change="onChange($event)"><template x-if="numSelected > 0"><ot-dropdown class="bulk-actions">- <button popovertarget="bulk-actions" type="button" class="small" data-cy="btn-bulk-actions">+ <button popovertarget="bulk-actions" type="button" class="small" data-testid="btn-bulk-actions"><span x-text="numSelectedLabel"></span> {{ Icon "more-vertical" }}</button><menu popover id="bulk-actions">{{- if gt $d.Page.Total $d.Page.PerPage }}- <button type="button" role="menuitem" class="ghost" data-cy="select-all-lists" x-cloak x-show="!allSelected" @click.prevent="onSelectAllQuery()">+ <button type="button" role="menuitem" class="ghost" data-testid="select-all-lists" x-cloak x-show="!allSelected" @click.prevent="onSelectAllQuery()">{{ Icon "list" }} <span x-text="selectAllLabel"></span></button>{{- end }}- <button type="button" role="menuitem" class="ghost" data-variant="danger" data-cy="btn-delete-lists" :disabled="isLoading('lists')" @click.prevent="onDeleteSelected(numSelected, selectedQueryParams().toString())">+ <button type="button" role="menuitem" class="ghost" data-variant="danger" data-testid="btn-delete-lists" :disabled="isLoading('lists')" @click.prevent="onDeleteSelected(numSelected, selectedQueryParams().toString())">{{ Icon "trash-2" }} {{ .L.T "globals.buttons.delete" }} <span x-text="numSelected"></span></button></menu>@@ -65,17 +65,17 @@<thead><tr><th width="5%"><input type="checkbox" aria-label="{{ .L.T "globals.buttons.toggleSelect" }}"></th>- <th width="20%" class="cy-name">{{ $d.Page.SortLink (URI "/admin/lists") "name" (.L.T "globals.fields.name") }}</th>- <th class="cy-type">{{ $d.Page.SortLink (URI "/admin/lists") "type" (.L.T "globals.fields.type") }}</th>- <th class="subscribers cy-subscribers">{{ $d.Page.SortLink (URI "/admin/lists") "subscriber_count" (.L.T "globals.terms.subscribers") }}</th>+ <th width="20%">{{ $d.Page.SortLink (URI "/admin/lists") "name" (.L.T "globals.fields.name") }}</th>+ <th>{{ $d.Page.SortLink (URI "/admin/lists") "type" (.L.T "globals.fields.type") }}</th>+ <th class="subscribers">{{ $d.Page.SortLink (URI "/admin/lists") "subscriber_count" (.L.T "globals.terms.subscribers") }}</th><th></th>- <th class="cy-created_at">{{ $d.Page.SortLink (URI "/admin/lists") "created_at" (.L.T "globals.fields.createdAt") }}</th>+ <th>{{ $d.Page.SortLink (URI "/admin/lists") "created_at" (.L.T "globals.fields.createdAt") }}</th><th class="align-right"></th></tr></thead><tbody>{{- range $d.Lists }}- <tr class="list-main-row">+ <tr class="list-main-row" data-testid="list-row" data-id="{{ .ID }}"><td><input name="id" type="checkbox" value="{{ .ID }}"></td><td><a href="{{ URI "/admin/lists" }}/{{ .ID }}">{{ .Name }}</a>@@ -136,20 +136,20 @@</button><menu popover id="list-actions-{{ .ID }}">{{- if $d.CanManageList .ID }}- <a href="{{ URI "/admin/lists" }}/{{ .ID }}" role="menuitem" class="button ghost" data-cy="btn-edit">{{ Icon "edit-2" }} {{ $.L.T "globals.buttons.edit" }}</a>+ <a href="{{ URI "/admin/lists" }}/{{ .ID }}" role="menuitem" class="button ghost" data-testid="btn-edit">{{ Icon "edit-2" }} {{ $.L.T "globals.buttons.edit" }}</a>{{- end }}{{- if $d.Can "subscribers:import" }}- <a href="{{ URI "/admin/import" }}?list_id={{ .ID }}" role="menuitem" class="button ghost" data-cy="btn-import">{{ Icon "upload" }} {{ $.L.T "globals.terms.import" }}</a>+ <a href="{{ URI "/admin/import" }}?list_id={{ .ID }}" role="menuitem" class="button ghost" data-testid="btn-import">{{ Icon "upload" }} {{ $.L.T "globals.terms.import" }}</a>{{- end }}{{- if $d.CanManageList .ID }}- <button type="button" role="menuitem" class="ghost" data-variant="danger" data-cy="btn-delete" :disabled="isLoading('lists')" @click.prevent="onDeleteList({{ .ID }}, {{ ToJSON .Name }})">{{ Icon "trash-2" }} {{ $.L.T "globals.buttons.delete" }}</button>+ <button type="button" role="menuitem" class="ghost" data-variant="danger" data-testid="btn-delete" :disabled="isLoading('lists')" @click.prevent="onDeleteList({{ .ID }}, {{ ToJSON .Name }})">{{ Icon "trash-2" }} {{ $.L.T "globals.buttons.delete" }}</button>{{- end }}<hr />{{- if $d.Can "campaigns:manage" "campaigns:manage_all" }}- <a href="{{ URI "/admin/campaigns/new" }}?list_id={{ .ID }}" role="menuitem" class="button ghost" data-cy="btn-campaign">{{ Icon "send" }} {{ $.L.T "campaigns.newCampaign" }}</a>+ <a href="{{ URI "/admin/campaigns/new" }}?list_id={{ .ID }}" role="menuitem" class="button ghost" data-testid="btn-campaign">{{ Icon "send" }} {{ $.L.T "campaigns.newCampaign" }}</a>{{- end }}{{- if and (eq .Optin "double") ($d.Can "campaigns:manage" "campaigns:manage_all") }}- <button type="button" role="menuitem" class="ghost send-optin" data-cy="btn-send-optin-campaign" :disabled="isLoading('lists')" @click.prevent="onCreateOptinCampaign({{ .ID }}, {{ ToJSON .Name }})">+ <button type="button" role="menuitem" class="ghost send-optin" data-testid="btn-send-optin-campaign" :disabled="isLoading('lists')" @click.prevent="onCreateOptinCampaign({{ .ID }}, {{ ToJSON .Name }})">{{ Icon "send" }} {{ $.L.T "lists.sendOptinCampaign" }}</button>{{- end }}diff --git a/tests/.gitignore b/tests/.gitignorenew file mode 100644index 00000000..7d0ff6c6--- /dev/null+++ b/tests/.gitignore@@ -0,0 +1,4 @@+node_modules/+.auth/+test-results/+playwright-report/diff --git a/tests/README.md b/tests/README.mdnew file mode 100644index 00000000..a141a74a--- /dev/null+++ b/tests/README.md@@ -0,0 +1,18 @@+# listmonk E2E tests++Playwright UI E2E tests. Requires a built `./listmonk` binary in the repo root with a test Postgres instance (use docker-compose.yml) set in config.toml. Every test run wipes and reinstalls the DB schema.++## Setup++```sh+cd tests+bun install+bun playwright install chromium+```++## Run++```sh+bun run test # runs tests in headless mode+bun run test:ui # Shows the Playwright UI+```diff --git a/tests/bun.lock b/tests/bun.locknew file mode 100644index 00000000..2001c212--- /dev/null+++ b/tests/bun.lock@@ -0,0 +1,21 @@+{+ "lockfileVersion": 1,+ "configVersion": 1,+ "workspaces": {+ "": {+ "name": "listmonk-tests",+ "devDependencies": {+ "@playwright/test": "^1.49.0",+ },+ },+ },+ "packages": {+ "@playwright/test": ["@playwright/[email protected]", "", { "dependencies": { "playwright": "1.62.1" }, "bin": { "playwright": "cli.js" } }, "sha512-DTcUc8qii+cpHvtOwggMtBRMjKZHXYWdw8syRYu2vtzuq4Wxphqq4NfCs5Zt44L6mA8rfDfj+PHnxFc/FeK6mQ=="],++ "fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="],++ "playwright": ["[email protected]", "", { "dependencies": { "playwright-core": "1.62.1" }, "optionalDependencies": { "fsevents": "2.3.2" }, "bin": { "playwright": "cli.js" } }, "sha512-0M+L3LAD8/nm554LOla9Ayx0j0tmFZ0FBcoQ7F1VuVHpM/XpiC8RcDzBQB8W5+hA8L22THxELzeF+2WcUzvcLg=="],++ "playwright-core": ["[email protected]", "", { "bin": { "playwright-core": "cli.js" } }, "sha512-wPYSwEBJY9GHraISXqyqtx0na0LpO3XEX7jNDhntbex7tzUS7kLnZsOlFruFJB4Hi/rhDMjXGqHewDZ68nYZVw=="],+ }+}diff --git a/tests/global-setup.js b/tests/global-setup.jsnew file mode 100644index 00000000..780e5120--- /dev/null+++ b/tests/global-setup.js@@ -0,0 +1,20 @@+import { chromium } from '@playwright/test';+import { mkdirSync } from 'node:fs';++const BASE_URL = process.env.LISTMONK_URL || 'http://localhost:9000';++// Login and create a persistent session for tests.+export default async function globalSetup() {+ const browser = await chromium.launch();+ const page = await browser.newPage();++ await page.goto(`${BASE_URL}/admin/login?next=/admin/lists`);+ await page.getByLabel('Username').fill('admin');+ await page.getByLabel('Password').fill('listmonk');+ await page.getByRole('button', { name: 'Login' }).click();+ await page.waitForURL('**/admin/lists');++ mkdirSync(new URL('.auth', import.meta.url).pathname, { recursive: true });+ await page.context().storageState({ path: new URL('.auth/admin.json', import.meta.url).pathname });+ await browser.close();+}diff --git a/tests/helpers.js b/tests/helpers.jsnew file mode 100644index 00000000..66a2c933--- /dev/null+++ b/tests/helpers.js@@ -0,0 +1,9 @@+// Open a table row's "More" actions dropdown.+export async function openMenu(row) {+ await row.getByRole('button', { name: 'More' }).click();+}++// Click the "Ok" button on the confirmation dialog.+export async function confirm(page) {+ await page.locator('dialog[open] [data-confirm-ok]').click();+}diff --git a/tests/package.json b/tests/package.jsonnew file mode 100644index 00000000..9e15071c--- /dev/null+++ b/tests/package.json@@ -0,0 +1,13 @@+{+ "name": "listmonk-tests",+ "private": true,+ "type": "module",+ "description": "Playwright end-to-end tests for the listmonk SSR admin.",+ "scripts": {+ "test": "playwright test",+ "test:ui": "playwright test --ui"+ },+ "devDependencies": {+ "@playwright/test": "^1.49.0"+ }+}diff --git a/tests/playwright.config.js b/tests/playwright.config.jsnew file mode 100644index 00000000..72b8088e--- /dev/null+++ b/tests/playwright.config.js@@ -0,0 +1,33 @@+import { defineConfig, devices } from '@playwright/test';++// listmonk root address (see ../config.toml).+const BASE_URL = process.env.LISTMONK_URL || 'http://localhost:9000';++export default defineConfig({+ testDir: './specs',+ workers: 1,+ reporter: process.env.CI ? 'list' : [['list'], ['html', { open: 'never' }]],++ // Log in once and save the session before any tests run.+ globalSetup: './global-setup.js',++ // Create a fresh listmonk DB instance for every test run.+ webServer: {+ command: './listmonk --install --yes && ./listmonk --static-dir static',+ cwd: '..',+ url: `${BASE_URL}/health`,+ reuseExistingServer: false,+ env: { LISTMONK_ADMIN_USER: 'admin', LISTMONK_ADMIN_PASSWORD: 'listmonk' },+ },++ use: {+ baseURL: BASE_URL,+ storageState: './.auth/admin.json',+ trace: 'retain-on-failure',+ screenshot: 'only-on-failure',+ },++ projects: [+ { name: 'chromium', use: { ...devices['Desktop Chrome'], viewport: { width: 1400, height: 950 } } },+ ],+});diff --git a/tests/specs/lists.spec.js b/tests/specs/lists.spec.jsnew file mode 100644index 00000000..724407c6--- /dev/null+++ b/tests/specs/lists.spec.js@@ -0,0 +1,310 @@+import { test, expect } from '@playwright/test';+import { openMenu, confirm } from '../helpers.js';++const LISTS = '/admin/lists';++// Find a table row by name.+function listRow(page, name) {+ const rows = page.getByTestId('list-row');+ return name ? rows.filter({ hasText: name }) : rows;+}++// IDs currently rendered in the table.+function rowIDs(page) {+ return page.getByTestId('list-row').evaluateAll((els) => els.map((el) => Number(el.dataset.id)));+}++// Fill the list form.+async function fillListForm(scope, { name, type, optin, tag, description } = {}) {+ await scope.locator('input[name="name"]').fill(name);+ await scope.locator('select[name="type"]').selectOption(type);+ await scope.locator('select[name="optin"]').selectOption(optin);+ if (tag) {+ const input = scope.locator('input[name="tags"]');+ await input.fill(tag);+ await input.press('Enter');+ }+ await scope.locator('textarea[name="description"]').fill(description);+}++// Run `action` and wait for the API response.+async function withListAPI(page, method, action) {+ const [res] = await Promise.all([+ page.waitForResponse((r) => /\/api\/lists(\/|\?|$)/.test(r.url()) && r.request().method() === method),+ action(),+ ]);+ expect(res.ok()).toBeTruthy();+}++test.describe.configure({ mode: 'serial' });++test.describe('Lists', () => {+ test('shows the default lists and their subscriber counts', async ({ page }) => {+ await page.goto(LISTS);++ await expect(listRow(page)).toHaveCount(2);+ await expect(listRow(page, 'Default list')).toBeVisible();+ await expect(listRow(page, 'Opt-in list')).toBeVisible();++ // Both seeded lists have exactly one subscriber.+ await expect(listRow(page, 'Default list').locator('.subscriber-total')).toContainText('1');+ await expect(listRow(page, 'Opt-in list').locator('.subscriber-total')).toContainText('1');++ // Type / opt-in badges.+ await expect(listRow(page, 'Default list')).toContainText('Private');+ await expect(listRow(page, 'Default list')).toContainText('Single opt-in');+ await expect(listRow(page, 'Opt-in list')).toContainText('Public');+ await expect(listRow(page, 'Opt-in list')).toContainText('Double opt-in');+ });++ test('creates a campaign for a list', async ({ page }) => {+ await page.goto(LISTS);++ const row = listRow(page, 'Default list');+ await openMenu(row);+ await Promise.all([+ page.waitForURL('**/admin/campaigns/new**'),+ row.getByTestId('btn-campaign').click(),+ ]);++ // The list is pre-selected on the new campaign form.+ await expect(page.getByText('Default list')).toBeVisible();+ });++ test('creates an opt-in campaign for a double opt-in list', async ({ page }) => {+ await page.goto(LISTS);++ const row = listRow(page, 'Opt-in list');+ await openMenu(row);+ await row.getByTestId('btn-send-optin-campaign').click();+ await confirm(page);++ // Redirects to the newly created campaign's content tab.+ await page.waitForURL(/\/admin\/campaigns\/\d+/);+ expect(page.url()).toContain('#tab=content');+ });++ test('shows the subscribers of each list', async ({ page }) => {+ const cases = [+ { list: 'Default list', email: '[email protected]' },+ { list: 'Opt-in list', email: '[email protected]' },+ ];++ for (const c of cases) {+ await page.goto(LISTS);+ await listRow(page, c.list).locator('.subscriber-total').click();++ await expect(page).toHaveURL(/\/admin\/subscribers\/lists\/\d+/);+ await expect(page.locator('tbody tr')).toHaveCount(1);+ await expect(page.locator('td.email')).toContainText(c.email);+ }+ });++ test('edits the default lists', async ({ page }) => {+ await page.goto(LISTS);+ const ids = await rowIDs(page);++ for (const [n, id] of ids.entries()) {+ await page.goto(`${LISTS}/${id}`);+ await fillListForm(page, {+ name: `list-${n}`,+ type: 'public',+ optin: 'double',+ tag: `tag${n}`,+ description: `desc${n}`,+ });+ await withListAPI(page, 'PUT', () => page.getByTestId('btn-save').click());+ }++ // Confirm the edits on the listing.+ await page.goto(LISTS);+ for (let n = 0; n < ids.length; n += 1) {+ const row = listRow(page, `list-${n}`);+ await expect(row).toContainText('Public');+ await expect(row).toContainText('Double opt-in');+ await expect(row).toContainText('#test');+ await expect(row).toContainText(`#tag${n}`);+ }+ });++ test('deletes all lists', async ({ page }) => {+ await page.goto(LISTS);++ let count = await listRow(page).count();+ while (count > 0) {+ const row = listRow(page).first();+ const id = await row.getAttribute('data-id');+ await openMenu(row);+ await row.getByTestId('btn-delete').click();+ await withListAPI(page, 'DELETE', () => confirm(page));++ count -= 1;+ await expect(listRow(page)).toHaveCount(count);+ }++ await expect(page.locator('.empty-state')).toBeVisible();+ });++ test('adds new lists of every type/opt-in combination', async ({ page }) => {+ const combos = [+ { type: 'private', optin: 'single' },+ { type: 'private', optin: 'double' },+ { type: 'public', optin: 'single' },+ { type: 'public', optin: 'double' },+ ];++ for (const [n, c] of combos.entries()) {+ const name = `list-${c.type}-${c.optin}-${n}`;+ await page.goto(LISTS);+ await page.getByTestId('btn-new').click();++ const dialog = page.locator('dialog[open]');+ await fillListForm(dialog, {+ name, type: c.type, optin: c.optin, tag: `tag${n}`, description: `desc-${c.type}-${n}`,+ });+ await withListAPI(page, 'POST', () => dialog.getByTestId('btn-save').click());++ const row = listRow(page, name);+ await expect(row).toBeVisible();+ await expect(row).toContainText(c.type === 'private' ? 'Private' : 'Public');+ await expect(row).toContainText(c.optin === 'single' ? 'Single opt-in' : 'Double opt-in');+ }+ });++ test('searches lists by name', async ({ page }) => {+ await page.goto(LISTS);++ await page.getByTestId('query').fill('list-public-single-2');+ await page.getByTestId('query').press('Enter');++ await expect(listRow(page)).toHaveCount(1);+ await expect(listRow(page)).toContainText('list-public-single-2');+ });++ test('filters lists by type', async ({ page }) => {+ await page.goto(LISTS);++ // Clicking a row's type badge filters the listing by that type.+ await listRow(page, 'list-private-single-0').locator('a[href*="type="]').click();+ await expect(page).toHaveURL(/[?&]type=private/);++ // Only the two private lists remain.+ await expect(listRow(page)).toHaveCount(2);+ await expect(listRow(page, 'list-private-single-0')).toBeVisible();+ await expect(listRow(page, 'list-private-double-1')).toBeVisible();++ // The active filter shows as a removable badge.+ await expect(page.locator('.page-title')).toContainText('Private');+ await page.getByTestId('btn-remove-filter').click();+ await expect(listRow(page)).toHaveCount(4);+ });++ test('filters lists by opt-in', async ({ page }) => {+ await page.goto(LISTS);++ await listRow(page, 'list-private-single-0').locator('a[href*="optin="]').click();+ await expect(page).toHaveURL(/[?&]optin=single/);++ // Only the two single opt-in lists remain.+ await expect(listRow(page)).toHaveCount(2);+ await expect(listRow(page, 'list-private-single-0')).toBeVisible();+ await expect(listRow(page, 'list-public-single-2')).toBeVisible();++ await expect(page.locator('.page-title')).toContainText('Single opt-in');+ await page.getByTestId('btn-remove-filter').click();+ await expect(listRow(page)).toHaveCount(4);+ });++ test('filters lists by tag', async ({ page }) => {+ await page.goto(LISTS);++ await listRow(page, 'list-private-single-0').locator('a[href*="tag="]').click();+ await expect(page).toHaveURL(/[?&]tag=tag0/);++ // Each list carries a unique tag, so only one row matches.+ await expect(listRow(page)).toHaveCount(1);+ await expect(listRow(page, 'list-private-single-0')).toBeVisible();++ await expect(page.locator('.page-title')).toContainText('#tag0');+ await page.getByTestId('btn-remove-filter').click();+ await expect(listRow(page)).toHaveCount(4);+ });++ test('filters lists by multiple criteria', async ({ page }) => {+ await page.goto(`${LISTS}?type=public&optin=double`);++ await expect(listRow(page)).toHaveCount(1);+ await expect(listRow(page, 'list-public-double-3')).toBeVisible();++ // Both active filters appear as badges in the header.+ await expect(page.locator('.page-title')).toContainText('Public');+ await expect(page.locator('.page-title')).toContainText('Double opt-in');+ });++ test('sorts lists by column', async ({ page }) => {+ await page.goto(LISTS);++ // Four lists exist with IDs [3,4,5,6] (see the "adds new lists" test).+ const clickSort = async (field, expected) => {+ await page.locator(`a[data-sort-field="${field}"]`).click();+ await expect.poll(() => rowIDs(page)).toEqual(expected);+ };++ await clickSort('name', [4, 3, 6, 5]);+ await clickSort('name', [5, 6, 3, 4]);++ await clickSort('type', [3, 4, 5, 6]);+ await clickSort('type', [6, 5, 4, 3]);++ await clickSort('created_at', [3, 4, 5, 6]);+ await clickSort('created_at', [6, 5, 4, 3]);+ });++ test('lists public lists on the public subscription form', async ({ page }) => {+ await page.goto('/subscription/form');++ const items = page.locator('ul.lists li');+ await expect(items).toHaveCount(2);+ await expect(items.filter({ hasText: 'list-public-single-2' })).toContainText('desc-public-2');+ await expect(items.filter({ hasText: 'list-public-double-3' })).toContainText('desc-public-3');+ });++ test('bulk deletes lists', async ({ page }) => {+ // Create enough lists to span more than one page.+ for (let i = 0; i < 30; i += 1) {+ const res = await page.request.post('/api/lists', {+ data: { name: `bulk-${i}`, type: 'public', optin: 'single' },+ });+ expect(res.ok()).toBeTruthy();+ }++ // Delete every list across all pages via the "select all" query option.+ await page.goto(LISTS);+ await page.locator('thead input[type="checkbox"]').check();+ await page.getByTestId('btn-bulk-actions').click();++ const selectAll = page.getByTestId('select-all-lists');+ if (await selectAll.isVisible()) {+ await selectAll.click();+ }+ await withListAPI(page, 'DELETE', async () => {+ await page.getByTestId('btn-delete-lists').click();+ await confirm(page);+ });+ await expect(page.locator('.empty-state')).toBeVisible();++ // Now delete a single page's worth using the selected-IDs.+ for (let i = 0; i < 5; i += 1) {+ await page.request.post('/api/lists', { data: { name: `bulk-again-${i}`, type: 'public', optin: 'single' } });+ }++ await page.goto(LISTS);+ await page.locator('thead input[type="checkbox"]').check();+ await page.getByTestId('btn-bulk-actions').click();+ await withListAPI(page, 'DELETE', async () => {+ await page.getByTestId('btn-delete-lists').click();+ await confirm(page);+ });+ await expect(page.locator('.empty-state')).toBeVisible();+ });+});