Skip to content

Commit

Permalink
update testing for smartContracts, buildTx, and submitTx
Browse files Browse the repository at this point in the history
  • Loading branch information
jeesunikim committed Feb 3, 2025
1 parent fce15a9 commit 3791d85
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
5 changes: 3 additions & 2 deletions tests/buildTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,8 @@ test.describe("Build Transaction Page", () => {
isSorobanOp: true,
label: "Contract ID",
value: "aaa",
errorMessage: "The string must start with 'C'.",
errorMessage:
"Invalid contract ID. Please enter a valid contract ID.",
});

await testInputError({
Expand All @@ -1374,7 +1375,7 @@ test.describe("Build Transaction Page", () => {
label: "Contract ID",
value: "CAQP53Z2GMZ6WVOKJWXMCVDL",
errorMessage:
"The string length should be at least 52 characters long.",
"Invalid contract ID. Please enter a valid contract ID.",
});

await testInputError({
Expand Down
2 changes: 1 addition & 1 deletion tests/mock/smartContracts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SAVED_ACCOUNT_1 } from "./localStorage";

export const MOCK_CONTRACT_ID =
"C000NO6F7FRDHSOFQBT2L2UWYIZ2PU76JKVRYAQTG3KZSQLYAOKIF2WB";
"CAQP53Z2GMZ6WVOKJWXMCVDLZYJ7GYVMWPAMWACPLEZRF2UEZW3B636S";
export const MOCK_CONTRACT_INFO_RESPONSE_SUCCESS = {
contract: MOCK_CONTRACT_ID,
account: MOCK_CONTRACT_ID,
Expand Down
4 changes: 2 additions & 2 deletions tests/smartContractsContractInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ test.describe("Smart Contracts: Contract Info", () => {
// Input validation
await contractIdInput.fill("aaa");
await expect(
page.getByText("The string must start with 'C'."),
page.getByText("Invalid contract ID. Please enter a valid contract ID."),
).toBeVisible();

// Valid input
await contractIdInput.fill(MOCK_CONTRACT_ID);
await expect(
page.getByText("The string must start with 'C'."),
page.getByText("Invalid contract ID. Please enter a valid contract ID."),
).toBeHidden();

// Fetch info
Expand Down
29 changes: 15 additions & 14 deletions tests/submitTransactionPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,24 +416,25 @@ test.describe("Submit Transaction Page", () => {
// Omitting the API end result because the test gives inconsistenet results
});
});
});

test.describe("Update default submit method to RPC when it is a Soroban XDR", () => {
test("Submit Soroban", async ({ page }) => {
const xdrInput = page.getByLabel(
"Input a base-64 encoded TransactionEnvelope",
);
const submitMethodsBtn = page
.locator(".SubmitTx__buttons")
.getByRole("button", { name: /via/i });
test.describe("Update default submit method to RPC when it is a Soroban XDR", () => {
test("Submit Soroban", async ({ page }) => {
const xdrInput = page.getByLabel(
"Input a base-64 encoded TransactionEnvelope",
);

// Input the Soroban XDR
await xdrInput.fill(MOCK_VALID_SOROBAN_TX_XDR.XDR);

await expect(submitMethodsBtn).toBeVisible();
const submitMethodsBtn = page
.locator(".SubmitTx__buttons")
.getByRole("button", { name: /via/i });

// Input the Soroban XDR
await xdrInput.fill(MOCK_VALID_SOROBAN_TX_XDR.XDR);
await expect(submitMethodsBtn).toBeVisible();

// Check if the submit method button shows RPC as default
await expect(submitMethodsBtn).toHaveText("via RPC");
// Check if the submit method button shows RPC as default
await expect(submitMethodsBtn).toHaveText("via RPC");
});
});
});

Expand Down

0 comments on commit 3791d85

Please sign in to comment.