|
| 1 | +# Epic: Create Component Test Plans (Hacktoberfest Cookbook) |
| 2 | + |
| 3 | +GH Ticket Id: #7475 |
| 4 | + |
| 5 | +**This is a perfect task for Hacktoberfest!** The deliverable is a single markdown file, which constitutes a valuable contribution and is eligible for the `hacktoberfest` label. |
| 6 | + |
| 7 | +## 1. Goal & AI-Native Workflow |
| 8 | + |
| 9 | +The goal of this epic is to rapidly increase our component test coverage by first creating high-quality, comprehensive test *plans*. |
| 10 | + |
| 11 | +This epic requires our new **AI-Native workflow**, and big parts of it can be resolved by navigating AI agents like Gemini. Your task is not to write code, but to act as a "prompt engineer". You will guide the agent to analyze the Neo.mjs codebase and generate a detailed test plan for a component. |
| 12 | + |
| 13 | +For getting up to speed, please read: |
| 14 | +- [**Working with Agents**](https://github.com/neomjs/neo/blob/dev/.github/WORKING_WITH_AGENTS.md) |
| 15 | +- [**AI Quick Start**](https://github.com/neomjs/neo/blob/dev/.github/AI_QUICK_START.md) |
| 16 | + |
| 17 | +Since this is a collaborative effort, we also strongly recommend joining our Slack and / or Discord Channels to synchronize with other contributors: |
| 18 | + |
| 19 | +- [Slack Invite](https://join.slack.com/t/neomjs/shared_invite/zt-6c50ueeu-3E1~M4T9xkNnb~M_prEEOA) |
| 20 | +- [Discord Invite](https://discord.gg/6p8paPq) |
| 21 | + |
| 22 | +## 2. The Deliverable |
| 23 | + |
| 24 | +Your contribution will be a single markdown file committed to the `.github/ISSUE/` directory. |
| 25 | + |
| 26 | +- **File Name:** `ticket-cpm-test-[component-name].md` |
| 27 | + - Replace `[component-name]` with the hyphenated path of the component, e.g., `form-field-text` for `Neo.form.field.Text`. |
| 28 | +- **Content:** A detailed test plan in markdown format, generated by the LLM. |
| 29 | + |
| 30 | +This file is the pull request, and it is the valuable contribution we are looking for. |
| 31 | + |
| 32 | +## 3. The Cookbook: A Step-by-Step Guide |
| 33 | + |
| 34 | +Follow these steps to generate the test plan. The key is to provide the LLM with the right context by asking it to perform a series of analysis tasks first. |
| 35 | + |
| 36 | +**Use the following prompts as a template.** |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +### Step 1: Pick a Component & Find Its Example |
| 41 | + |
| 42 | +First, choose a component from the `src/` directory that does not yet have a corresponding test in `test/playwright/component/`. |
| 43 | + |
| 44 | +> **Your Prompt to Gemini:** |
| 45 | +> "Hi Gemini, I want to create a test plan for `Neo.form.field.Text`. First, let's find its example application in the `examples/` folder. The examples folder structure often mirrors the `src` namespace (e.g., the example for `src/tab/Container.mjs` might be in `examples/tab/container/`)." |
| 46 | +
|
| 47 | +### Step 2: Visually Explore the Example |
| 48 | + |
| 49 | +This step is critical for understanding the component's behavior. |
| 50 | + |
| 51 | +1. Ensure the project is built: `npm run build-all` (if you haven't already). |
| 52 | +2. Start the development server: `npm run server-start`. |
| 53 | +3. The server will start at `http://localhost:8080/` by default. If the port is in use, it will automatically increment (e.g., to 8081). |
| 54 | +4. Open the example URL in your browser (e.g., `http://localhost:8080/examples/form/field/text/`). |
| 55 | +5. Use your browser's developer tools to inspect the DOM. |
| 56 | +6. Play with the configuration panel on the right. Change values and see how the component's appearance and DOM structure react in real-time. |
| 57 | + |
| 58 | +### Step 3: Programmatically Inspect the Live Component |
| 59 | + |
| 60 | +Now, ask Gemini to do the same exploration you just did. This gives the agent ground-truth information about the rendered component. |
| 61 | + |
| 62 | +> **Your Prompt to Gemini:** |
| 63 | +> "Gemini, now it's your turn to look at the live component. Please navigate to `http://localhost:8080/examples/form/field/text/`, take a snapshot of the initial DOM, and show me the result." |
| 64 | +
|
| 65 | +### Step 4: Analyze the Inheritance Chain |
| 66 | + |
| 67 | +A component inherits many of its features. We need to know the full chain to understand what to test. |
| 68 | + |
| 69 | +> **Your Prompt to Gemini:** |
| 70 | +> "Next, let's understand the component's DNA. Please read the source for `Neo.form.field.Text` and trace its full inheritance hierarchy up to `Neo.core.Base`." |
| 71 | +
|
| 72 | +### Step 5: Analyze Dependencies |
| 73 | + |
| 74 | +Components often use other components (e.g., Triggers, Plugins). We need to identify them. |
| 75 | + |
| 76 | +> **Your Prompt to Gemini:** |
| 77 | +> "What other components or classes does `Neo.form.field.Text` directly use or instantiate? Please analyze its source code, especially the imports and any `Neo.create()` or `ntype` configurations." |
| 78 | +
|
| 79 | +### Step 6: Analyze Styling & Theming |
| 80 | + |
| 81 | +A component's appearance and states are defined in SCSS. We need to know the CSS classes that control how it looks. |
| 82 | + |
| 83 | +> **Your Prompt to Gemini:** |
| 84 | +> "A component's appearance is crucial. Please find all `.scss` files related to `Neo.form.field.Text` for the base, `theme-light`, `theme-dark`, and `theme-neo-light` themes. Read them and extract the key CSS classes that represent its different states (e.g., `.neo-focus`, `.neo-invalid`, `.neo-disabled`)." |
| 85 | +
|
| 86 | +### Step 7: Synthesize the Test Plan |
| 87 | + |
| 88 | +This is the final and most important step. You'll ask the LLM to combine all the information it has gathered into a structured test plan, formatted as a complete ticket file. |
| 89 | + |
| 90 | +> **Your Prompt to Gemini:** |
| 91 | +> "Excellent. Now, based on all the information you have gathered, please generate a comprehensive test plan for `Neo.form.field.Text` and format it as a complete ticket file, following the project's standard structure. |
| 92 | +> |
| 93 | +> The output should be a single markdown document with YAML frontmatter. The main content should have a `## Description` and a `## Acceptance Criteria` section. The acceptance criteria should be a checklist of tests based on the component's inherited and specific features." |
| 94 | +
|
| 95 | +--- |
| 96 | + |
| 97 | +## 4. Create the Pull Request |
| 98 | + |
| 99 | +Once Gemini has generated the markdown, save it to a new file (e.g., `.github/ISSUE/ticket-cpm-test-form-field-text.md`), commit it, and open a pull request. |
| 100 | + |
| 101 | +A valid PR is eligible for the `hacktoberfest-accepted` label. If you would also like to implement the test and create a second PR, please leave a comment in your pull request asking for the ticket to be assigned to you. |
| 102 | + |
| 103 | +That's it! You've made a valuable contribution to the Neo.mjs project. |
| 104 | + |
| 105 | +--- |
| 106 | +## 5. Appendix: Example Ticket Output |
| 107 | + |
| 108 | +The markdown file you generate in Step 5 should look like this: |
| 109 | + |
| 110 | +```markdown |
| 111 | +--- |
| 112 | +title: 'Create Playwright Component Test for Neo.form.field.Text' |
| 113 | +labels: 'enhancement, testing, hacktoberfest, good first issue, help wanted' |
| 114 | +--- |
| 115 | + |
| 116 | +GH ticket id: (leave blank, will be assigned) |
| 117 | + |
| 118 | +**Epic:** Migrate Component Tests from Siesta to Playwright (R&D) |
| 119 | +**Phase:** 2 |
| 120 | +**Status:** To Do |
| 121 | + |
| 122 | +## Description |
| 123 | + |
| 124 | +This ticket is to create a new Playwright-based component test for `Neo.form.field.Text`. |
| 125 | + |
| 126 | +This test plan was generated using the AI-Native workflow defined in the "Cookbook Epic" and will serve as the acceptance criteria for the implementation. The test should be created in a new file `test/playwright/component/form/field/Text.spec.mjs` and follow the "Empty Viewport" architecture. |
| 127 | + |
| 128 | +## Acceptance Criteria |
| 129 | + |
| 130 | +### 1. Inherited Behavior Tests |
| 131 | + |
| 132 | +- [ ] **`disabled` config:** Test that setting `disabled: true` adds the `.neo-disabled` class, prevents user interaction, and disables the input element. |
| 133 | +- [ ] **`hidden` config:** Test that setting `hidden: true` removes the component from the DOM (using the default `removeDom` hideMode). |
| 134 | +- [ ] **`cls` & `style` configs:** Test that custom classes and inline styles are correctly applied to the component's root element. |
| 135 | +- [ ] **`value` config:** Test setting the field's value programmatically and verifying the input element reflects the change. |
| 136 | +- [ ] **`isDirty` flag:** Test that the `isDirty` flag is correctly set when the value changes from its original value. |
| 137 | + |
| 138 | +### 2. Component-Specific Feature Tests |
| 139 | + |
| 140 | +- [ ] **`clearable` config:** Test that the clear trigger appears when the field has value and `clearable: true`. Test that clicking the trigger clears the value. |
| 141 | +- [ ] **`labelText` & `labelPosition` configs:** Test that changing `labelPosition` applies the correct `.label-[position]` class. For `labelPosition: 'inline'`, test that the label animation works correctly on focus and when content is present. |
| 142 | +- [ ] **Validation (`minLength`, `maxLength`, `required`):** Test that entering a value that violates a validation rule correctly applies the `.neo-invalid` class and that an error message is displayed. |
| 143 | +- [ ] **Triggers:** Test that custom triggers can be added and that they are interactive. |
| 144 | +- [ ] **Styling States:** Test that `.neo-focus` and `.neo-hovered` classes are applied correctly on user interaction. |
| 145 | +``` |
| 146 | + |
| 147 | +## 7. Sub-Tasks |
| 148 | + |
| 149 | +- **To Do:** ticket-component-testing-cookbook-form-field-password.md |
0 commit comments