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 flakey tests #1509

Merged
merged 2 commits into from
Oct 8, 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
8 changes: 3 additions & 5 deletions extension/e2e-tests/addAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,9 @@ test("Adding Soroban verified token", async ({ page, extensionId }) => {
timeout: 30000,
});

await page.getByText("Manage Assets").click({ force: true });
await page
.getByTestId("ManageAssetRowButton__ellipsis-USDC")
.click({ force: true });
await page.getByText("Remove asset").click({ force: true });
await page.getByText("Manage Assets").click();
await page.getByTestId("ManageAssetRowButton__ellipsis-USDC").click();
await page.getByText("Remove asset").click();

await expect(page.getByTestId("account-view")).toBeVisible({
timeout: 30000,
Expand Down
18 changes: 9 additions & 9 deletions extension/e2e-tests/sendPayment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ test("Send XLM payment to C address", async ({ page, extensionId }) => {
await expect(page.getByTestId("SendSettingsTransactionFee")).toHaveText(
/[0-9]/,
);
await page.getByText("Review Send").click({ force: true });
await page.getByText("Review Send").click();

await expect(page.getByText("Verification")).toBeVisible();
await page.getByPlaceholder("Enter password").fill(PASSWORD);
await page.getByText("Submit").click({ force: true });
await page.getByText("Submit").click();

await expect(page.getByText("Confirm Send")).toBeVisible();
await expect(page.getByText("Confirm Send")).toBeVisible({
timeout: 200000,
});
await expectPageToHaveScreenshot({
page,
screenshot: "send-payment-confirm.png",
Expand Down Expand Up @@ -138,7 +140,7 @@ test("Send SAC to C address", async ({ page, extensionId }) => {

await page.getByText("Add asset").dispatchEvent("click");
await expect(page.getByTestId("account-view")).toBeVisible({
timeout: 30000,
timeout: 300000,
});

// swap to get some USDC
Expand Down Expand Up @@ -184,7 +186,7 @@ test("Send SAC to C address", async ({ page, extensionId }) => {

await expect(page.getByText("Send Settings")).toBeVisible();
await expect(page.getByText("Review Send")).toBeEnabled();
await page.getByText("Review Send").click({ force: true });
await page.getByText("Review Send").click();

await expect(page.getByText("Confirm Send")).toBeVisible();
await page.getByTestId("transaction-details-btn-send").click({ force: true });
Expand All @@ -203,9 +205,7 @@ test("Send SAC to C address", async ({ page, extensionId }) => {
// remove USDC

await page.getByText("Manage Assets").click({ force: true });
await page
.getByTestId("ManageAssetRowButton__ellipsis-USDC")
.click({ force: true });
await page.getByTestId("ManageAssetRowButton__ellipsis-USDC").click();
await page.getByText("Remove asset").click({ force: true });

await expect(page.getByTestId("account-view")).toBeVisible({
Expand Down Expand Up @@ -248,7 +248,7 @@ test("Send token payment to C address", async ({ page, extensionId }) => {
await page.getByTestId("transaction-details-btn-send").click({ force: true });

await expect(page.getByText("Successfully sent")).toBeVisible({
timeout: 60000,
timeout: 600000,
});

await page.getByText("Details").click({ force: true });
Expand Down
4 changes: 4 additions & 0 deletions extension/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { defineConfig, devices } from "@playwright/test";
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
expect: {
/* Set the default timeout for all tests to 30 seconds */
timeout: 300000,
},
testDir: "./e2e-tests",
/* Run tests in files in parallel */
fullyParallel: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ export const Settings = ({

useEffect(() => {
async function simulateTx() {
if (!recommendedFee) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it appears that part of the issue was the request to Horizon to get the recommended fee can sometimes take a long time to resolve, which will cause this hook to run but not be able to pass the conditional at ln 184 because the recommendedFee hasn't been set yet

return;
}
// use default transaction fee if unset
const baseFee = new BigNumber(
transactionFee || recommendedFee || stroopToXlm(BASE_FEE),
Expand Down Expand Up @@ -136,6 +139,7 @@ export const Settings = ({
),
);
}
setLoadingSimulation(false);
return;
}

Expand Down Expand Up @@ -193,17 +197,18 @@ export const Settings = ({
),
);
}
setLoadingSimulation(false);
return;
}

if (!transactionFee) {
dispatch(saveTransactionFee(baseFee.toString()));
}
setLoadingSimulation(false);
}
async function setFee() {
setLoadingSimulation(true);
await simulateTx();
setLoadingSimulation(false);
}
setFee();
}, [
Expand Down Expand Up @@ -251,7 +256,7 @@ export const Settings = ({
title={`${isSwap ? t("Swap") : t("Send")} ${t("Settings")}`}
customBackAction={() => navigateTo(previous)}
/>
{isLoadingSimulation ? (
{isLoadingSimulation && !recommendedFee ? (
<div className="SendSettings__loadingWrapper">
<Loader size="2rem" />
</div>
Expand Down
4 changes: 4 additions & 0 deletions extension/src/popup/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"Add": "Add",
"Add address": "Add address",
"Add an asset": "Add an asset",
"Add anyway": "Add anyway",
"Add asset": "Add asset",
"Add Asset trustline": "Add Asset trustline",
"Add Asset Trustline": "Add Asset Trustline",
Expand Down Expand Up @@ -374,6 +375,7 @@
"Resource cost": "Resource cost",
"Review": "Review",
"Review accounts to migrate": "Review accounts to migrate",
"Review anyway": "Review anyway",
"Review transaction on device": "Review transaction on device",
"Revocable Asset": "Revocable Asset",
"Salt": "Salt",
Expand Down Expand Up @@ -474,6 +476,8 @@
"This site has been scanned and verified": "This site has been scanned and verified",
"This site was flagged as malicious": "This site was flagged as malicious",
"This transaction could not be completed": "This transaction could not be completed.",
"This transaction is expected to fail": "This transaction is expected to fail",
"This transaction was flagged as malicious": "This transaction was flagged as malicious",
"This transaction was flagged by Blockaid for the following reasons": "This transaction was flagged by Blockaid for the following reasons",
"To": "To",
"To create a new account you need to send at least 1 XLM to it": "To create a new account you need to send at least 1 XLM to it.",
Expand Down
4 changes: 4 additions & 0 deletions extension/src/popup/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"Add": "Add",
"Add address": "Add address",
"Add an asset": "Add an asset",
"Add anyway": "Add anyway",
"Add asset": "Add asset",
"Add Asset trustline": "Add Asset trustline",
"Add Asset Trustline": "Add Asset Trustline",
Expand Down Expand Up @@ -374,6 +375,7 @@
"Resource cost": "Resource cost",
"Review": "Review",
"Review accounts to migrate": "Review accounts to migrate",
"Review anyway": "Review anyway",
"Review transaction on device": "Review transaction on device",
"Revocable Asset": "Revocable Asset",
"Salt": "Salt",
Expand Down Expand Up @@ -474,6 +476,8 @@
"This site has been scanned and verified": "This site has been scanned and verified",
"This site was flagged as malicious": "This site was flagged as malicious",
"This transaction could not be completed": "This transaction could not be completed.",
"This transaction is expected to fail": "This transaction is expected to fail",
"This transaction was flagged as malicious": "This transaction was flagged as malicious",
"This transaction was flagged by Blockaid for the following reasons": "This transaction was flagged by Blockaid for the following reasons",
"To": "To",
"To create a new account you need to send at least 1 XLM to it": "To create a new account you need to send at least 1 XLM to it.",
Expand Down