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

E2E test for reconciliation data import #6519

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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: 1 addition & 1 deletion e2e/portalicious/components/TableComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class TableComponent {
await this.applyFiltersButton.click();
}

async filterColumnByDopDownSelection({
async filterColumnByDropDownSelection({
columnName,
selection,
}: {
Expand Down
11 changes: 11 additions & 0 deletions e2e/portalicious/pages/BasePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class BasePage {
readonly accountDropdown: Locator;
readonly formError: Locator;
readonly toast: Locator;
readonly chooseFileButton: Locator;

constructor(page: Page) {
this.page = page;
Expand All @@ -28,6 +29,9 @@ class BasePage {
this.accountDropdown = this.page.getByRole('button', { name: 'Account' });
this.formError = this.page.getByTestId('form-error');
this.toast = this.page.getByRole('alert');
this.chooseFileButton = this.page.getByRole('button', {
name: 'Choose file',
});
}

async openSidebar() {
Expand Down Expand Up @@ -93,6 +97,13 @@ class BasePage {
async openCreateNewProject() {
await this.page.getByRole('button', { name: 'Add project' }).click();
}

async chooseAndUploadFile(filePath: string) {
const fileChooserPromise = this.page.waitForEvent('filechooser');
await this.chooseFileButton.click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(filePath);
}
}

export default BasePage;
41 changes: 34 additions & 7 deletions e2e/portalicious/pages/PaymentsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ class PaymentsPage extends BasePage {
readonly paymentSummaryMetrics: Locator;
readonly paymentSummaryWithInstructions: Locator;
readonly exportFspPaymentListButton: Locator;
readonly exportDropdown: Locator;
readonly exportButton: Locator;
readonly importReconcilationDataButton: Locator;
readonly chooseFileButton: Locator;
readonly importFileButton: Locator;
readonly proceedButton: Locator;
readonly viewPaymentTitle: Locator;
readonly paymentAmount: Locator;
Expand Down Expand Up @@ -43,10 +46,21 @@ class PaymentsPage extends BasePage {
this.paymentSummaryWithInstructions = this.page.getByTestId(
'create-payment-excel-fsp-instructions',
);
this.exportFspPaymentListButton = this.page.getByRole('button', {
name: 'Export FSP payment list',
this.exportFspPaymentListButton = this.page.getByLabel(
'Export FSP payment list',
);
this.exportButton = this.page.getByRole('button', {
name: 'Export',
});
this.importReconcilationDataButton = this.page.getByRole('button', {
name: 'Import reconciliation data',
});
this.chooseFileButton = this.page.getByRole('button', {
name: 'Choose file',
});
this.importFileButton = this.page.getByRole('button', {
name: 'Import file',
});
this.exportDropdown = this.page.locator('app-single-payment-export');
this.proceedButton = this.page.getByRole('button', { name: 'Proceed' });
this.viewPaymentTitle = this.page.getByRole('heading', {
name: 'Payment',
Expand Down Expand Up @@ -189,7 +203,7 @@ class PaymentsPage extends BasePage {
}
}
async selectPaymentExportOption({ option }: { option: string }) {
await this.exportDropdown.click();
await this.exportButton.click();
await this.page.getByRole('menuitem', { name: option }).click();
}

Expand Down Expand Up @@ -236,8 +250,8 @@ class PaymentsPage extends BasePage {
await expect(this.retryFailedTransfersButton).toBeHidden();
}

async retryFiledTransfers() {
await this.table.filterColumnByDopDownSelection({
async retryFailedTransfers() {
await this.table.filterColumnByDropDownSelection({
columnName: 'Transfer status',
selection: 'Failed',
});
Expand All @@ -248,6 +262,19 @@ class PaymentsPage extends BasePage {

await this.popupRetryTransferButton.click();
}

async importReconciliationData(filePath: string) {
await this.importReconcilationDataButton.click();

await this.chooseAndUploadFile(filePath);

await this.importFileButton.click();
}

async exportFspPaymentList() {
await this.exportButton.click();
await this.exportFspPaymentListButton.click();
}
}

export default PaymentsPage;
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test('[32302] [Excel fsp]: Error message should be shown in case no matching col
await paymentsPage.validateExcelFspInstructions();
});

await test.step('Do payment', async () => {
await test.step('Start payment and validate Error message', async () => {
await paymentsPage.validatePaymentSummary({
fsp: financialServiceProviders,
registrationsNumber: numberOfPas,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { test } from '@playwright/test';
import { format } from 'date-fns';
import path from 'path';

import { SeedScript } from '@121-service/src/scripts/enum/seed-script.enum';
import NLRCProgramPV from '@121-service/src/seed-data/program/program-nlrc-pv.json';
import { seedIncludedRegistrations } from '@121-service/test/helpers/registration.helper';
import {
getAccessToken,
resetDB,
} from '@121-service/test/helpers/utility.helper';
import {
programIdPV,
registrationsPvExcel,
} from '@121-service/test/registrations/pagination/pagination-data';

import LoginPage from '@121-e2e/portalicious/pages/LoginPage';
import PaymentsPage from '@121-e2e/portalicious/pages/PaymentsPage';

test.beforeEach(async ({ page }) => {
await resetDB(SeedScript.nlrcMultiple);
const accessToken = await getAccessToken();
await seedIncludedRegistrations(
registrationsPvExcel,
programIdPV,
accessToken,
);

// Login
const loginPage = new LoginPage(page);
await page.goto('/');
await loginPage.login(
process.env.USERCONFIG_121_SERVICE_EMAIL_ADMIN,
process.env.USERCONFIG_121_SERVICE_PASSWORD_ADMIN,
);
});

test('[32303] [Excel fsp]: Import reconciliation data should work similar to import registration data', async ({
page,
}) => {
const paymentsPage = new PaymentsPage(page);

const projectTitle = NLRCProgramPV.titlePortal.en;
const lastPaymentDate = `${format(new Date(), 'dd/MM/yyyy')}`;
const reconciliationData = path.resolve(
__dirname,
'../../../test-registration-data/test-reconciliation-Excel-pv.csv',
);

await test.step('Navigate to Program payments', async () => {
await paymentsPage.selectProgram(projectTitle);

await paymentsPage.navigateToProgramPage('Payments');
});

await test.step('Start payment', async () => {
await paymentsPage.createPayment();
await paymentsPage.startPayment();
// Assert redirection to payment overview page
await page.waitForURL((url) =>
url.pathname.startsWith(`/en-GB/project/${programIdPV}/payments/1`),
);
// Assert payment overview page by payment date/ title
await paymentsPage.validatePaymentsDetailsPageByDate(lastPaymentDate);
});

await test.step('Upload payment reconciliation data via UI', async () => {
await paymentsPage.importReconciliationData(reconciliationData);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test('[32300] Retry failed transfers', async ({ page }) => {
'automated test',
accessToken,
);
await paymentsPage.retryFiledTransfers();
await paymentsPage.retryFailedTransfers();
});

// DO NOT MAKE IT A RULE!!!
Expand Down
100 changes: 100 additions & 0 deletions e2e/portalicious/tests/ViewPayment/RetryPaymentWithExcelFsp.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { test } from '@playwright/test';
import { format } from 'date-fns';
import path from 'path';

import { SeedScript } from '@121-service/src/scripts/enum/seed-script.enum';
import NLRCProgramPV from '@121-service/src/seed-data/program/program-nlrc-pv.json';
import { seedIncludedRegistrations } from '@121-service/test/helpers/registration.helper';
import {
getAccessToken,
resetDB,
} from '@121-service/test/helpers/utility.helper';
import {
programIdPV,
registrationsPvExcel,
} from '@121-service/test/registrations/pagination/pagination-data';

import LoginPage from '@121-e2e/portalicious/pages/LoginPage';
import PaymentsPage from '@121-e2e/portalicious/pages/PaymentsPage';
import RegistrationsPage from '@121-e2e/portalicious/pages/RegistrationsPage';

// Export Excel FSP payment list
const amount = NLRCProgramPV.fixedTransferValue;
const fullName = registrationsPvExcel[2].fullName;
const addressStreet = registrationsPvExcel[2].addressStreet;
const addressHouseNumber = registrationsPvExcel[2].addressHouseNumber;
const addressPostalCode = registrationsPvExcel[2].addressPostalCode;

test.beforeEach(async ({ page }) => {
await resetDB(SeedScript.nlrcMultiple);
const accessToken = await getAccessToken();
await seedIncludedRegistrations(
registrationsPvExcel,
programIdPV,
accessToken,
);

// Login
const loginPage = new LoginPage(page);
await page.goto('/');
await loginPage.login(
process.env.USERCONFIG_121_SERVICE_EMAIL_ADMIN,
process.env.USERCONFIG_121_SERVICE_PASSWORD_ADMIN,
);
});

test('[32304] Retry payments should put failed transactions back in pending and download the payment instructions file for those pending transactions', async ({
page,
}) => {
const paymentsPage = new PaymentsPage(page);
const registrationsPage = new RegistrationsPage(page);

const projectTitle = NLRCProgramPV.titlePortal.en;
const lastPaymentDate = `${format(new Date(), 'dd/MM/yyyy')}`;
const reconciliationData = path.join(
__dirname,
'../../../test-registration-data/test-reconciliation-Excel-pv.csv',
);

await test.step('Navigate to Program payments', async () => {
await paymentsPage.selectProgram(projectTitle);

await paymentsPage.navigateToProgramPage('Payments');
});

await test.step('Do payment', async () => {
await paymentsPage.createPayment();
await paymentsPage.startPayment();
// Assert redirection to payment overview page
await page.waitForURL((url) =>
url.pathname.startsWith(`/en-GB/project/${programIdPV}/payments/1`),
);
// Assert payment overview page by payment date/ title
await paymentsPage.validatePaymentsDetailsPageByDate(lastPaymentDate);
});

await test.step('Upload payment reconciliation data & Retry Payment', async () => {
await paymentsPage.importReconciliationData(reconciliationData);
});

await test.step('Retry payment, Export FSP payment data and assert file', async () => {
await paymentsPage.validateRetryFailedTransfersButtonToBeVisible();
// Timeout has to be used in this case because choose option is not visible immediately after the dropdown button is clicked
await page.waitForTimeout(200);
await paymentsPage.retryFailedTransfers();
// Start download of the payment instructions file
await paymentsPage.exportFspPaymentList();
// Assert excel fsp list it should only include the failed transactions that were retried and are now in status pending
await registrationsPage.exportAndAssertExcelFspList(
0,
{
amount,
fullName,
addressStreet,
addressHouseNumber,
addressPostalCode,
},
{ condition: true, rowCount: 2 },
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ test('[32298] Table should be a filtered list of registrations included in the t
await table.clearAllFilters();

// Apply filter for FSP
await table.filterColumnByDopDownSelection({
await table.filterColumnByDropDownSelection({
columnName: 'FSP',
selection: 'Albert Heijn voucher WhatsApp',
});
Expand Down
5 changes: 5 additions & 0 deletions e2e/test-registration-data/test-reconciliation-Excel-pv.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
phoneNumber;status
14155235551;success
14155235552;success
14155235553;error
14155235557;error
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ export const registrationPvExcel2 = {
preferredLanguage: LanguageEnum.nl,
paymentAmountMultiplier: 1,
fullName: 'Jan Janssen',
phoneNumber: '14155235551',
phoneNumber: '14155235552',
programFinancialServiceProviderConfigurationName:
FinancialServiceProviders.excel,
whatsappPhoneNumber: '14155235551',
whatsappPhoneNumber: '14155235552',
addressStreet: 'Teststraat',
addressHouseNumber: '1',
addressHouseNumberAddition: '',
Expand All @@ -319,10 +319,10 @@ export const registrationPvExcel3 = {
preferredLanguage: LanguageEnum.nl,
paymentAmountMultiplier: 1,
fullName: 'Joost Herlembach',
phoneNumber: '14155235551',
phoneNumber: '14155235553',
programFinancialServiceProviderConfigurationName:
FinancialServiceProviders.excel,
whatsappPhoneNumber: '14155235551',
whatsappPhoneNumber: '14155235553',
addressStreet: 'Teststraat',
addressHouseNumber: '1',
addressHouseNumberAddition: '',
Expand Down
Loading