# create-product: fill and submit the Add Product form (apps/admin-ui). # Form-only: begins on the Add Product page - it is the orchestrator's job to # land there (launch/login/navigate). Text-only (no image upload), product # create does not need them. # Args: PRODUCT_NAME, STORE_NAME, PRODUCT_TYPE, # SHORT_DESCRIPTION, LONG_DESCRIPTION, # QUANTITY_1, PRICE_1, MARKET_PRICE_1, # QUANTITY_2, PRICE_2, MARKET_PRICE_2, # QUANTITY_3, PRICE_3, MARKET_PRICE_3, # COMBO_ITEM_0, COMBO_ITEM_1, COMBO_ITEM_2. # Descriptions are optional and gated per field. Variants are optional and must # be supplied in order (3 requires 2 requires 1, all three fields each). The # 3rd variant is always created as an Offer SKU. # Combo: PRODUCT_TYPE=combo adds "Included Items" rows to variant 1. Each # COMBO_ITEM_n is a SKU-label substring (case-insensitive, spaces become '-') # matched against the option ids (variant-0-combo-sku-n-option--). # Every pushed combo row must get a selection (placeholder skuId 0 fails the # backend zod positive-int check), so COMBO_ITEM_0 is required for combos. # Combo items after slot 0 only fill if the previous slots were filled. # Run from the admin-ui folder or via runFlow from an orchestrator flow. appId: in.freshyo.adminui env: PRODUCT_NAME: ${PRODUCT_NAME || ""} STORE_NAME: ${STORE_NAME || ""} PRODUCT_TYPE: ${PRODUCT_TYPE || "item"} SHORT_DESCRIPTION: ${SHORT_DESCRIPTION || ""} LONG_DESCRIPTION: ${LONG_DESCRIPTION || ""} QUANTITY_1: ${QUANTITY_1 || ""} PRICE_1: ${PRICE_1 || ""} MARKET_PRICE_1: ${MARKET_PRICE_1 || ""} QUANTITY_2: ${QUANTITY_2 || ""} PRICE_2: ${PRICE_2 || ""} MARKET_PRICE_2: ${MARKET_PRICE_2 || ""} QUANTITY_3: ${QUANTITY_3 || ""} PRICE_3: ${PRICE_3 || ""} MARKET_PRICE_3: ${MARKET_PRICE_3 || ""} COMBO_ITEM_0: ${COMBO_ITEM_0 || ""} COMBO_ITEM_1: ${COMBO_ITEM_1 || ""} COMBO_ITEM_2: ${COMBO_ITEM_2 || ""} --- # Fail fast: variant levels must be contiguous (3 -> 2 -> 1), each fully specified. - evalScript: ${output.hasV1 = (QUANTITY_1 != "" && PRICE_1 != "" && MARKET_PRICE_1 != "")} - evalScript: ${output.hasV2 = (QUANTITY_2 != "" && PRICE_2 != "" && MARKET_PRICE_2 != "")} - evalScript: ${output.hasV3 = (QUANTITY_3 != "" && PRICE_3 != "" && MARKET_PRICE_3 != "")} - assertTrue: condition: ${(!output.hasV2 || output.hasV1) && (!output.hasV3 || output.hasV2)} label: "create-product: variants must be specified in order - *_3 requires *_2 and *_1, and *_2 requires *_1. Pass all three fields (QUANTITY_n/PRICE_n/MARKET_PRICE_n) for each variant." # Fail fast: a combo with no item would submit a skuId 0 placeholder row. - assertTrue: condition: ${PRODUCT_TYPE.toLowerCase() !== "combo" || COMBO_ITEM_0 != ""} label: "create-product: PRODUCT_TYPE=combo requires COMBO_ITEM_0 (a SKU label substring to include)" # Combo items must also be contiguous. - assertTrue: condition: ${(COMBO_ITEM_2 != "" && COMBO_ITEM_1 != "" && COMBO_ITEM_0 != "") || (COMBO_ITEM_1 != "" && COMBO_ITEM_0 != "") || COMBO_ITEM_0 != "" || (COMBO_ITEM_1 == "" && COMBO_ITEM_2 == "") && COMBO_ITEM_0 == ""} label: "create-product: combo items must be specified in order - COMBO_ITEM_2 requires COMBO_ITEM_1 and COMBO_ITEM_0." - extendedWaitUntil: visible: id: product-name-input timeout: 30000 # focus-guaranteed tap (validates the field really got focus) - runFlow: file: subflows/tap-and-focus.yaml env: FIELD_ID: product-name-input - eraseText - inputText: ${PRODUCT_NAME} - pressKey: Enter # Gated descriptions (independent per field). - runFlow: when: true: ${SHORT_DESCRIPTION != ""} commands: # focus-guaranteed tap (validates the field really got focus) - runFlow: file: subflows/tap-and-focus.yaml env: FIELD_ID: product-short-description-input - eraseText - inputText: ${SHORT_DESCRIPTION} - pressKey: Enter # multiline field: Enter does NOT dismiss the keyboard - tap a # static, non-interactive topLabel so later taps are not eaten - tapOn: text: 'Product Name' - waitForAnimationToEnd - runFlow: when: true: ${LONG_DESCRIPTION != ""} commands: # focus-guaranteed tap (validates the field really got focus) - runFlow: file: subflows/tap-and-focus.yaml env: FIELD_ID: product-long-description-input - eraseText - inputText: ${LONG_DESCRIPTION} - pressKey: Enter # multiline field: Enter does NOT dismiss the keyboard - tap a # static, non-interactive topLabel so later taps are not eaten - tapOn: text: 'Product Name' - waitForAnimationToEnd - scrollUntilVisible: element: id: product-store-dropdown direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - assertVisible: id: product-store-dropdown - tapOn: id: product-store-dropdown - waitForAnimationToEnd # Select by id: BottomDropdown option testIDs embed the label slug # (product-store-dropdown-option--). - scrollUntilVisible: element: id: 'product-store-dropdown-option-.*${STORE_NAME.toLowerCase().split(" ").join("-")}.*' direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - tapOn: id: 'product-store-dropdown-option-.*${STORE_NAME.toLowerCase().split(" ").join("-")}.*' - extendedWaitUntil: notVisible: id: 'product-store-dropdown-option-.*${STORE_NAME.toLowerCase().split(" ").join("-")}.*' timeout: 10000 - waitForAnimationToEnd - scrollUntilVisible: element: id: product-type-dropdown direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - assertVisible: id: product-type-dropdown - tapOn: id: product-type-dropdown - waitForAnimationToEnd # Value + label slug make ids like product-type-dropdown-option-item-item; # match with .* on both sides (id matching is full-string regex). - scrollUntilVisible: element: id: 'product-type-dropdown-option-.*${PRODUCT_TYPE}.*' direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - tapOn: id: 'product-type-dropdown-option-.*${PRODUCT_TYPE}.*' - extendedWaitUntil: notVisible: id: 'product-type-dropdown-option-.*${PRODUCT_TYPE}.*' timeout: 10000 - waitForAnimationToEnd # ---- variant 1 (base) ---- - scrollUntilVisible: element: id: variant-0-attr-0-value direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd # focus-guaranteed tap (validates the field really got focus) - runFlow: file: subflows/tap-and-focus.yaml env: FIELD_ID: variant-0-attr-0-value - eraseText - inputText: ${QUANTITY_1} - pressKey: Enter - scrollUntilVisible: element: id: variant-0-price direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd # focus-guaranteed tap (validates the field really got focus) - runFlow: file: subflows/tap-and-focus.yaml env: FIELD_ID: variant-0-price - eraseText - inputText: ${PRICE_1} - pressKey: Enter - scrollUntilVisible: element: id: variant-0-market-price direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd # focus-guaranteed tap (validates the field really got focus) - runFlow: file: subflows/tap-and-focus.yaml env: FIELD_ID: variant-0-market-price - eraseText - inputText: ${MARKET_PRICE_1} - pressKey: Enter # ---- combo items (PRODUCT_TYPE=combo only; rows live under variant 1) ---- # Each combo-add tap appends one row; each row's dropdown must be given a real # SKU (placeholder skuId 0 fails the backend). Option ids are # variant-0-combo-sku--option--; slug = lowercased label # with every non-alnum run collapsed to '-', so match with .* on both sides. - runFlow: when: true: ${PRODUCT_TYPE.toLowerCase() === "combo"} commands: - scrollUntilVisible: element: id: variant-0-combo-add direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - tapOn: id: variant-0-combo-add - waitForAnimationToEnd # slot 0 (COMBO_ITEM_0 is required for combos - assertTrue above) - tapOn: id: variant-0-combo-sku-0 - waitForAnimationToEnd - scrollUntilVisible: element: id: 'variant-0-combo-sku-0-option-.*${COMBO_ITEM_0.toLowerCase().split(".").join("-").split(" ").join("-")}.*' direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - tapOn: id: 'variant-0-combo-sku-0-option-.*${COMBO_ITEM_0.toLowerCase().split(".").join("-").split(" ").join("-")}.*' - extendedWaitUntil: notVisible: id: 'variant-0-combo-sku-0-option-.*${COMBO_ITEM_0.toLowerCase().split(".").join("-").split(" ").join("-")}.*' timeout: 10000 - waitForAnimationToEnd # slot 1 - runFlow: when: true: ${COMBO_ITEM_1 != ""} commands: - scrollUntilVisible: element: id: variant-0-combo-add direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - tapOn: id: variant-0-combo-add - waitForAnimationToEnd - tapOn: id: variant-0-combo-sku-1 - waitForAnimationToEnd - scrollUntilVisible: element: id: 'variant-0-combo-sku-1-option-.*${COMBO_ITEM_1.toLowerCase().split(".").join("-").split(" ").join("-")}.*' direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - tapOn: id: 'variant-0-combo-sku-1-option-.*${COMBO_ITEM_1.toLowerCase().split(".").join("-").split(" ").join("-")}.*' - extendedWaitUntil: notVisible: id: 'variant-0-combo-sku-1-option-.*${COMBO_ITEM_1.toLowerCase().split(".").join("-").split(" ").join("-")}.*' timeout: 10000 - waitForAnimationToEnd # slot 2 - runFlow: when: true: ${COMBO_ITEM_2 != ""} commands: - scrollUntilVisible: element: id: variant-0-combo-add direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - tapOn: id: variant-0-combo-add - waitForAnimationToEnd - tapOn: id: variant-0-combo-sku-2 - waitForAnimationToEnd - scrollUntilVisible: element: id: 'variant-0-combo-sku-2-option-.*${COMBO_ITEM_2.toLowerCase().split(".").join("-").split(" ").join("-")}.*' direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - tapOn: id: 'variant-0-combo-sku-2-option-.*${COMBO_ITEM_2.toLowerCase().split(".").join("-").split(" ").join("-")}.*' - extendedWaitUntil: notVisible: id: 'variant-0-combo-sku-2-option-.*${COMBO_ITEM_2.toLowerCase().split(".").join("-").split(" ").join("-")}.*' timeout: 10000 - waitForAnimationToEnd # ---- variant 2 (optional) ---- - runFlow: when: true: ${output.hasV2} commands: - scrollUntilVisible: element: id: add-variant-button-footer direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - tapOn: id: add-variant-button-footer - waitForAnimationToEnd - scrollUntilVisible: element: id: variant-1-attr-0-value direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd # focus-guaranteed tap (validates the field really got focus) - runFlow: file: subflows/tap-and-focus.yaml env: FIELD_ID: variant-1-attr-0-value - eraseText - inputText: ${QUANTITY_2} - pressKey: Enter - scrollUntilVisible: element: id: variant-1-price direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd # focus-guaranteed tap (validates the field really got focus) - runFlow: file: subflows/tap-and-focus.yaml env: FIELD_ID: variant-1-price - eraseText - inputText: ${PRICE_2} - pressKey: Enter - scrollUntilVisible: element: id: variant-1-market-price direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd # focus-guaranteed tap (validates the field really got focus) - runFlow: file: subflows/tap-and-focus.yaml env: FIELD_ID: variant-1-market-price - eraseText - inputText: ${MARKET_PRICE_2} - pressKey: Enter # ---- variant 3 (optional) -> Offer SKU ---- - runFlow: when: true: ${output.hasV3} commands: - scrollUntilVisible: element: id: add-variant-button-footer direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - tapOn: id: add-variant-button-footer - waitForAnimationToEnd - scrollUntilVisible: element: id: variant-2-attr-0-value direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd # focus-guaranteed tap (validates the field really got focus) - runFlow: file: subflows/tap-and-focus.yaml env: FIELD_ID: variant-2-attr-0-value - eraseText - inputText: ${QUANTITY_3} - pressKey: Enter - scrollUntilVisible: element: id: variant-2-price direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd # focus-guaranteed tap (validates the field really got focus) - runFlow: file: subflows/tap-and-focus.yaml env: FIELD_ID: variant-2-price - eraseText - inputText: ${PRICE_3} - pressKey: Enter - scrollUntilVisible: element: id: variant-2-market-price direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd # focus-guaranteed tap (validates the field really got focus) - runFlow: file: subflows/tap-and-focus.yaml env: FIELD_ID: variant-2-market-price - eraseText - inputText: ${MARKET_PRICE_3} - pressKey: Enter - scrollUntilVisible: element: id: variant-2-offer direction: DOWN speed: 100 visibilityPercentage: 60 - waitForAnimationToEnd - tapOn: id: variant-2-offer # centerElement dropped on purpose: with the button already visible it # re-nudges the scroll endlessly trying to center it. - scrollUntilVisible: element: id: create-product-button direction: DOWN speed: 100 visibilityPercentage: 100 - waitForAnimationToEnd - waitForAnimationToEnd - assertVisible: id: create-product-button - tapOn: id: create-product-button - assertVisible: 'Product created successfully!' - tapOn: OK