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

Feature/additional settlement tests #49

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
156 changes: 83 additions & 73 deletions integration_test/tests/src/tests/SettlementsPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,82 +47,92 @@ fixture `Settlements Feature`
.click(SideMenu.settlementWindowsButton); // yes, not the settlements button
});

test.meta({
ID: '',
STORY: 'MMD-440',
description:
`Close two settlement windows. Add them to a settlement. Settle the settlement.`,
})('Settle settlement containing two closed windows', async (t) => {
const { cli, participants } = t.fixtureCtx;
// Run a transfer to ensure the settlement window can be closed
const transfers1: protocol.TransferMessage[] = [{
msg_sender: participants[1].name,
msg_recipient: participants[0].name,
currency: 'MMK',
amount: '10',
transfer_id: uuidv4(),
}];
await cli.completeTransfers(transfers1);
const openWindows1 = await cli.getSettlementWindows({ state: "OPEN" });
await t.expect(openWindows1.length).eql(1, 'Expected only a single open window');
const closedSettlementWindowId1 = await cli.closeSettlementWindow({
id: openWindows1[0].settlementWindowId,
reason: 'Integration test',
});

// Run a transfer so the settlement window can be closed
const transfers2: protocol.TransferMessage[] = [{
msg_sender: participants[0].name,
msg_recipient: participants[1].name,
currency: 'MMK',
amount: '10',
transfer_id: uuidv4(),
}];
await cli.completeTransfers(transfers2);
const openWindows2 = await cli.getSettlementWindows({ state: "OPEN" });
await t.expect(openWindows2.length).eql(1, 'Expected only a single open window');
const closedSettlementWindowId2 = await cli.closeSettlementWindow({
id: openWindows2[0].settlementWindowId,
reason: 'Integration test',
});

const settlementWindowIds = [
closedSettlementWindowId1,
closedSettlementWindowId2,
];

const settlement = await cli.createSettlement({
reason: 'Integration test',
settlementModel: 'DEFERREDNET',
settlementWindows: settlementWindowIds.map((id) => ({ id })),
test.meta({
ID: '',
STORY: 'MMD-440',
description:
`Close two settlement windows. Add them to a settlement. Settle the settlement.`,
})('Settle settlement containing two closed windows', async (t) => {
const { cli, participants } = t.fixtureCtx;
// Run a transfer to ensure the settlement window can be closed
const transfers1: protocol.TransferMessage[] = [{
msg_sender: participants[1].name,
msg_recipient: participants[0].name,
currency: 'MMK',
amount: '10',
transfer_id: uuidv4(),
}];
await cli.completeTransfers(transfers1);
const openWindows1 = await cli.getSettlementWindows({ state: "OPEN" });
await t.expect(openWindows1.length).eql(1, 'Expected only a single open window');
const closedSettlementWindowId1 = await cli.closeSettlementWindow({
id: openWindows1[0].settlementWindowId,
reason: 'Integration test',
});

// Run a transfer so the settlement window can be closed
const transfers2: protocol.TransferMessage[] = [{
msg_sender: participants[0].name,
msg_recipient: participants[1].name,
currency: 'MMK',
amount: '10',
transfer_id: uuidv4(),
}];
await cli.completeTransfers(transfers2);
const openWindows2 = await cli.getSettlementWindows({ state: "OPEN" });
await t.expect(openWindows2.length).eql(1, 'Expected only a single open window');
const closedSettlementWindowId2 = await cli.closeSettlementWindow({
id: openWindows2[0].settlementWindowId,
reason: 'Integration test',
});

const settlementWindowIds = [
closedSettlementWindowId1,
closedSettlementWindowId2,
];

const settlement = await cli.createSettlement({
reason: 'Integration test',
settlementModel: 'DEFERREDNET',
settlementWindows: settlementWindowIds.map((id) => ({ id })),
});

await t.click(SideMenu.settlementsButton);

const rowsBefore = await SettlementsPage.getResultRows();
const settlementRowBefore = await Promise.any(rowsBefore.map(
(r) => r.id.innerText.then(id => Number(id) === settlement.id ? Promise.resolve(r) : Promise.reject()),
));
await t.expect(settlementRowBefore.state.innerText).eql('Pending Settlement');
await t.click(settlementRowBefore.finalizeButton);
await t.click(SettlementFinalizeModal.closeButton);
const rowsAfter = await SettlementsPage.getResultRows();
const settlementRowAfter = await Promise.any(rowsAfter.map(
(r) => r.id.innerText.then(id => Number(id) === settlement.id ? Promise.resolve(r) : Promise.reject()),
));
await t.expect(settlementRowAfter.state.innerText).eql('Settled');
});

await t.click(SideMenu.settlementsButton);

const rowsBefore = await SettlementsPage.getResultRows();
const settlementRowBefore = await Promise.any(rowsBefore.map(
(r) => r.id.innerText.then(id => Number(id) === settlement.id ? Promise.resolve(r) : Promise.reject()),
));
await t.expect(settlementRowBefore.state.innerText).eql('Pending Settlement');
await t.click(settlementRowBefore.finalizeButton);
await t.click(SettlementFinalizeModal.closeButton);
const rowsAfter = await SettlementsPage.getResultRows();
const settlementRowAfter = await Promise.any(rowsAfter.map(
(r) => r.id.innerText.then(id => Number(id) === settlement.id ? Promise.resolve(r) : Promise.reject()),
));
await t.expect(settlementRowAfter.state.innerText).eql('Settled');
});


test.skip.meta({
ID: '',
STORY: 'MMD-440',
})(
`Once I click Settlement tab in Side Menu, the page on the right should come up with
test.meta({
ID: '',
STORY: 'MMD-440',
Scenario: `Once I click Settlement tab in Side Menu, the page on the right should come up with
Date drop-down defaulted to Today, From and To drop-down defaulted to current date in MM/DD/YYYY HH:MM:SS format
State should be empty and Clear Filters button`,
async (t) => {
//Call Mojaloop Settlement API to get the current window details
// Check that the latest window ID that displays on the page is the same
},
);
State should be empty and Clear Filters button`
})(
'Default landing page', async (t) => {

});

test.meta({
ID: '',
STORY: 'MMD-440',
Scenario: `The following options should be available for State column drop-down, Pending Settlement
Ps Transfers Recorded, Ps Transfers Reserved, Ps Transfers Committed, Settling, Settled, Aborted`
})(
'State Column drop-down options', async (t) => {

});