Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Tguntenaar/neardevhub-widgets into …
Browse files Browse the repository at this point in the history
…feature/events-bos-ws
  • Loading branch information
Tguntenaar committed Jul 15, 2024
2 parents 2ea4b88 + acc6579 commit cb2b892
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 17 deletions.
3 changes: 1 addition & 2 deletions instances/devhub.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
"REPL_EFIZ": "efiz.near",
"REPL_DEVS": "devs.near",
"REPL_SOCIAL_CONTRACT": "social.near",
"REPL_RPC_URL": "https://rpc.mainnet.near.org",
"REPL_TERMS_AND_CONDITION_BLOCKHEIGHT": "122927956"
"REPL_RPC_URL": "https://rpc.mainnet.near.org"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ State.init({
message: props.data,
});

const profilesData = Social.get("*/profile/name", "final");
const followingData = Social.get(
`${context.accountId}/graph/follow/**`,
"final"
);
const profilesData = Social.get("*/profile/name", "final") ?? {};
const followingData =
Social.get(`${context.accountId}/graph/follow/**`, "final") ?? {};

// SIMPLEMDE CONFIG //
const fontFamily = props.fontFamily ?? "sans-serif";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ fetchGraphQL(query, "GetLatestSnapshot", variables).then(async (result) => {
if (result.status === 200) {
if (result.body.data) {
const data = result.body.data?.[queryName];
console.log(data);
State.update({ proposalBlockHeight: data[0].block_height });
}
}
});

let acceptedTermsVersion = "${REPL_TERMS_AND_CONDITION_BLOCKHEIGHT}";
let acceptedTermsVersion = Near.block().header.height;

if (state.proposalBlockHeight !== null) {
const data = fetch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ const onSubmit = ({ isDraft, isCancel }) => {
status: "CANCELLED",
sponsor_requested_review: false,
reviewer_completed_attestation: false,
kyc_verified: false,
}
: isDraft
? { status: "DRAFT" }
Expand All @@ -750,7 +751,7 @@ const onSubmit = ({ isDraft, isCancel }) => {
args["id"] = editProposalData.id;
} else {
args["accepted_terms_and_conditions_version"] = parseInt(
"${REPL_TERMS_AND_CONDITION_BLOCKHEIGHT}"
Near.block().header.height
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ const proposalStatusOptions = [
status: TIMELINE_STATUS.REJECTED,
sponsor_requested_review: true,
reviewer_completed_attestation: false,
kyc_verified: true,
},
},
{
Expand All @@ -384,6 +385,7 @@ const proposalStatusOptions = [
status: TIMELINE_STATUS.CANCELED,
sponsor_requested_review: false,
reviewer_completed_attestation: false,
kyc_verified: true,
},
},
{
Expand Down
35 changes: 28 additions & 7 deletions playwright-tests/tests/proposal/proposals.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ test.afterEach(
async ({ page }) => await page.unrouteAll({ behavior: "ignoreErrors" })
);

let acceptedTermsVersion = 122927956;
async function getCurrentBlockHeight(page) {
// set current block height for accepted terms and conditions
await page.route(`http://localhost:20000/`, async (route) => {
const request = route.request();
const requestPostData = request.postDataJSON();
if (
requestPostData?.method === "block" &&
requestPostData?.params?.finality === "optimistic"
) {
const response = await route.fetch();
const json = await response.json();
json.result.header.height = acceptedTermsVersion;
await route.fulfill({ response, json });
} else {
await route.continue();
}
});
}

test.describe("Wallet is connected, but not KYC verified", () => {
test.use({
storageState:
Expand Down Expand Up @@ -397,8 +417,8 @@ test.describe("Wallet is connected", () => {
account,
}) => {
test.setTimeout(120000);
await getCurrentBlockHeight(page);
await page.goto(`/${account}/widget/app?page=create-proposal`);

const delay_milliseconds_between_keypress_when_typing = 0;
const titleArea = await page.getByRole("textbox").first();
await expect(titleArea).toBeEditable();
Expand Down Expand Up @@ -478,7 +498,7 @@ test.describe("Wallet is connected", () => {
null,
1
);
await expect(transactionText).toEqual(
expect(transactionText).toEqual(
JSON.stringify(
{
labels: [],
Expand All @@ -499,7 +519,7 @@ test.describe("Wallet is connected", () => {
status: "DRAFT",
},
},
accepted_terms_and_conditions_version: 122927956,
accepted_terms_and_conditions_version: acceptedTermsVersion,
},
null,
1
Expand Down Expand Up @@ -597,6 +617,7 @@ test.describe("Wallet is connected", () => {
account,
}) => {
test.setTimeout(120000);
await getCurrentBlockHeight(page);
await page.goto(`/${account}/widget/app?page=create-proposal`);

const delay_milliseconds_between_keypress_when_typing = 0;
Expand Down Expand Up @@ -629,12 +650,12 @@ test.describe("Wallet is connected", () => {
.locator(".CodeMirror textarea");
await descriptionArea.focus();
await descriptionArea.pressSequentially(
`The test proposal description. And referencing #2`,
`The test proposal description. And referencing #`,
{
delay: delay_milliseconds_between_keypress_when_typing,
}
);

await descriptionArea.pressSequentially("2", { delay: 10 });
await pauseIfVideoRecording(page);

await page
Expand Down Expand Up @@ -686,7 +707,7 @@ test.describe("Wallet is connected", () => {
status: "DRAFT",
},
},
accepted_terms_and_conditions_version: 122927956,
accepted_terms_and_conditions_version: acceptedTermsVersion,
},
null,
1
Expand Down Expand Up @@ -757,4 +778,4 @@ test.describe("Wallet is connected", () => {
await expect(element).toBeVisible();
});
});
});
});

0 comments on commit cb2b892

Please sign in to comment.