discourse/spec/system/page_objects/components
chapoi 2ca06ba236
DEV: form-kit
This PR introduces FormKit, a component-based form library designed to simplify form creation and management. This library provides a single `Form` component, various field components, controls, validation mechanisms, and customization options. Additionally, it includes helpers to facilitate testing and writing specifications for forms.

1. **Form Component**:
   - The main component that encapsulates form logic and structure.
   - Yields various utilities like `Field`, `Submit`, `Alert`, etc.

   **Example Usage**:
   ```gjs
   import Form from "discourse/form";

   <template>
     <Form as |form|>
       <form.Field
         @name="username"
         @title="Username"
         @validation="required"
         as |field|
       >
         <field.Input />
       </form.Field>

       <form.Field @name="age" @title="Age" as |field|>
         <field.Input @type="number" />
       </form.Field>

       <form.Submit />
     </Form>
   </template>
   ```

2. **Validation**:
   - Built-in validation rules such as `required`, `number`, `length`, and `url`.
   - Custom validation callbacks for more complex validation logic.

   **Example Usage**:
   ```javascript
   validateUsername(name, value, data, { addError }) {
     if (data.bar / 2 === value) {
       addError(name, "That's not how maths work.");
     }
   }
   ```

   ```hbs
   <form.Field @name="username" @validate={{this.validateUsername}} />
   ```

3. **Customization**:
   - Plugin outlets for extending form functionality.
   - Styling capabilities through propagated attributes.
   - Custom controls with properties provided by `form` and `field`.

   **Example Usage**:
   ```hbs
   <Form class="my-form" as |form|>
     <form.Field class="my-field" as |field|>
       <MyCustomControl id={{field.id}} @onChange={{field.set}} />
     </form.Field>
   </Form>
   ```

4. **Helpers for Testing**:
   - Test assertions for form and field validation.

   **Example usage**:
   ```javascript
   assert.form().hasErrors("the form shows errors");
   assert.form().field("foo").hasValue("bar", "user has set the value");
   ```

   - Helper for interacting with he form

   **Example usage**:
   ```javascript
   await formKit().field("foo").fillIn("bar");
   ```

5. **Page Object for System Specs**:
   - Page objects for interacting with forms in system specs.
   - Methods for submitting forms, checking alerts, and interacting with fields.

   **Example Usage**:
   ```ruby
   form = PageObjects::Components::FormKit.new(".my-form")
   form.submit
   expect(form).to have_an_alert("message")
   ```

   **Field Interactions**:
   ```ruby
   field = form.field("foo")
   expect(field).to have_value("bar")
   field.fill_in("bar")
   ```


6. **Collections handling**:
   - A specific component to handle array of objects

   **Example Usage**:
   ```gjs
    <Form @data={{hash foo=(array (hash bar=1) (hash bar=2))}} as |form|>
      <form.Collection @name="foo" as |collection|>
        <collection.Field @name="bar" @title="Bar" as |field|>
          <field.Input />
        </collection.Field>
      </form.Collection>
    </Form>
   ```
2024-07-17 11:59:35 +02:00
..
navigation_menu DEV: Improve the sidebar section expansion handling (#27805) 2024-07-09 18:32:29 -03:00
ace_editor.rb DEV: Allow typed objects theme settings to be saved via settings editor (#26100) 2024-03-11 08:42:12 +08:00
admin_about_config_area_contact_information_card.rb DEV: Wiring for the admin about config page (#27492) 2024-07-01 05:40:37 +03:00
admin_about_config_area_general_settings_card.rb DEV: Wiring for the admin about config page (#27492) 2024-07-01 05:40:37 +03:00
admin_about_config_area_your_organization_card.rb DEV: Wiring for the admin about config page (#27492) 2024-07-01 05:40:37 +03:00
admin_theme_settings_editor.rb DEV: Allow typed objects theme settings to be saved via settings editor (#26100) 2024-03-11 08:42:12 +08:00
admin_theme_translations_settings_editor.rb FEATURE: add language picker for theme translations in admin UI (#26150) 2024-03-18 12:00:28 -04:00
base.rb
bookmark_menu.rb DEV: implements <DropdownMenu /> (#26917) 2024-05-08 09:08:42 +02:00
calendar_date_time_picker.rb DEV: Add more structure for admin plugin config nav (#26707) 2024-05-02 11:36:46 +10:00
category_badge.rb FEATURE: Bulk topic tagging allowing restricted operations on sole categories (#26602) 2024-04-12 13:10:14 +10:00
category_list.rb DEV: Implement glimmer topic-list (#26743) 2024-05-21 14:36:15 +02:00
composer.rb FIX: prevents showing discard modal on re-edit (#26639) 2024-04-16 10:34:32 +02:00
d_toggle_switch.rb UI: redesigned settings/members (#23804) 2023-10-09 14:11:16 +02:00
dialog.rb DEV: Add confirm_danger to Dialog page object (#26846) 2024-05-03 09:31:16 +10:00
emoji_picker.rb DEV: Speed up core system tests (#21394) 2023-05-05 07:45:53 +08:00
fast_editor.rb
filter.rb FEATURE: move back to the forum link above the filter (#26070) 2024-03-07 14:48:16 +11:00
form_kit.rb DEV: form-kit 2024-07-17 11:59:35 +02:00
group-card.rb FIX: Member Highlights on Group Cards (#22828) 2023-07-28 14:33:42 +00:00
new_topic_list_toggle_tab.rb FEATURE: New topics vs replies toggle for the new new view (#22920) 2023-08-18 12:44:04 +08:00
new_topic_list_toggle.rb UX: update /new toggle styles, class names (#23154) 2023-08-21 09:34:12 +08:00
pikaday_calendar.rb DEV: Add more structure for admin plugin config nav (#26707) 2024-05-02 11:36:46 +10:00
private_message_map.rb DEV: convert PrivateMessageMap widget to glimmer components (#25837) 2024-03-04 10:24:25 +08:00
select_kit.rb DEV: form-kit 2024-07-17 11:59:35 +02:00
sidebar_header_dropdown.rb UX: Remove section heading for community section (#22405) 2023-07-11 09:40:37 +08:00
theme_translation_text_area.rb FEATURE: add language picker for theme translations in admin UI (#26150) 2024-03-18 12:00:28 -04:00
toasts.rb UX: enhances chat copy features (#23770) 2023-10-04 16:14:37 +02:00
topic_list_controls.rb UX: Don't hide new navigation item in experimental new new view (#26094) 2024-03-08 09:26:09 +08:00
topic_list_header.rb FEATURE: Use new topic bulk actions dropdown on search page (#27303) 2024-06-07 10:41:42 +10:00
topic_list.rb FIX: Correctly highlight new topic-list-items in glimmer (#27623) 2024-06-26 20:04:33 +02:00
topic_map.rb DEV: add system test for topic map (#25242) 2024-01-17 19:25:18 +08:00
topic_query_filter.rb FIX: /filter route input field not updating on route change (#23119) 2023-08-17 09:04:48 +08:00
topic_view.rb FIX: correctly untrack topics when dismiss unread (#23894) 2023-10-11 02:51:43 +00:00
uppy_image_uploader.rb DEV: Fix flaky spec for the /about admin config area (#27697) 2024-07-04 10:39:22 +10:00
user_menu.rb DEV: Add setUserMenuNotificationsLimit plugin-api method (#25119) 2024-01-09 08:38:00 +08:00