Skip to content

Commit

Permalink
added back activity page
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 committed Jan 23, 2024
1 parent c103cab commit 2198a71
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 0 deletions.
68 changes: 68 additions & 0 deletions playwright-tests/tests/community.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,74 @@ test("should load an error page if handle does not exist", async ({ page }) => {
expect(communityNotFound).not.toBeNull();
});

test.describe("Wallet is connected", () => {
test.use({
storageState: "playwright-tests/storage-states/wallet-connected.json",
});

test("should allow connected user to post from community page", async ({
page,
}) => {
await page.goto(
"/devhub.near/widget/app?page=community&handle=devhub-test&tab=activity"
);

const postButtonSelector = 'a:has-text("Post")';

await page.waitForSelector(postButtonSelector, {
state: "visible",
});

// Click the Post button and wait for the load state to be 'networkidle'
await Promise.all([
page.click(postButtonSelector),
page.waitForLoadState("networkidle"),
]);

// Verify that the URL is the expected one.
expect(page.url()).toBe(
"http://localhost:8080/devhub.near/widget/app?page=create&labels=devhub-test"
);

// Wait for the Typeahead field to render.
const typeaheadSelector = ".rbt-input-main";
await page.waitForSelector(typeaheadSelector, { state: "visible" });

const typeaheadValueSelector = ".rbt-token-label";

// Wait for prepoluated label to appear.
await page.waitForSelector(typeaheadValueSelector, { state: "visible" });

// Fetch the element and its text content.
const element = await page.$(typeaheadValueSelector);
const elementText = await element.textContent();

expect(element).toBeTruthy();
expect(elementText).toBe("devhub-test");
});
});

test.describe("Wallet is not connected", () => {
test.use({
storageState: "playwright-tests/storage-states/wallet-not-connected.json",
});

test("should not allow unconnected user to post from community page", async ({
page,
}) => {
await page.goto(
"/devhub.near/widget/app?page=community&handle=devhub-test"
);

const createCommunityButtonSelector = 'button:has-text("Post")';

await page.waitForSelector(createCommunityButtonSelector, {
state: "detached",
});
});
});


test.describe("Is community admin", () => {
test.use({
storageState:
Expand Down
79 changes: 79 additions & 0 deletions src/devhub/entity/community/Activity.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const { handle } = props;

const { getCommunity } = VM.require(
"${REPL_DEVHUB}/widget/core.adapter.devhub-contract"
);

const { href } = VM.require("${REPL_DEVHUB}/widget/core.lib.url");

if (!getCommunity || !href) {
return <p>Loading modules...</p>;
}

// TODO: Why do we need to get community data again? Isn't the tag the handle...
const communityData = getCommunity({ handle });

if (communityData === null) {
return <div>Loading...</div>;
}

const MainContent = styled.div`
flex-grow: 1;
max-width: 75%;
@media screen and (max-width: 960px) {
max-width: 100%;
}
`;

const SidebarContainer = styled.div`
max-width: 25%;
margin-right: 1.5rem;
@media screen and (max-width: 960px) {
display: none;
}
`;

return (
<div style={{ maxWidth: "100%", width: "100%" }}>
<div class="col">
<div class="d-flex w-100">
<MainContent>
<Widget
src={"${REPL_DEVHUB}/widget/devhub.feature.post-search.panel"}
props={{
hideHeader: true,
tag: communityData.tag,
children: (
<Widget
src={
"${REPL_DEVHUB}/widget/devhub.components.molecule.PostControls"
}
props={{
title: "Post",
href: href({
widgetSrc: "${REPL_DEVHUB}/widget/app",
params: {
page: "create",
labels: [communityData.tag],
},
}),
}}
/>
),
recency,
transactionHashes: props.transactionHashes,
}}
/>
</MainContent>
<SidebarContainer>
<Widget
src={"${REPL_DEVHUB}/widget/devhub.entity.community.Sidebar"}
props={{ community: communityData }}
/>
</SidebarContainer>
</div>
</div>
</div>
);
7 changes: 7 additions & 0 deletions src/devhub/page/community/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ const tabs = [
handle: community.handle,
},
},
{
title: "Activity",
view: "${REPL_DEVHUB}/widget/devhub.entity.community.Activity",
params: {
handle: community.handle,
},
},
{
title: "Teams",
view: "${REPL_DEVHUB}/widget/devhub.entity.community.Teams",
Expand Down

0 comments on commit 2198a71

Please sign in to comment.