-
Notifications
You must be signed in to change notification settings - Fork 364
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
B2CQA-2136 : Switching From and To currencies and perform a swap test #8715
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,6 +296,71 @@ for (const { swap, xrayTicket } of rejectedSwaps) { | |
}); | ||
} | ||
|
||
const switchFromToSwaps = [ | ||
{ | ||
swap: new Swap( | ||
Account.ETH_1, | ||
Account.BTC_NATIVE_SEGWIT_1, | ||
"0.02", | ||
Fee.MEDIUM, | ||
Provider.CHANGELLY, | ||
Rate.FLOAT, | ||
), | ||
xrayTicket: "B2CQA-2136", | ||
}, | ||
]; | ||
|
||
for (const { swap, xrayTicket } of switchFromToSwaps) { | ||
test.describe("Swap - Switch From and To (without tx broadcast)", () => { | ||
test.beforeAll(async () => { | ||
process.env.SWAP_DISABLE_APPS_INSTALL = "true"; | ||
process.env.SWAP_API_BASE = "https://swap-stg.ledger-test.com/v5"; | ||
process.env.DISABLE_TRANSACTION_BROADCAST = "1"; | ||
}); | ||
|
||
const accPair: string[] = [swap.accountToDebit, swap.accountToCredit].map(acc => | ||
acc.currency.speculosApp.name.replace(/ /g, "_"), | ||
); | ||
|
||
test.beforeEach(async () => { | ||
setExchangeDependencies( | ||
accPair.map(appName => ({ | ||
name: appName, | ||
})), | ||
); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
delete process.env.SWAP_DISABLE_APPS_INSTALL; | ||
delete process.env.SWAP_API_BASE; | ||
delete process.env.DISABLE_TRANSACTION_BROADCAST; | ||
}); | ||
|
||
test.use({ | ||
userdata: "speculos-tests-app", | ||
speculosApp: app, | ||
}); | ||
|
||
test( | ||
`Swap ${swap.accountToDebit.currency.name} to ${swap.accountToCredit.currency.name}`, | ||
{ | ||
annotation: { | ||
type: "TMS", | ||
description: xrayTicket, | ||
}, | ||
}, | ||
async ({ app, electronApp }) => { | ||
await addTmsLink(getDescription(test.info().annotations, "TMS").split(", ")); | ||
await switchFromToCurrencySwap(app, electronApp, swap); | ||
await app.swap.selectQuote(electronApp, swap.provider.name, swap.rate); | ||
await performSwapUntilDeviceVerificationStep(app, electronApp, swap); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I understand this test suppose to check that user is able to inverse "from" and "to" therefore I don't see the reason of doing full e2e swap scenario here |
||
await app.speculos.verifyAmountsAndAcceptSwap(swap); | ||
await app.swapDrawer.verifyExchangeCompletedTextContent(swap.accountToCredit.currency.name); | ||
}, | ||
); | ||
}); | ||
} | ||
|
||
const tooLowAmountForQuoteSwaps = [ | ||
{ | ||
swap: new Swap( | ||
|
@@ -436,6 +501,28 @@ async function performSwapUntilQuoteSelectionStep( | |
await app.swap.fillInOriginCurrencyAmount(electronApp, swap.amount); | ||
} | ||
|
||
async function switchFromToCurrencySwap( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function should be about switching currencies in a swap but it does ton of other stuff (looks like a duplicate of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, this method is used only once, so I don't see a utility of having separate method for this code |
||
app: Application, | ||
electronApp: ElectronApplication, | ||
swap: Swap, | ||
) { | ||
//todo: remove 2 following lines after LIVE-14410 | ||
await app.layout.goToAccounts(); | ||
await app.accounts.navigateToAccountByName(swap.accountToDebit.accountName); | ||
await app.layout.waitForPageDomContentLoadedState(); | ||
|
||
await app.layout.waitForAccountsSyncToBeDone(); | ||
await app.swap.waitForPageNetworkIdleState(); | ||
await app.layout.goToSwap(); | ||
await app.swap.waitForPageNetworkIdleState(); | ||
await app.swap.selectAssetFrom(electronApp, swap.accountToDebit); | ||
await app.swapDrawer.selectAccountByName(swap.accountToDebit); | ||
await app.swap.selectAssetTo(electronApp, swap.accountToCredit.currency.name); | ||
await app.swapDrawer.selectAccountByName(swap.accountToCredit); | ||
await app.swap.reverseSwapPair(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function doesn't seem to verify that currencies have been inverted |
||
await app.swap.fillInOriginCurrencyAmount(electronApp, swap.amount); | ||
} | ||
|
||
async function performSwapUntilDeviceVerificationStep( | ||
app: Application, | ||
electronApp: ElectronApplication, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need "for" loop here since you have only one element in switchFromToSwaps