-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding tests for create and fund account (#808)
- Loading branch information
1 parent
66bc155
commit 16500a2
Showing
10 changed files
with
408 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { useStore } from "@/store/useStore"; | ||
|
||
export const useIsTestingNetwork = (): boolean => { | ||
const { network } = useStore(); | ||
|
||
return network.id === "testnet" || network.id === "futurenet"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test.describe("Create Account Page", () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto("http://localhost:3000/account/create"); | ||
}); | ||
|
||
test("Loads", async ({ page }) => { | ||
await expect(page.locator("h1")).toHaveText("Keypair Generator"); | ||
}); | ||
|
||
test("Renders 'Generate keypair' and 'Fund account' button", async ({ | ||
page, | ||
}) => { | ||
const buttonContainer = page.getByTestId("createAccount-buttons"); | ||
expect(buttonContainer.getByText("Generate keypair")).toBeVisible; | ||
expect(buttonContainer.getByText("Fund account with Friendbot")) | ||
.toBeVisible; | ||
}); | ||
|
||
test("Test 'Generate keypair' button", async ({ page }) => { | ||
await page.getByRole("button", { name: "Generate keypair" }).click(); | ||
|
||
await expect( | ||
page.locator("input[id='generate-keypair-publickey']"), | ||
).toHaveValue(/^G/); | ||
await expect( | ||
page.locator("input[id='generate-keypair-secretkey']"), | ||
).toHaveValue(/^S/); | ||
}); | ||
|
||
test("Test 'Fund account' button", async ({ page }) => { | ||
await page | ||
.getByRole("button", { name: "Fund account with Friendbot" }) | ||
.click(); | ||
|
||
await expect(page).toHaveURL(/.*\/account\/fund/); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
import { Account, MuxedAccount } from "@stellar/stellar-sdk"; | ||
|
||
test.describe("Create Muxed Account Page", () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto("http://localhost:3000/account/muxed-create"); | ||
}); | ||
|
||
test("Loads", async ({ page }) => { | ||
await expect(page.locator("h1")).toHaveText("Create Multiplexed Account"); | ||
}); | ||
|
||
test("Renders 'Base Account G Address' and 'Muxed Account ID' input field", async ({ | ||
page, | ||
}) => { | ||
expect(page.locator("input[id='muxed-public-key']")).toBeVisible; | ||
expect(page.locator("input[id='muxed-account-iD']")).toBeVisible; | ||
}); | ||
|
||
test("Gets an error with an invalid public key in 'Base Account G Address' field", async ({ | ||
page, | ||
}) => { | ||
const publicKeyInput = page.locator("#muxed-public-key"); | ||
|
||
// Type in an invalid string in 'Public Key' input field | ||
await publicKeyInput.fill("XLKDSFJLSKDJF"); | ||
|
||
await expect(publicKeyInput).toHaveAttribute("aria-invalid", "true"); | ||
await expect( | ||
page.getByText("Base account address should start with G"), | ||
).toBeVisible(); | ||
}); | ||
|
||
test("Gets an error with a non whole number 'Muxed Account ID' field", async ({ | ||
page, | ||
}) => { | ||
const muxedAccountIdInput = page.locator("#muxed-account-id"); | ||
|
||
await muxedAccountIdInput.fill("XLKDSFJLSKDJF"); | ||
|
||
await expect(muxedAccountIdInput).toHaveAttribute("aria-invalid", "true"); | ||
await expect(page.getByText("Expected a whole number")).toBeVisible(); | ||
}); | ||
|
||
test("Successfully creates a muxed account", async ({ page }) => { | ||
const publicKey = | ||
"GDVOT2ALMUF3G54RBHNJUEV6LOAZCQQCARHEVNUPKGMVPWFC4PFN33QR"; | ||
const muxedId = "2"; | ||
const publicKeyInput = page.locator("#muxed-public-key"); | ||
await publicKeyInput.fill(publicKey); | ||
|
||
const muxedAccountIdInput = page.locator("#muxed-account-id"); | ||
await muxedAccountIdInput.fill(muxedId); | ||
|
||
const createButton = page.getByRole("button").getByText("Create"); | ||
|
||
await expect(publicKeyInput).toHaveAttribute("aria-invalid", "false"); | ||
await expect(muxedAccountIdInput).toHaveAttribute("aria-invalid", "false"); | ||
await expect(createButton).toBeEnabled(); | ||
|
||
await createButton.click(); | ||
|
||
await expect(page.getByTestId("createAccount-success")).toBeVisible(); | ||
|
||
const muxedValue = page.locator("input[id='muxed-account-address-result']"); | ||
|
||
const muxedAccount = new MuxedAccount(new Account(publicKey, "0"), muxedId); | ||
|
||
await expect(muxedValue).toHaveValue(muxedAccount.accountId()); | ||
}); | ||
}); |
Oops, something went wrong.