diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..64f91af --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,69 @@ +# LiveTemplate Examples + +## Progressive Complexity + +All examples follow the **progressive complexity** model introduced in livetemplate v0.8.7: + +- **Tier 1 (Standard HTML)** is the default. Use native HTML forms, buttons, and inputs. +- **Tier 2 (`lvt-*` attributes)** only when standard HTML cannot express the behavior. + +### Tier 1 Constructs + +| Construct | Pattern | Routes to | +|-----------|---------|-----------| +| Form submission | `
` | `Add()` method | +| Button action | `
diff --git a/chat/chat_e2e_test.go b/chat/chat_e2e_test.go index ffd1147..2c3ce57 100644 --- a/chat/chat_e2e_test.go +++ b/chat/chat_e2e_test.go @@ -123,17 +123,17 @@ func TestChatE2E(t *testing.T) { err := chromedp.Run(browserCtx, // Capture initial state chromedp.Text(".stats", &initialStatsText, chromedp.ByQuery), - chromedp.Evaluate(`document.querySelector('form[lvt-submit="join"]') !== null`, &initialFormVisible), + chromedp.Evaluate(`document.querySelector('form[name="join"]') !== null`, &initialFormVisible), // Fill and submit join form chromedp.SetValue(`input[name="username"]`, "testuser", chromedp.ByQuery), - chromedp.Click(`button[type="submit"]`, chromedp.ByQuery), + chromedp.Evaluate(`document.querySelector('form[name="join"] button[type="submit"]').click()`, nil), waitFor(`document.querySelector('.messages') !== null`, 5*time.Second), // Capture after-join state chromedp.Text(".stats", &afterStatsText, chromedp.ByQuery), chromedp.Evaluate(`document.querySelector('.messages') !== null`, &afterChatVisible), - chromedp.Evaluate(`document.querySelector('form[lvt-submit="join"]') !== null`, &afterFormVisible), + chromedp.Evaluate(`document.querySelector('form[name="join"]') !== null`, &afterFormVisible), ) if err != nil { @@ -190,9 +190,9 @@ func TestChatE2E(t *testing.T) { chromedp.Run(browserCtx, chromedp.WaitVisible(`input[name="username"]`, chromedp.ByQuery), chromedp.SetValue(`input[name="username"]`, "testuser", chromedp.ByQuery), - chromedp.Click(`button[type="submit"]`, chromedp.ByQuery), + chromedp.Evaluate(`document.querySelector('form[name="join"] button[type="submit"]').click()`, nil), waitFor(`document.querySelector('.messages') !== null`, 5*time.Second), - chromedp.WaitVisible(`.messages`, chromedp.ByQuery), // Explicitly wait for messages container + chromedp.WaitVisible(`.messages`, chromedp.ByQuery), ) t.Log("Join completed, .messages container is visible") } @@ -210,7 +210,7 @@ func TestChatE2E(t *testing.T) { return nil }), chromedp.SetValue(`input[name="message"]`, "First message", chromedp.ByQuery), - chromedp.Click(`form[lvt-submit="send"] button[type="submit"]`, chromedp.ByQuery), + chromedp.Evaluate(`document.querySelector('form[name="send"] button[type="submit"]').click()`, nil), waitFor(`document.querySelectorAll('.messages .message').length >= 1`, 5*time.Second), chromedp.ActionFunc(func(ctx context.Context) error { @@ -231,7 +231,7 @@ func TestChatE2E(t *testing.T) { return nil }), chromedp.SetValue(`input[name="message"]`, "Second message", chromedp.ByQuery), - chromedp.Click(`form[lvt-submit="send"] button[type="submit"]`, chromedp.ByQuery), + chromedp.Evaluate(`document.querySelector('form[name="send"] button[type="submit"]').click()`, nil), waitFor(`document.querySelectorAll('.messages .message').length >= 2`, 5*time.Second), chromedp.ActionFunc(func(ctx context.Context) error { @@ -252,7 +252,7 @@ func TestChatE2E(t *testing.T) { return nil }), chromedp.SetValue(`input[name="message"]`, "Third message", chromedp.ByQuery), - chromedp.Click(`form[lvt-submit="send"] button[type="submit"]`, chromedp.ByQuery), + chromedp.Evaluate(`document.querySelector('form[name="send"] button[type="submit"]').click()`, nil), waitFor(`document.querySelectorAll('.messages .message').length >= 3`, 5*time.Second), chromedp.ActionFunc(func(ctx context.Context) error { diff --git a/counter/counter.tmpl b/counter/counter.tmpl index 2241f71..db32af0 100644 --- a/counter/counter.tmpl +++ b/counter/counter.tmpl @@ -10,9 +10,9 @@

Counter: {{.Counter}}

- - - + + +