diff --git a/playwright-tests/tests/addons.spec.js b/playwright-tests/tests/addons.spec.js new file mode 100644 index 000000000..f740f1dc5 --- /dev/null +++ b/playwright-tests/tests/addons.spec.js @@ -0,0 +1,124 @@ +const { test, expect } = require("@playwright/test"); + +test.describe("Wallet is connected", () => { + test.use({ + storageState: "playwright-tests/storage-states/wallet-connected.json", + }); + + test.describe("AddonsConfigurator", () => { + const baseUrl = + "/devgovgigs.near/widget/app?page=community.configuration&handle=devhub-test"; + // const dropdownSelector = + // 'input[data-component="near/widget/DIG.InputSelect"]'; + // const addButtonSelector = "button.btn-success:has(i.bi.bi-plus)"; + // const toggleButtonSelector = 'button[role="switch"]'; + // const moveUpButtonSelector = "button.btn-secondary:has(i.bi.bi-arrow-up)"; + // const removeButtonSelector = + // "button.btn-outline-danger:has(i.bi.bi-trash-fill)"; + + test("Addons configuration section comes up on load", async ({ page }) => { + await page.goto(baseUrl); + + const addonsConfiguratorSelector = 'span:has-text("Add-Ons")'; + + await page.waitForSelector(addonsConfiguratorSelector, { + state: "visible", + }); + }); + }); +}); + +// NOTE: +// The below tests need some more work. +// We are using the DIG component, which is essentially a Radix Select field. +// Radix select renders as an input and requires to be focused, then value inputted, before the option can be selected. +// I was having trouble making this work. + +// test('Can add an addon to the list', async ({ page }) => { +// await page.goto(baseUrl); + +// await page.click(dropdownSelector); +// await page.fill(dropdownSelector, 'Wiki'); +// await page.click(`li:has-text('Wiki')`); + +// await page.waitForSelector(addButtonSelector, { +// state: "visible", +// }); + +// await page.click(addButtonSelector); + +// const addedAddon = await page.$('input[type="text"].form-control[disabled][value="Wiki"]'); // You will need to fill this in +// expect(addedAddon).toBeTruthy(); +// }); + +// test('Can reorder addons in the list', async ({ page }) => { +// await page.goto(baseUrl); + +// await page.click(dropdownSelector); +// await page.inputValue(dropdownSelector, 'Wiki'); +// await page.click(`li:has-text('Wiki')`); + +// await page.waitForSelector(addButtonSelector, { +// state: "visible", +// }); + +// await page.click(addButtonSelector); + +// await page.inputValue(dropdownSelector, 'telegram'); +// await page.click(addButtonSelector); + +// await page.waitForSelector(moveUpButtonSelector, { +// state: "visible", +// }); + +// await page.click(moveUpButtonSelector); + +// const firstAddon = await page.$('input[type="text"].form-control[disabled][value="Telegram"]'); +// const secondAddon = await page.$('input[type="text"].form-control[disabled][value="Wiki"]'); +// expect(firstAddon).toBeTruthy(); +// expect(secondAddon).toBeTruthy(); +// }); + +// test('Can remove an addon from the list', async ({ page }) => { +// await page.goto(baseUrl); + +// await page.inputValue(dropdownSelector, 'Wiki'); + +// await page.waitForSelector(addButtonSelector, { +// state: "visible", +// }); + +// await page.click(addButtonSelector); + +// await page.waitForSelector(removeButtonSelector, { +// state: "visible", +// }); + +// await page.click(removeButtonSelector); + +// const removedAddon = await page.$('input[type="text"].form-control[disabled][value="Wiki"]'); // You will need to fill this in +// expect(removedAddon).toBeNull(); +// }); + +// test('Can toggle to disable an addon', async ({ page }) => { +// await page.goto(baseUrl); + +// await page.inputValue(dropdownSelector, 'Wiki'); +// await page.waitForSelector(addButtonSelector, { +// state: "visible", +// }); + +// await page.click(addButtonSelector); + +// await page.waitForSelector(toggleButtonSelector, { +// state: "visible", +// }); + +// await page.click(toggleButtonSelector); + +// const toggleState = await page.getAttribute(toggleButtonSelector, 'aria-checked'); +// expect(toggleState).toBe('false'); +// }); +// }); + +// }); diff --git a/playwright-tests/tests/search.spec.js b/playwright-tests/tests/search.spec.js index 8e6cc5bf2..be967b90c 100644 --- a/playwright-tests/tests/search.spec.js +++ b/playwright-tests/tests/search.spec.js @@ -9,6 +9,7 @@ test("should show post history for posts in the feed", async ({ page }) => { state: "visible", }); await searchInput.fill("zero knowledge"); + await searchInput.press("Enter"); await page.waitForSelector('span:has-text("zero knowledge")', { state: "visible", diff --git a/src/core/adapter/devhub-contract.jsx b/src/core/adapter/devhub-contract.jsx index eb74d0f13..fbbac46d9 100644 --- a/src/core/adapter/devhub-contract.jsx +++ b/src/core/adapter/devhub-contract.jsx @@ -113,30 +113,30 @@ function getAvailableAddons() { configurator_widget: "${REPL_DEVHUB}/widget/devhub.entity.addon.telegram.Configurator", }, - { - id: "github", - title: "Github", - description: "Connect your github", - view_widget: "${REPL_DEVHUB}/widget/devhub.entity.addon.github.Viewer", - configurator_widget: - "${REPL_DEVHUB}/widget/devhub.entity.addon.github.Configurator", - }, - { - id: "kanban", - title: "Kanban", - description: "Connect your github kanban board", - view_widget: "${REPL_DEVHUB}/widget/devhub.entity.addon.kanban.Viewer", - configurator_widget: - "${REPL_DEVHUB}/widget/devhub.entity.addon.kanban.Configurator", - }, - { - id: "blog", - title: "Blog", - description: "Create a blog for your community", - view_widget: "${REPL_DEVHUB}/widget/devhub.entity.addon.blog.Viewer", - configurator_widget: - "${REPL_DEVHUB}/widget/devhub.entity.addon.blog.Configurator", - }, + // { + // id: "github", + // title: "Github", + // description: "Connect your github", + // view_widget: "${REPL_DEVHUB}/widget/devhub.entity.addon.github.Viewer", + // configurator_widget: + // "${REPL_DEVHUB}/widget/devhub.entity.addon.github.Configurator", + // }, + // { + // id: "kanban", + // title: "Kanban", + // description: "Connect your github kanban board", + // view_widget: "${REPL_DEVHUB}/widget/devhub.entity.addon.kanban.Viewer", + // configurator_widget: + // "${REPL_DEVHUB}/widget/devhub.entity.addon.kanban.Configurator", + // }, + // { + // id: "blog", + // title: "Blog", + // description: "Create a blog for your community", + // view_widget: "${REPL_DEVHUB}/widget/devhub.entity.addon.blog.Viewer", + // configurator_widget: + // "${REPL_DEVHUB}/widget/devhub.entity.addon.blog.Configurator", + // }, ]; // return Near.view("${REPL_DEVHUB_CONTRACT}", "get_available_addons") ?? null; } diff --git a/src/devhub/components/molecule/Input.jsx b/src/devhub/components/molecule/Input.jsx new file mode 100644 index 000000000..69b27c7e2 --- /dev/null +++ b/src/devhub/components/molecule/Input.jsx @@ -0,0 +1,99 @@ +const TextInput = ({ + className, + format, + inputProps: { className: inputClassName, ...inputProps }, + key, + label, + multiline, + onChange, + placeholder, + type, + value, + skipPaddingGap, + style, + ...otherProps +}) => { + const typeAttribute = + type === "text" || type === "password" || type === "number" ? type : "text"; + + const renderedLabels = [ + (label?.length ?? 0) > 0 ? ( + + {label} + + {inputProps.required ? * : null} + + ) : null, + + format === "markdown" ? ( + + ) : null, + + format === "comma-separated" ? ( + + {format} + + ) : null, + + (inputProps.max ?? null) !== null ? ( + {`${ + value?.length ?? 0 + } / ${inputProps.max}`} + ) : null, + ].filter((label) => label !== null); + + return ( +
+ {renderedLabels.length > 0 ? ( + + {renderedLabels.map((label) => label)} + + ) : null} + + {!multiline ? ( +
+ {inputProps.prefix && ( + {inputProps.prefix} + )} + +
+ ) : ( +