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: e2e tests #501

Closed
wants to merge 6 commits into from
Closed
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
2 changes: 2 additions & 0 deletions src/components/AboutModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
<script>
import { mapState, mapGetters } from 'vuex';
import contractInfo from 'dex-contracts-v2/package.json';
// TODO: i don't think this is ok
import packageLock from '../../package-lock.json';

Check failure on line 54 in src/components/AboutModal.vue

View workflow job for this annotation

GitHub Actions / Lint and Test

'packageLock' is defined but never used
import ModalDefault from './ModalDefault.vue';
import appInfo from '../../package.json';
import InfoRow from './InfoRow.vue';
Expand Down
1 change: 1 addition & 0 deletions src/components/AeBalance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
aettosToAe, handleUnknownError, isNotFoundError,
} from '@/lib/utils';
import AnimatedSpinner from '../assets/animated-spinner.svg?skip-optimize';
import { DEFAULT_NETWORKS } from '../lib/constants';

Check failure on line 22 in src/components/AeBalance.vue

View workflow job for this annotation

GitHub Actions / Lint and Test

'DEFAULT_NETWORKS' is defined but never used

const pollState = {};
let storeState;
Expand Down
5 changes: 4 additions & 1 deletion src/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatAmount, AE_AMOUNT_FORMATS, decode } from '@aeternity/aepp-sdk';

Check failure on line 1 in src/lib/utils.js

View workflow job for this annotation

GitHub Actions / Lint and Test

'decode' is defined but never used
import BigNumber from 'bignumber.js';
import dexContractsErrorMessages from 'dex-contracts-v2/build/errors';
import dexUiErrorMessages from './errors';
Expand Down Expand Up @@ -69,6 +69,8 @@
Object.entries(params)
.filter(([, value]) => ![undefined, null].includes(value))
.forEach(([name, value]) => url.searchParams.set(name, value));
console.log('params', params);
console.log('url', url);
return url;
};

Expand Down Expand Up @@ -171,7 +173,8 @@
message = instance._calldata.decodeFateString(returnValue);
break;
case 'error':
message = decode(returnValue).toString();
// TODO: COMMENTED
// message = decode(returnValue).toString();
break;
default: message = `Unknown returnType: ${returnType}`;
}
Expand Down
8 changes: 6 additions & 2 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { shallowReactive } from 'vue';
import { createStore } from 'vuex';
import {
Node, AeSdkAepp, walletDetector, BrowserWindowMessageConnection, AeSdk, unpackTx,
RpcRejectedByUserError,
RpcRejectedByUserError
} from '@aeternity/aepp-sdk';
import createPersistedState from 'vuex-persistedstate';
import {
Expand Down Expand Up @@ -37,6 +37,8 @@ export default createStore({
transactions: [],
lang: null,
hasSeenOnboarding: false,
// This was added because of the following error:
// sdk.getNodesInPool()
},
getters: {
networks() {
Expand Down Expand Up @@ -112,6 +114,7 @@ export default createStore({
},
},
actions: {
// HERE this is for mobile
async initUniversal({
commit, dispatch, state: { networkId }, getters: { networks },
}) {
Expand All @@ -120,7 +123,7 @@ export default createStore({
instance: new Node(network.url),
}));

const instance = shallowReactive(new AeSdk({ nodes }));
const instance = shallowReactive(new AeSdk({ nodes })));
commit('setSdk', instance);
await dispatch('selectNetwork', networkId);
},
Expand Down Expand Up @@ -271,6 +274,7 @@ export default createStore({
.find((t) => JSON.stringify(t.txParams) === JSON.stringify(tx.encodedTx)));

if (index !== -1 && transactions[index].pending && transactions[index].unfinished) {
// HERE
const { txHash: hash } = await sdk.api.postTransaction({ tx: transaction });
commit('changeTransactionById', { index, transaction: { unfinished: false, hash } });
}
Expand Down
17 changes: 14 additions & 3 deletions src/store/modules/aeternity.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import routerACI from 'dex-contracts-v2/build/AedexV2Router.aci.json';
import waeACI from 'dex-contracts-v2/build/WAE.aci.json';
import factoryACI from 'dex-contracts-v2/build/AedexV2Factory.aci.json';
import pairACI from 'dex-contracts-v2/build/AedexV2Pair.aci.json';
import { decode } from '@aeternity/aepp-sdk';
import {
cttoak, createOnAccountObject, addSlippage, subSlippage,
getPairId, sortTokens, isDexBackendDisabled,
Expand Down Expand Up @@ -40,7 +41,7 @@ const genRouterWaeMethodAction = (method, argsMapper, isWae = false) => async (
dispatch,
commit,
state: { router, wae },
rootState: { address, useSdkWallet },
rootState: { sdk, address, useSdkWallet },
} = context;
const methodArgs = argsMapper(context, args);
methodArgs[methodArgs.length - 1] = {
Expand All @@ -56,11 +57,19 @@ const genRouterWaeMethodAction = (method, argsMapper, isWae = false) => async (
return result;
}
const result = await (isWae ? wae : router)[method](...methodArgs);
debugger;
const builded = result.rawTx;
console.log('builded', builded);
const decoded = decode(builded);
console.log('decoded', decoded);
commit('addTransaction', {
txParams: result.tx, info: transactionInfo, pending: true, unfinished: true,
}, { root: true });
window.location = await dispatch('sendTxDeepLinkUrl', builded, { root: true });
const ret = await dispatch('sendTxDeepLinkUrl', builded, { root: true });
debugger;
console.log(ret);
console.log('href', ret.href);
window.location = ret;
return result;
};
const withFetchingPairInfo = (work) => async (context, args) => {
Expand Down Expand Up @@ -632,7 +641,7 @@ export default {
dispatch,
commit,
state: { slippage },
rootState: { address, useSdkWallet },
rootState: { address, useSdkWallet, sdk },
}, {
instance,
toAccount,
Expand Down Expand Up @@ -679,6 +688,8 @@ export default {
amountWithSlippage - currentAllowance,
{ onAccount, callStatic: true },
);
debugger;
const builded = await sdk.buildTx(tx);
commit('addTransaction', {
txParams: tx, info: transactionInfo, pending: true, unfinished: true,
}, { root: true });
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Cypress.Commands.add('login', () => {
.get('[data-cy=import]')
.click()
.get('button')
.contains('Confirm')
.contains('Accept')
.click()
.visit('/')
.login();
Expand Down
Loading