Skip to content

Commit

Permalink
Show settlement window open and close dates (#59)
Browse files Browse the repository at this point in the history
* Fix bug

* Remove promise.any shim as it should not be required with the version of node now used in CI

* Removed unused code

* Tests and stuff

* 2.3.2

* Versions
  • Loading branch information
partiallyordered authored Sep 14, 2021
1 parent 73639a8 commit f1580c8
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 308 deletions.
4 changes: 2 additions & 2 deletions helm/finance-portal-v2-ui/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
appVersion: "v2.4.0"
appVersion: "v2.4.1"
description: Mojaloop Finance Portal UI v2
name: finance-portal-v2-ui
version: 2.4.0
version: 2.4.1
2 changes: 1 addition & 1 deletion helm/finance-portal-v2-ui/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replicaCount: 1

image:
repository: ghcr.io/mojaloop/finance-portal-v2-ui
tag: v2.4.0
tag: v2.4.1
pullPolicy: IfNotPresent

imagePullCredentials:
Expand Down
279 changes: 0 additions & 279 deletions integration_test/tests/package-lock.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions integration_test/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
"//": "We explicitly configure testcafe to compile our tests with our installed version of typescript. We therefore alias typescript to 'ts4' in order to reduce the chance of accidentally using the wrong module.",
"dependencies": {
"@js-temporal/polyfill": "^0.2.0",
"@types/promise.any": "^2.0.0",
"@types/uuid": "^8.3.1",
"@types/ws": "^6.0.4",
"axios": "^0.21.1",
"dotenv": "^10.0.0",
"env-var": "^7.0.1",
"mojaloop-voodoo-client": "0.7.0",
"promise.any": "^2.0.2",
"request": "2.88.2",
"testcafe": "1.15.1",
"testcafe-react-selectors": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export type SettlementWindowRow = {
id: Selector,
closeButton: Selector,
checkbox: Selector,
openDate: Selector,
closeDate: Selector,
}

const datePickerSelectDate = async (
Expand Down Expand Up @@ -79,9 +81,11 @@ export const SettlementWindowsPage = {
return Array
.from({ length })
.map((_, i) => ({
closeButton: rows.nth(i).findReact('Button'),
id: rows.nth(i).findReact('ItemCell').nth(1),
checkbox: rows.nth(i).findReact('ItemCell').withKey('_checkbox_column'),
closeButton: rows.nth(i).findReact('Button'),
id: rows.nth(i).findReact('ItemCell').nth(1),
openDate: rows.nth(i).findReact('ItemCell').nth(3),
closeDate: rows.nth(i).findReact('ItemCell').nth(4),
checkbox: rows.nth(i).findReact('ItemCell').withKey('_checkbox_column'),
}));
},

Expand Down
5 changes: 0 additions & 5 deletions integration_test/tests/src/tests/FindTransfersPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import { config } from '../config';
import { SideMenu } from '../page-objects/components/SideMenu';
import { VoodooClient, protocol } from 'mojaloop-voodoo-client';
import { v4 as uuidv4 } from 'uuid';
import { shim } from 'promise.any';

// At the time of writing, for some reason, in CI Promise.any is not working with
// > TypeError: Promise.any is not a function
shim();

fixture `Find Transfers Feature`
.page`${config.financePortalEndpoint}`
Expand Down
11 changes: 6 additions & 5 deletions integration_test/tests/src/tests/SettlementWindowsPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import { SideMenu } from '../page-objects/components/SideMenu';
import { VoodooClient, protocol } from 'mojaloop-voodoo-client';
import { v4 as uuidv4 } from 'uuid';
import * as assert from 'assert';
import { shim } from 'promise.any';

// At the time of writing, for some reason, in CI Promise.any is not working with
// > TypeError: Promise.any is not a function
shim();
const dateNotPresentRegex = /^-$|^$/;

const closeOpenSettlementWindow = async (t: TestController): Promise<string> => {
// TODO: [multi-currency] we expect a single window per currency. Here we assume a single
Expand Down Expand Up @@ -110,14 +107,16 @@ test.meta({
// remaining open window?
const resultRows = await SettlementWindowsPage.getResultRows();
await t.expect(resultRows.length).eql(1, 'Expected exactly one closed settlement window');
await t.expect(resultRows[0].openDate.innerText).notMatch(dateNotPresentRegex);
await t.expect(resultRows[0].closeDate.innerText).match(dateNotPresentRegex);
});

test.meta({
ID: '',
STORY: 'MMD-440',
Scenario:
`Close the single open settlement window, and expect the same window now shows up in a list of
closed windows`,
closed windows. Expect the closed windows in the list to display closed dates.`,
})('Close settlement window', async (t) => {
// TODO: consider comparing this with the ML API result? Or, instead, use the UI to set up a
// state that we expect, i.e. by closing all existing windows, then observing the single
Expand All @@ -134,6 +133,8 @@ test.meta({
).catch(() => {
throw new Error(`Couldn't find closed window with id ${settlementWindowId}`);
});
await t.expect(closedRows[0].openDate.innerText).notMatch(dateNotPresentRegex);
await t.expect(closedRows[0].closeDate.innerText).notMatch(dateNotPresentRegex);
});

test.meta({
Expand Down
5 changes: 0 additions & 5 deletions integration_test/tests/src/tests/SettlementsPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import { config } from '../config';
import { SideMenu } from '../page-objects/components/SideMenu';
import { VoodooClient, protocol } from 'mojaloop-voodoo-client';
import { v4 as uuidv4 } from 'uuid';
import { shim } from 'promise.any';

// At the time of writing, for some reason, in CI Promise.any is not working with
// > TypeError: Promise.any is not a function
shim();

fixture `Settlements Feature`
.page`${config.financePortalEndpoint}`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "finance-portal-v2-ui",
"version": "2.4.0",
"version": "2.4.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
7 changes: 5 additions & 2 deletions src/App/SettlementWindows/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ export function formatDate(date: string | undefined): string | undefined {
export function buildFiltersParams(filters: SettlementWindowFilters) {
return {
state: filters.state,
fromDateTime: filters.start ? moment(filters.start).toISOString() : undefined,
toDateTime: filters.end ? moment(filters.end).toISOString() : undefined,
// The default datetimes are the earliest and latest dates representable in the MySQL DATETIME
// type. The database *shouldn't* leak here, really, but these aren't insane "default" dates to
// have, in any case.
fromDateTime: filters.start ? moment(filters.start).toISOString() : '1000-01-01T00:00:00Z',
toDateTime: filters.end ? moment(filters.end).toISOString() : '9999-12-31T23:59:59Z',
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/App/SettlementWindows/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function* fetchSettlementWindows() {
) {
yield put(setSettlementWindows([]));
} else {
yield put(setSettlementWindows(response.data.map(helpers.mapApiToModel)));
yield put(setSettlementWindows(response.data));
}
} catch (e) {
yield put(setSettlementWindowsError(e.message));
Expand Down
7 changes: 5 additions & 2 deletions src/App/Settlements/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ export function zeroToDash(value: string | number): string | number {
export function buildFiltersParams(filters: SettlementFilters) {
return {
state: filters.state,
fromDateTime: filters.start ? moment(filters.start).toISOString() : undefined,
toDateTime: filters.end ? moment(filters.end).toISOString() : undefined,
// The default datetimes are the earliest and latest dates representable in the MySQL DATETIME
// type. The database *shouldn't* leak here, really, but these aren't insane "default" dates to
// have, in any case.
fromDateTime: filters.start ? moment(filters.start).toISOString() : '1000-01-01T00:00:00Z',
toDateTime: filters.end ? moment(filters.end).toISOString() : '9999-12-31T23:59:59Z',
};
}

Expand Down

0 comments on commit f1580c8

Please sign in to comment.