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

NNS1-3486: period filter for reporting transactions #6032

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

yhabib
Copy link
Contributor

@yhabib yhabib commented Dec 17, 2024

Motivation

We want users to be able to generate three types of reports:

  • full history
  • year-to-date
  • last year

https://qsgjb-riaaa-aaaaa-aaaga-cai.yhabib-ingress.devenv.dfinity.network/reporting/

Changes

  • Adds period state to ReportingTransactions. It binds it to ReportingDateRangeSelector so it can be updated, and it passes it down to ReportingTransactionsButton to be used when generating the report.

Tests

  • Unit tests for ReportingTransactions

Todos

  • Add entry to changelog (if necessary).

@yhabib yhabib force-pushed the NNS1-3486/clean-up-types branch from cbccad8 to 06fb4af Compare December 17, 2024 17:11
Base automatically changed from NNS1-3486/clean-up-types to main December 18, 2024 09:28
@yhabib yhabib force-pushed the NNS1-3486/filter-transactions branch 2 times, most recently from a07715b to 276db08 Compare December 18, 2024 12:27
@yhabib yhabib force-pushed the NNS1-3486/filter-transactions branch from 276db08 to 0b6204f Compare December 18, 2024 12:39
@yhabib yhabib changed the title WIP NNS1-3486: period filter for reporting transactions Dec 18, 2024
@yhabib yhabib marked this pull request as ready for review December 18, 2024 12:56
@yhabib yhabib requested a review from a team as a code owner December 18, 2024 12:56
@@ -5,7 +5,7 @@ import { render } from "@testing-library/svelte";

describe("ReportingDateRangeSelector", () => {
const renderComponent = () => {
const { container } = render(ReportingDateRangeSelector);
const { container } = render(ReportingDateRangeSelector, { period: "all" });
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a unit test that selecting an option changes the exported prop.
And a unit test that changing the prop changes the selected option.

@@ -123,7 +123,7 @@
label: $i18n.reporting.timestamp,
},
];
const fileName = `icp_transactions_export_${formatDateCompact(new Date())}`;
const fileName = `icp_transactions_export_${period}_${formatDateCompact(new Date())}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's "last year", does it still make sense to put the current date in the filename, rather than last year's year?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will revert the change and sync with the PO to decide how to proceed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not for this PR, but the static under functions for page objects don't need named parameters if there's only a single parameter. We only do that if an additional testId needs to be passed.

@yhabib yhabib requested a review from dskloetd December 18, 2024 16:01

await tick();

const currentValue = component.$$.ctx[component.$$.props["period"]];
Copy link
Contributor Author

@yhabib yhabib Dec 18, 2024

Choose a reason for hiding this comment

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

This is how I check if the value is updated. Is there a better way?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine. Another possibility is to add a custom component for testing, which exposes the value in the DOM.

@yhabib yhabib force-pushed the NNS1-3486/filter-transactions branch from 1d72c17 to 581b2a0 Compare December 18, 2024 16:05

await tick();

const currentValue = component.$$.ctx[component.$$.props["period"]];
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine. Another possibility is to add a custom component for testing, which exposes the value in the DOM.

await tick();

const currentValue = component.$$.ctx[component.$$.props["period"]];
expect(currentValue).toBe("last-year");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also expect a different value before clicking on the option.
I recommend moving the code to get the prop value into a function so the test itself is more readable.

@yhabib yhabib force-pushed the NNS1-3486/filter-transactions branch from eb53247 to 34b503e Compare December 18, 2024 20:17
@yhabib yhabib requested a review from dskloetd December 18, 2024 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants