Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/near/neardevhub-widgets int…
Browse files Browse the repository at this point in the history
…o patch/285-solution-posts
  • Loading branch information
carina-akaia committed Oct 31, 2023
2 parents af739d1 + c595326 commit 8f6438f
Show file tree
Hide file tree
Showing 16 changed files with 1,178 additions and 37 deletions.
17 changes: 12 additions & 5 deletions docs/how-we-work.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,15 @@ Note: We expect you to complete your ticket within the number of days you commit

Notes: We may reassign issues that are not in progress yet. So it is important to indicate once you start working on it.

### 3. **Implement tests**

### 3. **Update Tickets**
1. As part of every development work, there should be tests that cover the functionality you have made, or the bug you have fixed
2. Implement tests to ensure that other developers will be warned if they break your code by accident
3. Also use tests to speed up your own development workflow. Writing tests during implementation should reduce the code-test iteration loop time.
4. Help the Pull Request reviewer, your tests should clearly describe what you have implemented. The better the test coverage, the better are the chances of getting your PR approved.
5. For more information about writing tests look into the [contribution guidelines](https://github.com/near/neardevhub-widgets/blob/main/CONTRIBUTING.md#writing-tests)

### 4. **Update Tickets**

1. If your ticket blocked:
1. Identify blocker: Add a comment specifying the blocker, what actions you have already taken to understand and mitigate the problem, and tag the appropriate people and specify what you need. Move the ticket to the blocked column.
Expand All @@ -98,24 +105,24 @@ Notes: We may reassign issues that are not in progress yet. So it is important t
c. Add a daily comment to the ticket to indicate your progress.


### 4. **Request Review**
### 5. **Request Review**

1. Deploy a preview version, see how to deploy a preview version below. Once you completed your work, and provide the link in the PR description.
2. Test the preview version to ensure everything works and meets the acceptance criteria
3. Change the PR from draft to “ready for review”

### 5. **Review**
### 6. **Review**

1. Another team member should review your work within one day. If you do not get a response, escalate on our Telegram channel.
2. For reviewers: If there are no reviews by the end of your work day, please leave your review.
3. We require one code owner review, and in the case the reviewer has questions about the UI/UX, a review from the PM, to approve the pull request.

### 6. **Address Review**
### 7. **Address Review**
1. Address any new review comments within 2 business days
2. Respond to each comment by either following the suggestion or providing a rationale for disagreement.
3. Request further review from the same reviewer.

### 7. **Completion**
### 8. **Completion**

1. If the PR is approved, a DevHub Tech Lead squash and merge the PR and the issue is considered done.
2. Move the issue to the “Done” column in our project board
Expand Down
124 changes: 124 additions & 0 deletions playwright-tests/tests/addons.spec.js
Original file line number Diff line number Diff line change
@@ -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');
// });
// });

// });
1 change: 1 addition & 0 deletions playwright-tests/tests/search.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
48 changes: 24 additions & 24 deletions src/core/adapter/devhub-contract.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
99 changes: 99 additions & 0 deletions src/devhub/components/molecule/Input.jsx
Original file line number Diff line number Diff line change
@@ -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 ? (
<span className="d-inline-flex gap-1 text-wrap">
<span>{label}</span>

{inputProps.required ? <span className="text-danger">*</span> : null}
</span>
) : null,

format === "markdown" ? (
<i class="bi bi-markdown text-muted" title="Markdown" />
) : null,

format === "comma-separated" ? (
<span
className="d-inline-flex align-items-center text-muted"
style={{ fontSize: 12 }}
>
{format}
</span>
) : null,

(inputProps.max ?? null) !== null ? (
<span className="d-inline-flex text-muted" style={{ fontSize: 12 }}>{`${
value?.length ?? 0
} / ${inputProps.max}`}</span>
) : null,
].filter((label) => label !== null);

return (
<div
className={[
"d-flex flex-column flex-1 align-items-start justify-content-evenly",
skipPaddingGap ? "" : "gap-1 p-2",
className ?? "",
].join(" ")}
style={style}
{...otherProps}
>
{renderedLabels.length > 0 ? (
<span
className="d-flex justify-content-between align-items-center gap-3 w-100"
id={key}
>
{renderedLabels.map((label) => label)}
</span>
) : null}

{!multiline ? (
<div className="input-group">
{inputProps.prefix && (
<span className="input-group-text">{inputProps.prefix}</span>
)}
<input
aria-describedby={key}
aria-label={label}
className={["form-control border border-2", inputClassName].join(
" "
)}
type={typeAttribute}
{...{ onChange, placeholder, value, ...inputProps }}
/>
</div>
) : (
<textarea
aria-describedby={key}
aria-label={label}
className={["form-control border border-2", inputClassName].join(" ")}
placeholder={
placeholder + (inputProps.required ? " ( required )" : "")
}
style={{ resize: inputProps.resize ?? "vertical" }}
type={typeAttribute}
{...{ onChange, placeholder, value, ...inputProps }}
/>
)}
</div>
);
};

return TextInput(props);
1 change: 0 additions & 1 deletion src/devhub/components/templates/AppLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ const AppHeader = ({ page }) => {
};

function AppLayout({ page, children }) {
console.log("page", page);
return (
<Container>
<AppHeader page={page} />
Expand Down
Loading

0 comments on commit 8f6438f

Please sign in to comment.