Skip to content

Commit

Permalink
working test
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed Jan 17, 2024
1 parent 19c57ec commit 1aad90e
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 35 deletions.
4 changes: 2 additions & 2 deletions playwright-tests/tests/admin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ test.describe("Wallet is connected", () => {
await page.goto("/devhub.near/widget/app?page=admin");

const buttonSelector = `button[data-testid="preview-homepage"]`;
// Wait for the first post history button to be visible
// Wait for the preview homepage to appear
await page.waitForSelector(buttonSelector, {
state: "visible",
});

// Click on the first post history button
// Click on Community handle input
await page.getByPlaceholder("Community handle").nth(4).click();
await page
.getByPlaceholder("Community handle")
Expand Down
15 changes: 8 additions & 7 deletions playwright-tests/tests/announcements.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,20 @@ test.describe("Admin wallet is connected", () => {
await page.goto(
"/devhub.near/widget/app?page=community&handle=devhub-test"
);
// card class div is only visible when there is a post
const postsDivSelector = `div[class="card"]`;
await page.waitForSelector(postsDivSelector, {
state: "visible",
});
const postLocator = page.locator(".post");
await postLocator.focus();
});

test("a comment shows on post in feed", async ({ page }) => {

// SKIPPING
test.skip("a comment shows on post in feed", async ({ page }) => {
// This test needs to be revisited if we modify the post / comment
// At this time comments occur within "near" accountId's widgets with no discernable traits for testing
await page.goto(
"/devhub.near/widget/app?page=community&handle=devhub-test"
);
// only comments have a row class
const commentsDivSelector = `div[class="row"]`;
const commentsDivSelector = `i[class="bi-chat"]`;
await page.waitForSelector(commentsDivSelector, {
state: "visible",
});
Expand Down
6 changes: 2 additions & 4 deletions playwright-tests/tests/blog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ test("should prepopulate the form when a blog is selected from the left", async
});

test("should have an empty form if select new blog", async ({ page }) => {
await page.goto(
"/devgovgigs.near/widget/devhub.entity.addon.blog.Configurator"
);
await page.goto("/devhub.near/widget/devhub.entity.addon.blog.Configurator");

const newBlogSelector = `[id^="create-new-blog"]`;
await page.waitForSelector(newBlogSelector, {
Expand Down Expand Up @@ -95,7 +93,7 @@ test("should load a blog page and its blogs for a given community handle", async
page,
}) => {
await page.goto(
"/devgovgigs.near/widget/devhub.entity.addon.blog.Viewer?handle=devhub-test"
"/devhub.near/widget/devhub.entity.addon.blog.Viewer?handle=devhub-test"
);

const blogCardSelector = '[id^="blog-card-"]';
Expand Down
7 changes: 2 additions & 5 deletions playwright-tests/tests/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ test.describe("Wallet is connected", () => {

await page.click('button:has-text("Solution")');

await setInputAndAssert(
page,
'input[data-testid="name-editor"]',
"The test title"
);
await page.getByTestId("name-editor").fill("The test title");

const descriptionInput = page
.frameLocator("iframe")
Expand All @@ -61,6 +57,7 @@ test.describe("Wallet is connected", () => {
'input[data-testid="requested-amount-editor"]',
"300"
);
await page.getByTestId("requested-amount-editor").fill("300");
await page.click('button:has-text("Submit")');
await expect(page.locator("div.modal-body code")).toHaveText(
JSON.stringify(
Expand Down
6 changes: 6 additions & 0 deletions playwright-tests/tests/funding.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test.describe("Wallet is connected", () => {
});

test("should be able to submit a solution (funding request)", async ({
//
page,
}) => {
await page.goto("/devhub.near/widget/app?page=create");
Expand All @@ -31,6 +32,11 @@ test.describe("Wallet is connected", () => {

await page.click('label:has-text("Yes") button');
await selectAndAssert(page, 'div:has-text("Currency") select', "USDT");
await setInputAndAssert(
page,
'input[data-testid="requested-amount-editor"]',
"300"
);
await page.getByTestId("requested-amount-editor").fill("300");

await page.click('button:has-text("Submit")');
Expand Down
17 changes: 6 additions & 11 deletions src/core/adapter/devhub-contract.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
function getRootMembers() {
return Near.view("${REPL_DEVHUB_CONTRACT}", "get_root_members") ?? null;
return Near.view("${REPL_DEVHUB_LEGACY}", "get_root_members") ?? null;
}

function removeMember(member) {
return Near.call("${REPL_DEVHUB_CONTRACT}", "remove_member", { member });
return Near.call("${REPL_DEVHUB_LEGACY}", "remove_member", { member });
}

function hasModerator({ account_id }) {
return (
Near.view("${REPL_DEVHUB_CONTRACT}", "has_moderator", { account_id }) ??
null
Near.view("${REPL_DEVHUB_LEGACY}", "has_moderator", { account_id }) ?? null
);
}

Expand All @@ -30,9 +29,7 @@ function getCommunity({ handle }) {
}

function getFeaturedCommunities() {
return (
Near.view("${REPL_DEVHUB_CONTRACT}", "get_featured_communities") ?? null
);
return Near.view("${REPL_DEVHUB_LEGACY}", "get_featured_communities") ?? null;
}

function setFeaturedCommunities({ handles }) {
Expand Down Expand Up @@ -89,13 +86,11 @@ function getAllAddons() {
}

function getAccessControlInfo() {
return (
Near.view("${REPL_DEVHUB_CONTRACT}", "get_access_control_info") ?? null
);
return Near.view("${REPL_DEVHUB_LEGACY}", "get_access_control_info") ?? null;
}

function getAllAuthors() {
return Near.view("${REPL_DEVHUB_CONTRACT}", "get_all_authors") ?? null;
return Near.view("${REPL_DEVHUB_LEGACY}", "get_all_authors") ?? null;
}

function getAllCommunitiesMetadata() {
Expand Down
1 change: 1 addition & 0 deletions src/devhub/components/organism/Feed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ return (
props={{
accountId: item.accountId,
blockHeight: item.blockHeight,
filteredAccountIds: filteredAccountIds,
}}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions src/devhub/entity/post/Post.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const searchKeywords = props.searchKeywords ? (

const allowedToEdit =
!props.isPreview &&
Near.view("${REPL_DEVHUB_CONTRACT}", "is_allowed_to_edit", {
Near.view("${REPL_DEVHUB_LEGACY}", "is_allowed_to_edit", {
post_id: postId,
editor: context.accountId,
});
Expand Down Expand Up @@ -270,7 +270,7 @@ let grantNotify = Near.view(
"${REPL_SOCIAL_CONTRACT}",
"is_write_permission_granted",
{
predecessor_id: "${REPL_DEVHUB_CONTRACT}",
predecessor_id: "${REPL_DEVHUB_LEGACY}",
key: context.accountId + "/index/notify",
}
);
Expand Down
4 changes: 2 additions & 2 deletions src/devhub/entity/post/PostEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ let grantNotify = Near.view(
"${REPL_SOCIAL_CONTRACT}",
"is_write_permission_granted",
{
predecessor_id: "${REPL_DEVHUB_CONTRACT}",
predecessor_id: "${REPL_DEVHUB_LEGACY}",
key: context.accountId + "/index/notify",
}
);
Expand Down Expand Up @@ -387,7 +387,7 @@ const onSubmit = () => {
};

const checkLabel = (label) => {
Near.asyncView("${REPL_DEVHUB_CONTRACT}", "is_allowed_to_use_labels", {
Near.asyncView("${REPL_DEVHUB_LEGACY}", "is_allowed_to_use_labels", {
editor: context.accountId,
labels: [label],
}).then((allowed) => {
Expand Down
4 changes: 2 additions & 2 deletions src/devhub/page/admin/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function createEditTeam({
if (!membersAndTeams.includes(member)) {
// Add member
txn.push({
contractName: "${REPL_DEVHUB_CONTRACT}",
contractName: "${REPL_DEVHUB_LEGACY}",
methodName: "add_member",
args: {
member: member,
Expand All @@ -79,7 +79,7 @@ function createEditTeam({
Near.call([
...txn,
{
contractName: "${REPL_DEVHUB_CONTRACT}",
contractName: "${REPL_DEVHUB_LEGACY}",
methodName: contractCall, // add_member || edit_member
args: {
member: `team:${teamName}`,
Expand Down

0 comments on commit 1aad90e

Please sign in to comment.