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

feat: Filter transactions table by date #993

Open
wants to merge 57 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b048959
add basic UI
janmichek Nov 14, 2024
6fd2312
watch selected range value
janmichek Nov 14, 2024
00fb597
concat url string for combined parameter
janmichek Nov 14, 2024
e216c2f
style UI
janmichek Nov 14, 2024
2dfaa39
fix combining queries
janmichek Nov 15, 2024
338560f
fix passing parameter
janmichek Nov 15, 2024
e2b9640
style UI
janmichek Nov 18, 2024
f4a9421
todo move solution to store
janmichek Nov 19, 2024
bdae425
todo move solution to store
janmichek Nov 19, 2024
6d5e3c2
todo move solution to store
janmichek Nov 19, 2024
1296b4c
fix combine filtering
janmichek Nov 20, 2024
44a46c4
set parameters to components from directly pasted url
janmichek Nov 20, 2024
82e877a
fix initial state
janmichek Nov 20, 2024
a3adf28
cleanup code
janmichek Nov 22, 2024
e98fdb7
names refactoring
janmichek Nov 22, 2024
32f6dbd
names refactoring
janmichek Nov 22, 2024
4d5a956
add cancel button
janmichek Nov 22, 2024
b870edf
set component state after nevigating throught direct link
janmichek Nov 22, 2024
748e3b5
enable clear date
janmichek Dec 12, 2024
b75c564
increase test timeout
janmichek Dec 16, 2024
86f1e09
fix setting time parameters from url
janmichek Dec 17, 2024
d586ce7
fix initialize table
janmichek Dec 17, 2024
4009485
fix combine parameters
janmichek Dec 18, 2024
0eb2132
resolve edge casees of combining parameters
janmichek Dec 19, 2024
038bdcd
fix code style
janmichek Dec 19, 2024
a367f13
add e2e test before refactoring
janmichek Dec 19, 2024
51f3ea4
components refactoring
janmichek Dec 19, 2024
c5aa757
components refactoring
janmichek Dec 19, 2024
1cb9174
store refactoring
janmichek Dec 19, 2024
cca00fc
edit tx counter
janmichek Dec 19, 2024
e7ad96a
improve tests
janmichek Dec 20, 2024
c303599
refactor store
janmichek Dec 20, 2024
4f65202
refactor store
janmichek Dec 20, 2024
ed5d713
improve test precision
janmichek Dec 20, 2024
ab2a6d9
rename variables
janmichek Dec 20, 2024
16f51f5
move formatting to store
janmichek Dec 21, 2024
4e1bd02
move formatting to store
janmichek Dec 21, 2024
dfd2010
format datetime value inside component
janmichek Dec 25, 2024
b911c14
rename variable
janmichek Dec 25, 2024
7037d0b
Merge branch 'develop' into Filter-transactions-table-by-date
janmichek Dec 25, 2024
be3902d
simplify formatting
janmichek Dec 25, 2024
acb327b
refactor formatting
janmichek Dec 25, 2024
7e72ace
ui style fixes
janmichek Dec 26, 2024
623d2e7
fix code style
janmichek Dec 26, 2024
7d568a2
simplify parameters
janmichek Dec 26, 2024
c7c9611
simplify parameters
janmichek Dec 26, 2024
16343fd
fix styles
janmichek Dec 26, 2024
5410db1
formatting fixes
janmichek Dec 27, 2024
4f10027
tod fix reseting scope
janmichek Dec 27, 2024
78bfc04
use useVModel
janmichek Dec 31, 2024
506199e
reuse clear function
janmichek Dec 31, 2024
7b5bcdb
code cleanup
janmichek Jan 1, 2025
9bcddb1
code cleanup
janmichek Jan 1, 2025
b08fa0b
fix test to pass
janmichek Jan 2, 2025
4c2a907
fix test to pass
janmichek Jan 2, 2025
573795f
Merge branch 'develop' into Filter-transactions-table-by-date
janmichek Jan 14, 2025
79d3bb0
fixes after rebase
janmichek Jan 14, 2025
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
Prev Previous commit
Next Next commit
improve test precision
janmichek committed Dec 20, 2024
commit ed5d713f9cbbc870aefa54162042d94b843ab7db
92 changes: 50 additions & 42 deletions cypress/e2e/app/transactions.cy.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,32 @@
describe('transactions', () => {
// it('should display transactions', () => {
// cy.visit('/transactions')
//
// cy.get('.transactions-table').should('be.visible')
// cy.get('.line-chart').should('be.visible')
// cy.get('.transaction-statistics__panel').should('be.visible')
// cy.get('.transaction-statistics__panel .chip').should('be.visible')
// })
//
// // todo back
//
// it('should display same transactions after going back from detail', () => {
// cy.visit('/transactions')
//
// cy.get('.transactions-table__data').first()
// .invoke('text')
// .then(hash1 => {
// const transactionDetailLink = cy.get('.transactions-table__data').first().find('.u-hidden-mobile a')
// transactionDetailLink.click()
//
// cy.get('.copy-chip__text') // workaround to time out before going back get the element
//
// cy.go(-1)
//
// cy.get('.transactions-table__data').first()
// .invoke('text')
// .should(hash2 => {
// expect(hash1).to.eq(hash2)
// })
// })
// })
it('should filter by combining parameters from URL', () => {
cy.visit('/transactions?scope=time:1733871600-1733958000&txType=spend')
it('should display transactions', () => {
cy.visit('/transactions')

cy.get('.paginated-content .dp__input')
.should('have.value', '12/11/2024 - 12/12/2024')
cy.get('.paginated-content .multiselect__single').contains('SpendTx')
cy.get('.transactions-table tbody tr').should('have.length', 10)
cy.get('.transactions-table tbody tr').contains('td', 'SpendTx').should('have.length', 1)
cy.get('.transactions-table').should('be.visible')
cy.get('.line-chart').should('be.visible')
cy.get('.transaction-statistics__panel').should('be.visible')
cy.get('.transaction-statistics__panel .chip').should('be.visible')
})

it('should display same transactions after going back from detail', () => {
cy.visit('/transactions')

cy.get('.transactions-table__data').first()
.invoke('text')
.then(hash1 => {
const transactionDetailLink = cy.get('.transactions-table__data').first().find('.u-hidden-mobile a')
transactionDetailLink.click()

cy.get('.copy-chip__text') // workaround to time out before going back get the element

cy.go(-1)

cy.get('.transactions-table__data').first()
.invoke('text')
.should(hash2 => {
expect(hash1).to.eq(hash2)
})
})
})

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was really hard to achive, hence is fully tested

it('should select date', () => {
@@ -46,14 +35,18 @@ describe('transactions', () => {
cy.get('.paginated-content .scope-picker').click()
cy.get('.dp__today').click()
cy.get('.dp__today').parent().prev().click()

cy.url().should('include', 'scope=')
cy.get('.paginated-content .dp__input').should('not.have.value', '')
})
it('should select type', () => {
it('should select type', () => {
cy.visit('/transactions')

cy.get('.paginated-content .multiselect').click()
cy.contains('.paginated-content .multiselect__option', 'SpendTx').click()

cy.url().should('include', 'txType=spend')
cy.get('.paginated-content .multiselect__single').contains('SpendTx')
})

it('should select combined parameters', () => {
@@ -64,8 +57,21 @@ describe('transactions', () => {
cy.get('.dp__today').parent().prev().click()

cy.get('.paginated-content .multiselect').click()
cy.contains('.paginated-content .multiselect__option', 'SpendTx').click()
cy.url().should('include', 'txType=spend').should('include', 'scope=')
cy.contains('.paginated-content .multiselect__option', 'NameClaimTx').click()

cy.url().should('include', 'txType=name_claim').should('include', 'scope=')
cy.get('.paginated-content .multiselect__single').contains('NameClaimTx')
cy.get('.paginated-content .dp__input').should('not.have.value', '')
})

it('should filter by combining parameters from direct URL access', () => {
cy.visit('/transactions?scope=time:1733871600-1733958000&txType=contract_create')

cy.get('.paginated-content .multiselect__single').contains('ContractCreateTx')
cy.get('.transactions-table tbody tr').should('have.length', 10)
cy.get('.transactions-table tbody tr').contains('td', 'ContractCreateTx').should('have.length', 1)
cy.get('.paginated-content .dp__input')
.should('have.value', '12/11/2024 - 12/12/2024')
})

it('should cancel filtering and clear url', () => {
@@ -74,7 +80,9 @@ describe('transactions', () => {
cy.get('.paginated-content .multiselect').click()
cy.contains('.paginated-content .multiselect__option', 'All types').click()
cy.get('.dp--clear-btn').click()

cy.url().should('eq', Cypress.config().baseUrl + '/transactions')
cy.get('.paginated-content .multiselect__single').contains('All types')
cy.get('.paginated-content .dp__input').should('have.value', '')
})
// todo mostly check both values and url
})
3 changes: 0 additions & 3 deletions src/components/ChartControls.vue
Original file line number Diff line number Diff line change
@@ -44,9 +44,6 @@ function selectInterval(option) {
}

function selectCustomInterval(dateCustomInterval) {
console.log('selectCustomInterval dateCustomInterval[0]', dateCustomInterval[0])
console.log('selectCustomInterval dateCustomInterval[0]', typeof dateCustomInterval[0])

const customInterval = {
customInterval: {
minStart: dateCustomInterval[0].toISOString().split('T')[0],
1 change: 0 additions & 1 deletion src/components/ScopePicker.vue
Original file line number Diff line number Diff line change
@@ -59,7 +59,6 @@ watch(
watch(
() => props.scope,
newScope => {
console.log('newScope', newScope)
selectedScope.value = newScope
},
{ immediate: true },
1 change: 0 additions & 1 deletion src/components/TransactionsChartPanel.vue
Original file line number Diff line number Diff line change
@@ -52,7 +52,6 @@ const props = defineProps({
})

const selectedScope = ref(props.scope)
console.log('selectedScope', selectedScope)
const selectedTxType = ref(TX_TYPES_OPTIONS[0])

await useAsyncData(async() => {
23 changes: 11 additions & 12 deletions src/stores/transactions.js
Original file line number Diff line number Diff line change
@@ -66,7 +66,6 @@ export const useTransactionsStore = defineStore('transactions', () => {
const hasType = !!params.value?.txType
// todo mozna konverze uz tady

console.log('selectedScope', selectedScope)
selectedTxType.value = hasType
? TX_TYPES_OPTIONS.find(option => option.typeQuery === params.value.txType)
: TX_TYPES_OPTIONS[0]
@@ -78,22 +77,27 @@ export const useTransactionsStore = defineStore('transactions', () => {
async function loadTransactions(queryParameters) {
setUrlParametersToStore()

const ddd = scopeSlug.value ? scopeSlug.value.substring(6) : null
console.log('ddd', ddd)

await fetchTransactions({
queryParameters,
scope: selectedScope.value,
scope: ddd,
type: selectedTxType.value?.typeQuery,
limit: pageLimit.value,
})

await fetchTransactionsCount({
scope: selectedScope.value,
scope: ddd,
type: selectedTxType.value?.typeQuery,
})

setPageIndex(1)
}

async function fetchTransactions({ queryParameters, scope, type, limit } = {}) {
console.log('fetchTransactions scope', scope)

rawTransactions.value = null

if (queryParameters) {
@@ -108,10 +112,7 @@ export const useTransactionsStore = defineStore('transactions', () => {
url.searchParams.append('limit', limit.value ?? 10)

if (scope) {
// todo try to move
const bbb = formatScopeToParameters(scope.customInterval.minStart, scope.customInterval.maxStart)
const ccc = bbb.substring(6)
url.searchParams.append('scope', ccc)
url.searchParams.append('scope', scope)
}

if (type) {
@@ -125,18 +126,16 @@ export const useTransactionsStore = defineStore('transactions', () => {
}

async function fetchTransactionsCount({ scope, type }) {
console.log('fetchTransactionsCount scope', scope)
transactionsCount.value = null
if (scope && type) {
// todo workaround reoprt to MDW
// todo workaround reoprt to MDW + add E2 TESTS for counter
transactionsCount.value = null
} else {
const url = new URL(`${MIDDLEWARE_URL}/v3/transactions/count`)

if (scope) {
// todo try to move
const bbb = formatScopeToParameters(scope.customInterval.minStart, scope.customInterval.maxStart)
const ccc = bbb.substring(6)
url.searchParams.append('scope', ccc)
url.searchParams.append('scope', scope)
}

if (type) {

Unchanged files with check annotations Beta

FROM node:lts-alpine as server

Check warning on line 1 in Dockerfile

GitHub Actions / build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 1 in Dockerfile

GitHub Actions / build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
WORKDIR /app
COPY package.json .