Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions e2e/tests/dashboard/team-setup.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { test, expect } from '@playwright/test'
import { setupSite } from '../fixtures'
import { expectLiveViewConnected } from '../test-utils'

test('submitting team name via Enter key does not crash', async ({
page,
request
}) => {
await setupSite({ page, request })
await page.goto('/team/setup')

// await expectLiveViewConnected(page)
// at test-utils.ts:5
//
// 3 |
// 4 | export async function expectLiveViewConnected(page: Page) {
// > 5 | return expect(page.locator('.phx-connected')).toHaveCount(1)
// | ^
// 6 | }
// 7 |


await expect(
page.getByRole('button', { name: 'Create Team' })
).toBeVisible()

const nameInput = page.locator('input[name="team[name]"]')

await nameInput.clear()
await nameInput.fill('My New Team')

await nameInput.press('Enter')

// the form had no phx-submit handler and plain HTTP POST fallback was made
await expect(
page.getByRole('button', { name: 'Create Team' })
).toBeVisible()

await expect(nameInput).toHaveValue('My New Team')

// should follow a redirect?
await page.goto('/settings/team/general')

await expectLiveViewConnected(page)

const nameInput2 = page.locator('input[name="team[name]"]')
// fails:
await expect(nameInput2).toHaveValue('My New Team')
})
1 change: 1 addition & 0 deletions lib/plausible_web/live/team_setup.ex
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ defmodule PlausibleWeb.Live.TeamSetup do
for={@team_name_form}
method="post"
phx-change="update-team"
phx-submit="update-team"
phx-blur="update-team"
id="update-team-form"
class="mt-4 mb-8"
Expand Down
Loading