一键导入
acceptance-testing
Use this skill when writing tests that need to exercise the system as whole. Also known as end to end tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use this skill when writing tests that need to exercise the system as whole. Also known as end to end tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use this skill to perform a code review. This should be done every time a task involving new feature development is completed
Use this skill when writing Elixir context functions that involve multi-step operations, external API calls, or database operations. Covers using `with` statements, proper error handling, and organizing code in Phoenix contexts.
This skill describes how to use the Elixir test runner
Use this skill when writing tests for code that interacts with external APIs, third-party services, or LLMs. Covers the behaviour/fake module pattern with configurable implementations.
Use this skill at the beginning and end of a coding session in a Sprite VM. At session start, it checks out main and pulls latest. At session end, it ensures tests pass, commits on a branch, and creates a PR. Invoke this skill when the user starts a session, says they're done, wants to wrap up, or asks to create a PR for their work.
Use this skill when working on any new feature. It enforces a strict test-driven development workflow where tests are written before implementation code.
| name | acceptance-testing |
| description | Use this skill when writing tests that need to exercise the system as whole. Also known as end to end tests. |
You MUST consult this skill when:
Ask yourself: "Does this change affect what users see or how they interact with the app?" If yes, an acceptance test is likely needed.
For bugs or features that involve the UI, we need an acceptance test. Choose the right approach:
Use Playwright tests when testing:
Location: test/waylo_web/features/*test.exs
Use LiveView tests when:
defmodule WayloWeb.FeatureNameBrowserTest do
use PhoenixTest.Playwright.Case, async: false, slow_mo: 50
alias Waylo.Products.Search.Fake, as: FakeSearch
import Waylo.Factory
import PhoenixTest.Playwright, only: [click: 2, click: 3, type: 3]
describe "feature name" do
setup do
FakeSearch.reset()
:ok
end
test "description of behavior", %{conn: conn} do
# 1. Setup: Create test data using factories
user = insert(:user_with_password, email: "unique@example.com")
customer = insert(:customer, user: user, name: "Test Customer", external_ids: %{"opencart" => "unique_id"})
product = insert(:product, name: "Test Product", user_id: user.id, available_quantity: 50)
# 2. Setup fakes for external services
FakeSearch.set_responses(%{
~r/test product/i => product
})
# 3. Authentication flow
conn
|> visit("/users/log-in")
|> fill_in("#login_form_password_email", "Email", with: "unique@example.com")
|> fill_in("Password", with: "hello world!")
|> click_button("Log in and stay logged in")
# 4. Navigation to the feature
|> click_link("Customers")
|> click("tr", "Test Customer")
# 5. Interact with the feature
|> assert_has("waylo-upload")
|> click_button("Make an Order")
# 6. Assert on outcomes
|> assert_has(".dialog-header", text: "Upload Order File")
end
end
end
# Navigation
visit(conn, "/path")
click_link("Link Text")
click_button("Button Text")
# Clicking elements
click("selector", "description") # Click by CSS selector
click("[data-testid='my-element']", "My Element")
# Forms
fill_in("Label", with: "value")
fill_in("#css-selector", "Label", with: "value")
type("[data-testid='input']", "text to type")
# File uploads
upload("input[type='file']", "Label", "test/support/filename.csv", [])
# Assertions
assert_has("selector")
assert_has("selector", text: "expected text")
assert_has(".class", text: "text")
refute_has("selector")
refute_has("selector", text: "text")
assert_path("/expected/path")
# Chaining with verification
|> then(fn conn ->
# Database assertions
orders = Waylo.Orders.list_orders(scope)
assert length(orders) == 1
conn
end)
test "displays error message when upload fails", %{conn: conn} do
user = insert(:user_with_password, email: "error_test@example.com")
_customer = insert(:customer, user: user, name: "Test Customer", external_ids: %{"opencart" => "err1"})
conn
|> visit("/users/log-in")
|> fill_in("#login_form_password_email", "Email", with: "error_test@example.com")
|> fill_in("Password", with: "hello world!")
|> click_button("Log in and stay logged in")
|> click_link("Customers")
|> click("tr", "Test Customer")
|> click_button("Make an Order")
|> upload("input[type='file']", "Select File", "test/support/invalid_format.csv", [])
|> click("[data-testid='upload-button']", "Upload")
|> assert_has("[data-testid='upload-error']")
|> assert_has(".error-title", text: "Unrecognized File Format")
end
test "updates UI when state changes", %{conn: conn} do
# ... setup ...
conn
|> click_button("Action")
|> assert_has(".loading-state") # Verify loading state
|> assert_has(".success-state") # Wait for success state
|> refute_has(".loading-state") # Verify loading is gone
end
test "creates record in database", %{conn: conn} do
# ... setup and actions ...
|> assert_path("/success/path")
|> then(fn conn ->
# Verify database state
scope = Waylo.Accounts.Scope.for_user(user)
orders = Waylo.Orders.list_orders(scope)
assert length(orders) == 1
[order] = orders
assert order.status == "submitted"
conn
end)
end
Create test support files in test/support/:
test_order.csv - Valid CSV for successful uploadstest_order_alternate.csv - Alternative valid CSVinvalid_format.csv - CSV with unrecognized columns for error testingFakeSearch.reset() and other fake resetsassert_has to wait for elements before interactingFirst, identify what needs testing:
Create necessary test fixtures in test/support/ if needed
Write tests that exercise the full stack: