Skip to content

Commit

Permalink
fix(events/infrastructure): see the proposal you submit, and not anot…
Browse files Browse the repository at this point in the history
…her (#945)

* fix(events): see the proposal you submit, and not another

apply similar fix from devhub to events
enable all proposal tests for events committee

* editing proposal lag test working for events-committee

* split out proposal tests that currently only work on devhub

* adjust create proposal test for infrastructure committee
fix bug for infrastructure committee

* fix test for infrastructure-committee: edit proposal timeline from review to decision

* fix test for infra: should not be able to move proposal timeline to decision stage without approving KYC in review stage

* fix test for infra: editing proposal should not be laggy

* run generic proposal test in infrastructure committee

* move devhub specific proposal tests into "other"

* events proposal test mock must return the same title and description as the submitted proposal

* adjust testmatch for infrastructure, so that it only runs generic proposal tests and infrastructure-committee specific tests
  • Loading branch information
petersalomonsen authored Oct 7, 2024
1 parent c9d5ea4 commit 6330078
Show file tree
Hide file tree
Showing 11 changed files with 551 additions and 352 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/continuous-integration-workflow-events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ jobs:
npx playwright install
- name: Run tests
run: |
# The whole proposal folder does not work yet
# INSTANCE=events npx playwright test --project=events playwright-tests/tests/proposal
INSTANCE=events npx playwright test --project=events playwright-tests/tests/proposal/comment.spec.js
INSTANCE=events npx playwright test --project=events playwright-tests/tests/proposal/links.spec.js
INSTANCE=events npx playwright test --project=events playwright-tests/tests/proposal
playwright-tests-events:
name: Events Committee - Playwright tests
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/continuous-integration-workflow-infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ jobs:
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/mpeterdev/bos-loader/releases/download/v0.7.1/bos-loader-v0.7.1-installer.sh | sh
npx playwright install-deps
npx playwright install
- name: Run tests
- name: Run infrastructure specific tests
run: |
INSTANCE=infrastructure npx playwright test --project=infrastructure playwright-tests/tests/infrastructure
- name: Run generic proposal tests
run: |
INSTANCE=infrastructure npx playwright test --project=infrastructure playwright-tests/tests/proposal
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
test-results
build
instances/**/src/**
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,23 @@ useEffect(() => {
Array.isArray(proposalIdsArray) &&
proposalIds.length !== proposalIdsArray.length
) {
setCreateTxn(false);
setProposalId(proposalIds[proposalIds.length - 1]);
setShowProposalPage(true);
const latestProposalId = proposalIds[proposalIds.length - 1];
const latestProposal = Near.view(
"${REPL_DEVHUB_CONTRACT}",
"get_proposal",
{
proposal_id: latestProposalId,
}
);

if (
latestProposal.snapshot.name === title &&
latestProposal.snapshot.description === description
) {
setCreateTxn(false);
setProposalId(proposalIds[proposalIds.length - 1]);
setShowProposalPage(true);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,23 @@ useEffect(() => {
Array.isArray(proposalIdsArray) &&
proposalIds.length !== proposalIdsArray.length
) {
setCreateTxn(false);
setProposalId(proposalIds[proposalIds.length - 1]);
setShowProposalViewModal(true);
const latestProposalId = proposalIds[proposalIds.length - 1];
const latestProposal = Near.view(
"${REPL_INFRASTRUCTURE_COMMITTEE_CONTRACT}",
"get_proposal",
{
proposal_id: latestProposalId,
}
);

if (
latestProposal.snapshot.name === title &&
latestProposal.snapshot.description === description
) {
setCreateTxn(false);
setProposalId(proposalIds[proposalIds.length - 1]);
setShowProposalViewModal(true);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
"name": "events-committee.near_wallet_auth_key",
"value": "{\"accountId\":\"theori.near\",\"allKeys\":[\"ed25519:9enAAsDiQ2NvKU2TsHLETp96sYeN2qkbHxhpXLjCQThS\"]}"
},
{
"name": "infrastructure-committee.near_wallet_auth_key",
"value": "{\"accountId\":\"theori.near\",\"allKeys\":[\"ed25519:G6PXTFq5xNvyYL4LttWVvHo7srmfGuTumX5W7JyXV21P\"]}"
},
{
"name": "near-api-js:keystore:theori.near:mainnet",
"value": "ed25519:67p9ygtfVNZz5AzMkeN4bqstCck8RWxWDthcTa7JaBvxkrBRTc6A43SsuPy9LdtiR6XtSRD1HiS4KQTWCZw83FKS"
Expand All @@ -40,6 +44,10 @@
"name": "events-committee.near:keystore:theori.near:mainnet",
"value": "ed25519:2fBVgJF9NpbAsGfNsGVZGbA1wX46Xyqcn9pZZ9hLA6BpawvDbeD9CAuXDteHMGa3mRuTg9pMQJqvqNhGRfUzYhtc"
},
{
"name": "infrastructure-committee.near:keystore:theori.near:mainnet",
"value": "ed25519:3WZFLnory8LU1iji6dXPrhQr4bq7SvaAH68i7odEzJ8N1acMn8LjAU8py84LmiQkgVs4x5Ma1XaFy1BpQGuBRVS1"
},
{
"name": "near-social-vm:v01::accountId:",
"value": "\"theori.near\""
Expand Down
35 changes: 26 additions & 9 deletions playwright-tests/tests/events/proposals.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,40 @@ test.describe("Don't ask again enabled", () => {
await pauseIfVideoRecording(page);
await expect(disabledSubmitButton).not.toBeAttached();

let newProposalId = 0;
await mockTransactionSubmitRPCResponses(
page,
async ({ route, request, transaction_completed, last_receiver_id }) => {
const postData = request.postDataJSON();
if (
transaction_completed &&
postData.params?.method_name === "get_all_proposal_ids"
) {
if (postData.params?.method_name === "get_all_proposal_ids") {
const response = await route.fetch();
const json = await response.json();

console.log(
"transaction completed, modifying get_proposal_ids result"
);
await new Promise((resolve) => setTimeout(() => resolve(), 4000));
const resultObj = decodeResultJSON(json.result.result);
resultObj.push(1);
console.log(JSON.stringify(resultObj));
newProposalId = resultObj[resultObj.length - 1] + 1;
if (transaction_completed) {
resultObj.push(newProposalId);
}
json.result.result = encodeResultJSON(resultObj);

await route.fulfill({ response, json });
} else if (
postData.params?.method_name === "get_proposal" &&
postData.params.args_base64 ===
btoa(JSON.stringify({ proposal_id: newProposalId }))
) {
postData.params.args_base64 = btoa(
JSON.stringify({ proposal_id: newProposalId - 1 })
);
const response = await route.fetch({
postData: JSON.stringify(postData),
});
const json = await response.json();

let resultObj = decodeResultJSON(json.result.result);
resultObj.snapshot.name = "Test proposal 123456";
resultObj.snapshot.description = "The test proposal description.";
json.result.result = encodeResultJSON(resultObj);

await route.fulfill({ response, json });
Expand Down
Loading

0 comments on commit 6330078

Please sign in to comment.