Skip to content

Commit

Permalink
add test for clicking like on a proposal comment
Browse files Browse the repository at this point in the history
  • Loading branch information
petersalomonsen committed Oct 12, 2024
1 parent bbfb154 commit 41c04e2
Showing 1 changed file with 53 additions and 6 deletions.
59 changes: 53 additions & 6 deletions playwright-tests/tests/proposal/comment.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { test as base, expect } from "@playwright/test";
import { test } from "../../util/multiinstance.js";

import { expect } from "@playwright/test";
import { pauseIfVideoRecording } from "../../testUtils.js";
import { setCommitWritePermissionDontAskAgainCacheValues } from "../../util/cache.js";
import {
Expand All @@ -7,11 +9,56 @@ import {
encodeResultJSON,
} from "../../util/transaction.js";

const test = base.extend({
// Define an option and provide a default value.
// We can later override it in the config.
account: ["devhub.near", { option: true }],
proposalAuthorAccountId: ["megha19.near", { option: true }],
test.describe("Wallet connected", () => {
test.use({
contextOptions: {
permissions: ["clipboard-read", "clipboard-write"],
},
storageState: "playwright-tests/storage-states/wallet-connected.json",
});
test("should like a proposal comment", async ({
page,
account: instanceAccount,
linksTestProposalId,
linksTestCommentAuthorId,
linksTestCommentBlockHeight,
}) => {
await page.goto(
`/${instanceAccount}/widget/app?page=proposal&id=${linksTestProposalId}&accountId=${linksTestCommentAuthorId}&blockHeight=${linksTestCommentBlockHeight}`
);
const viewer = await page.locator("near-social-viewer");
const commentElement = await viewer.locator(
`css=div#${linksTestCommentAuthorId.replaceAll(
/[^0-9a-z]/g,
""
)}${linksTestCommentBlockHeight}`
);
await expect(commentElement).toBeVisible({ timeout: 20000 });
await page
.locator(
`#${linksTestCommentAuthorId.replaceAll(
/[^0-9a-z]/g,
""
)}${linksTestCommentBlockHeight}`
)
.locator(`button[title="Like"]`)
.click();
await page.waitForTimeout(2000);

const transactionObject = JSON.parse(
await page.locator("div.modal-body code").innerText()
);
const expectedTransactionObject = {
"efiz.near": {
index: {
like: `{\"key\":{\"type\":\"social\",\"path\":\"${linksTestCommentAuthorId}/post/comment\",\"blockHeight\":${linksTestCommentBlockHeight}},\"value\":{\"type\":\"like\"}}`,
notify: `{\"key\":\"${linksTestCommentAuthorId}\",\"value\":{\"type\":\"like\",\"item\":{\"type\":\"social\",\"path\":\"${linksTestCommentAuthorId}/post/comment\",\"blockHeight\":${linksTestCommentBlockHeight}}}}`,
},
},
};
await expect(transactionObject).toEqual(expectedTransactionObject);
await pauseIfVideoRecording(page);
});
});

test.describe("Don't ask again enabled", () => {
Expand Down

0 comments on commit 41c04e2

Please sign in to comment.