-
Notifications
You must be signed in to change notification settings - Fork 149
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: swaps test and others #4726
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { test } from '../../fixtures/fixtures'; | ||
|
||
const alexSdkPostRoute = 'https://*.alexlab.co/v1/graphql'; | ||
const hiroApiPostRoute = '*/**/v2/transactions'; | ||
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 possible to be specific to Hiro api origin, too? |
||
|
||
test.describe('Swaps', () => { | ||
test.beforeEach(async ({ extensionId, globalPage, homePage, onboardingPage, swapPage }) => { | ||
await globalPage.setupAndUseApiCalls(extensionId); | ||
await onboardingPage.signInWithTestAccount(extensionId); | ||
await homePage.enableTestMode(); | ||
await homePage.swapButton.click(); | ||
await swapPage.waitForSwapPageReady(); | ||
}); | ||
|
@@ -16,8 +16,7 @@ test.describe('Swaps', () => { | |
}); | ||
|
||
test('that it shows correct swap review details', async ({ swapPage }) => { | ||
const swapAmountInputs = await swapPage.swapAmountInput.all(); | ||
await swapAmountInputs[0].fill('1'); | ||
await swapPage.inputSwapAmountFrom(); | ||
await swapPage.selectAssetToReceive(); | ||
|
||
const swapProtocol = await swapPage.swapDetailsProtocol.innerText(); | ||
|
@@ -37,14 +36,22 @@ test.describe('Swaps', () => { | |
}); | ||
|
||
test('that the swap is broadcast', async ({ swapPage }) => { | ||
const requestPromise = swapPage.page.waitForRequest(alexSdkPostRoute); | ||
|
||
await swapPage.page.route(alexSdkPostRoute, async route => { | ||
await route.abort(); | ||
}); | ||
|
||
const swapAmountInputs = await swapPage.swapAmountInput.all(); | ||
await swapAmountInputs[0].fill('1'); | ||
let requestPromise; | ||
const isSponsoredSwap = swapPage.page.getByText('Sponsored'); | ||
|
||
if (isSponsoredSwap) { | ||
requestPromise = swapPage.page.waitForRequest(alexSdkPostRoute); | ||
await swapPage.page.route(alexSdkPostRoute, async route => { | ||
await route.abort(); | ||
}); | ||
} else { | ||
requestPromise = swapPage.page.waitForRequest(hiroApiPostRoute); | ||
await swapPage.page.route(alexSdkPostRoute, async route => { | ||
await route.abort(); | ||
}); | ||
} | ||
|
||
await swapPage.inputSwapAmountFrom(); | ||
await swapPage.selectAssetToReceive(); | ||
|
||
await swapPage.swapBtn.click(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,13 +15,6 @@ test.describe('Transaction signing', () => { | |
|
||
testAppPage = await TestAppPage.openDemoPage(context); | ||
await testAppPage.signIn(); | ||
const accountsPage = await context.waitForEvent('page'); | ||
await accountsPage.locator('text="Account 1"').click(); | ||
await testAppPage.page.bringToFront(); | ||
await testAppPage.page.click('text=Debugger', { | ||
timeout: 30000, | ||
}); | ||
await accountsPage.close(); | ||
}); | ||
|
||
// These tests often break if ran in parallel | ||
|
@@ -31,6 +24,14 @@ test.describe('Transaction signing', () => { | |
test('that it validates against insufficient funds when performing a contract call', async ({ | ||
context, | ||
}) => { | ||
const accountsPage = await context.waitForEvent('page'); | ||
await accountsPage.locator('text="Account 2"').click(); | ||
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. Account 1 in the test account doesn't have a 0 balance atm so this was failing. 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. Should we fill it up instead of making this change? 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. I think the problem was |
||
await testAppPage.page.bringToFront(); | ||
await testAppPage.page.click('text=Debugger', { | ||
timeout: 30000, | ||
}); | ||
await accountsPage.close(); | ||
|
||
await testAppPage.clickContractCallButton(); | ||
const transactionRequestPage = new TransactionRequestPage(await context.waitForEvent('page')); | ||
const error = | ||
|
@@ -42,6 +43,14 @@ test.describe('Transaction signing', () => { | |
|
||
test.describe('App initiated STX transfer', () => { | ||
test('that it broadcasts correctly with given fee and amount', async ({ context }) => { | ||
const accountsPage = await context.waitForEvent('page'); | ||
await accountsPage.locator('text="Account 1"').click(); | ||
await testAppPage.page.bringToFront(); | ||
await testAppPage.page.click('text=Debugger', { | ||
timeout: 30000, | ||
}); | ||
await accountsPage.close(); | ||
|
||
await testAppPage.clickStxTransferButton(); | ||
const transactionRequestPage = new TransactionRequestPage(await context.waitForEvent('page')); | ||
|
||
|
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.
This test was failing bc the high fee warning popup was being triggered w/out a fee provided.