Skip to content

Commit

Permalink
fixed swap instant testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
fullstackninja864 committed Mar 19, 2024
1 parent df5f630 commit a364f07
Showing 1 changed file with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import BigNumber from "bignumber.js";
import { PoolPairData } from "@defichain/whale-api-client/dist/api/poolpairs";
import { WhaleApiClient } from "@defichain/whale-api-client";
import { checkValueWithinRange } from "../../../../../support/utils";

function setCustomSlippage(customSlippage: string): void {
Expand All @@ -11,11 +13,22 @@ context(
"Wallet - DEX - Instant Swap (non-DFI)",
{ testIsolation: false },
() => {
let whale: WhaleApiClient;

before(() => {
cy.clearAllCookies();
cy.clearAllLocalStorage();
cy.createEmptyWallet(true);
cy.getByTestID("header_settings").click();
const network = localStorage.getItem("Development.NETWORK");
whale = new WhaleApiClient({
url:
network === "Playground"
? "https://playground.jellyfishsdk.com"
: "http://localhost:19553",
network: "regtest",
version: "v0",
});
cy.sendDFItoWallet()
.sendDFITokentoWallet()
.sendTokenToWallet(["LTC", "TU10"])
Expand Down Expand Up @@ -46,11 +59,18 @@ context(
// Valid form
cy.getByTestID("text_input_tokenA").clear().type("1");
cy.wait(2000);
cy.getByTestID("tokenB_value")
.invoke("text")
.then((text) => {
checkValueWithinRange("100", text.replace("$", ""));
});
cy.wrap<PoolPairData[]>(whale.poolpairs.list(200)).then(
(response: PoolPairData[]) => {
const pair: PoolPairData = response.find(
({ displaySymbol }) => displaySymbol === "dLTC-DFI",
);
cy.getByTestID("tokenB_value")
.invoke("text")
.then((text) => {
checkValueWithinRange(pair.priceRatio.ab, text.replace("$", ""));
});
},
);

cy.getByTestID("button_confirm_submit").should(
"not.have.attr",
Expand Down

0 comments on commit a364f07

Please sign in to comment.