Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(events/infrastructure): see the proposal you submit, and not another #945

Merged
merged 12 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading