Skip to content

Commit

Permalink
Feat.refactor registration data (#5857)
Browse files Browse the repository at this point in the history
* Refactor registration data and attributes

Excel FSP: multiple per program (#5848)

* Excel FSP: multiple per program

* Program registration attribute portal (#5858)

* Frontend alligning to new registration attribute & fsp config change

Renamed portal models according to new data structure, registration attribtes & new fsp conig

Added missing import

Check voucher support with fspName instead of label

* Styling changes

---------

Co-authored-by: Ruben <vandervalk@geoit.nl>

* Fix.excel setup (#5970)

* fix: get match column correctly AB#30281

* fix: lingering case of StatusEnum AB#30281

* fix: do not duplicate response rows with multiple fspConfigs

* fix: api-test AB#30281

* fix: fix and unskip api-test on get fsp instructions AB#30281

* fix: api-test on snapshot AB#30281

* feat: return separate template file per fsp config

* fix: snapshot template api test

* chore: remove hasReconciliation

* chore: split off interface

* fix: resolve comments

---------

Co-authored-by: Ruben <vandervalk@geoit.nl>
Co-authored-by: jannisvisser <jannisvisser@redcross.nl>

Validate fsp config and required attributes for Registration data refactor (#5860)

* AB#30474 Validate fsp config and required attributes WIP

* AB#30474 & AB#30781 Validate registration with program registration attribute refactor

* Migrate refactored registration data and program attributes (#5977)

Migrations refactor registration data

Co-authored-by: Ruben <vandervalk@geoit.nl>

* Select the right kind of type while migrating program questions

* Changes based on comments on the new validation of registrations

* Expect required fsp attributes to be filled during payment

* chore: rm unused methods / unskip tests / typos (#6004)

---------

Co-authored-by: Ruben <vandervalk@geoit.nl>
Co-authored-by: jannisvisser <jannisvisser@redcross.nl>

fix: make seed mock script work again (#6003)

* fix: make seed mock script work again

* fix: revert to abbreviated sequence name

test: api-tests on update chosen fsp AB#31025 (#6006)

Fix.test data (#6015)

* fix: api-test excel

* fix: make test data work

* fix: calculate totalmultiplierSum in dryRun case

* fix: import of boolean attribute

Program fsp configs endpoints (#5989)

* Some initial refactor and draft code

Add code framework for endpoints

Get endpoint implementation done

WIP implement post endpoint

* Manage fsp config enpoints

* Comments jannis manage program fsp config

---------

Co-authored-by: Diderik van Wingerden <diderik@diderikvanwingerden.com>
Co-authored-by: Ruben <vandervalk@geoit.nl>

fix api & unit & e2e tests (#6010)

* WIP: fix api & unit tests

* Fixed playwright tests & typechecks after registration data refactor

* fix: getProgramWithManyAttributes + drop persistence (#6016)

Fixed playwright tests & typechecks after registration data refactor

fix: getProgramWithManyAttributes + drop persistence

fix: other k6 tests

chore: update import csv endpoint path + rm remnants of import-as-invited

test: add k6 test for import 1000 registrations

temp change GA k6 test file to import1000registrations to test length

typo

fix: small performance increase + set allowed duration + switch gh action test back to default one

Co-authored-by: Ruben <vandervalk@geoit.nl>

Enabled portal e2e tests again

* Fix bug in cbe query & added api test (#6031)

Co-authored-by: Ruben <vandervalk@geoit.nl>

* Api test for programFspConfigName is not equal to the fsp name (#6030)

* Api test for programFspConfigName is not equal to the fsp name

* Api test for programFspConfigName is not equal to the fsp name

* chore: update snapshot filename

---------

Co-authored-by: Ruben <vandervalk@geoit.nl>
Co-authored-by: jannisvisser <jannisvisser@redcross.nl>

* Refactor the code validateRequiredFinancialServiceProviderConfiguration (#6029)

Co-authored-by: Ruben <vandervalk@geoit.nl>

* Remove permissions for refactor registration data (#6034)

Co-authored-by: Ruben <vandervalk@geoit.nl>

* Refactor registration data processing comments on AB#30189

* Made api test less twitchy

* Out of date tests

* Allow non-required properties in the portal & change import registrat… (#6024)

* Allow non-required properties in the portal & change import registrations url

* Refactor registration data comment on non-required properties in portal

---------

Co-authored-by: Ruben <vandervalk@geoit.nl>

---------

Co-authored-by: Ruben <vandervalk@geoit.nl>
Co-authored-by: jannisvisser <jannisvisser@redcross.nl>

lint

fix import

Fix safaricom attributes

Chore.cleanup code (#6036)

* fix: rm lingering cases of program-question/custom-attribute/etc

* chore: more cleanup

* Fix.permission update fsp (#6041)

* fix: check specifically on update-fsp permission in patch endpoint

* test: api-test on bulk update chosen fsp

* fix: process PR comments

* portalicious: fix remaining endpoints (#6196)

AB#31660

---------

Co-authored-by: Ruben <vandervalk@geoit.nl>
Co-authored-by: Domenico Gemoli <dgemoli@redcross.nl>
  • Loading branch information
3 people authored Dec 2, 2024
1 parent 92e0b7c commit 6e2a9ec
Show file tree
Hide file tree
Showing 404 changed files with 16,566 additions and 14,601 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ node_modules

# TS Build output logs
*.tsbuildinfo

**/.DS_Store
104 changes: 59 additions & 45 deletions e2e/pages/PersonalInformationPopUp/PersonalInformationPopUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,12 @@ import { expect, Locator } from '@playwright/test';
import { Page } from 'playwright';

import englishTranslations from '@121-portal/src/assets/i18n/en.json';
import visaIntersolveTranslations from '@121-service/src/seed-data/fsp/fsp-intersolve-visa.json';
import programTestTranslations from '@121-service/src/seed-data/program/program-test.json';
import programTest from '@121-service/src/seed-data/program/program-test.json';

const updateSuccesfullNotification =
englishTranslations.common['update-success'];
const programWesterosQuestionName =
programTestTranslations.programQuestions[1].label.en;
const fspCahngeWarning =
englishTranslations['page'].program['program-people-affected'][
'edit-person-affected-popup'
].fspChangeWarning;
const visaQuestionStreet = visaIntersolveTranslations.questions[0].label.en;
const visaQuestionHouseNumberAddition =
visaIntersolveTranslations.questions[2].label.en;
const visaQuestionPostalCode = visaIntersolveTranslations.questions[3].label.en;
const visaQuestionCity = visaIntersolveTranslations.questions[4].label.en;
programTest.programRegistrationAttributes[1].label.en;

class PersonalInformationPopup {
readonly page: Page;
Expand Down Expand Up @@ -121,8 +111,29 @@ class PersonalInformationPopup {
const saveButton = this.page.getByRole('button', { name: saveButtonName });
const okButton = this.page.getByRole('button', { name: okButtonName });
const alertMessage = this.page.getByRole('alertdialog');
const fieldInput = fieldSelector.getByRole('textbox');
await fieldInput.fill(newValue);

// Locate the field input which can be a textbox, textarea, number input, phone input, select, or checkbox
const fieldInput = fieldSelector.locator(
'ion-input input, textarea, input[type="number"], input[type="tel"], ion-select, ion-checkbox',
);

if (
await fieldInput.evaluate(
(el) => el.tagName.toLowerCase() === 'ion-select',
)
) {
await fieldInput.selectOption(newValue);
} else if (
await fieldInput.evaluate(
(el) => el.tagName.toLowerCase() === 'ion-input',
)
) {
// Locate the native input element within ion-input
const nativeInput = fieldInput.locator('input');
await nativeInput.fill(newValue);
} else {
await fieldInput.fill(newValue);
}

await this.page.waitForLoadState('networkidle');
await fieldSelector.getByText(saveButtonName).click();
Expand Down Expand Up @@ -258,7 +269,7 @@ class PersonalInformationPopup {
}

async selectFspInputForm({ filterValue }: { filterValue: string }) {
const fieldSelector = this.personAffectedPopUpFsp;
const fieldSelector = this.editPersonAffectedPopUp;
const updatePropertyItem = fieldSelector.locator(
'app-update-property-item',
);
Expand All @@ -270,60 +281,63 @@ class PersonalInformationPopup {
return inputForm.getByRole('textbox');
}

async updateAttributeByLabel({
labelText,
newValue,
}: {
labelText: string;
newValue: string;
}) {
const saveButtonName = englishTranslations.common.save;
const okButtonName = englishTranslations.common.ok;
const labelElement = this.editPersonAffectedPopUp
.locator(`text=${labelText}`)
.first();
const parentElement = labelElement.locator('..').locator('..');

await this.updateField({
fieldSelector: parentElement,
newValue,
saveButtonName,
okButtonName,
reasonText: (newValue) => `Change ${labelText} to ${newValue}`,
});
}

async updatefinancialServiceProvider({
fspNewName,
fspOldName,
saveButtonName,
okButtonName,
newAttributes,
}: {
fspNewName: string;
fspOldName: string;
saveButtonName: string;
okButtonName: string;
newAttributes: { labelText: string; newValue: string }[];
}) {
// Loop over the attributes and update each one
for (const attribute of newAttributes) {
await this.updateAttributeByLabel({
labelText: attribute.labelText,
newValue: attribute.newValue,
});
}

const dropdown = this.page.getByRole('radio');
const warning = fspCahngeWarning;
const newValue = 'Nieuwe straat';
const fieldSelector = this.personAffectedPopUpFsp;
const okButton = this.page.getByRole('button', { name: okButtonName });
const streetAdressInput = await this.selectFspInputForm({
filterValue: visaQuestionStreet,
});
const numberAdditionInput = await this.selectFspInputForm({
filterValue: visaQuestionHouseNumberAddition,
});
const postalCodeInput = await this.selectFspInputForm({
filterValue: visaQuestionPostalCode,
});
const cityInput = await this.selectFspInputForm({
filterValue: visaQuestionCity,
});

await this.validateFspNamePresentInEditPopUp(fspOldName);
await this.financialServiceProviderDropdown.click();
await dropdown.getByText(fspNewName).click();

await this.validateFspWarningInEditPopUp(warning);

await streetAdressInput.fill(newValue);
await this.personAffectedHouseNumber.getByLabel('').click();
await this.personAffectedHouseNumber.getByLabel('').fill('2');
await numberAdditionInput.fill('D');
await postalCodeInput.fill('1234AB');
await cityInput.fill('Amsterdam');
await postalCodeInput.click();
await fieldSelector.getByText(saveButtonName).click();

await okButton.waitFor({ state: 'visible' });
await okButton.click();
}

async validateFspWarningInEditPopUp(warning: string) {
await this.page.waitForLoadState('networkidle');
const element = this.page.locator('ion-text.ion-padding.md.hydrated');
const text = await element.textContent();
expect(text).toContain(warning);
}
}

export default PersonalInformationPopup;
15 changes: 11 additions & 4 deletions e2e/pages/Table/TableModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import { Locator, Page } from 'playwright';
import * as XLSX from 'xlsx';

import englishTranslations from '@121-portal/src/assets/i18n/en.json';
import visaFspIntersolve from '@121-service/src/seed-data/fsp/fsp-intersolve-visa.json';
import { FinancialServiceProviders } from '@121-service/src/financial-service-providers/enum/financial-service-provider-name.enum';
import { FINANCIAL_SERVICE_PROVIDER_SETTINGS } from '@121-service/src/financial-service-providers/financial-service-providers-settings.const';

const fsp = FINANCIAL_SERVICE_PROVIDER_SETTINGS.find(
(fsp) => fsp.name === FinancialServiceProviders.intersolveVisa,
);

const labelVisaEn = fsp ? fsp.defaultLabel.en : undefined;

const paymentLabel =
englishTranslations.page.program['program-people-affected'].actions.doPayment;
Expand Down Expand Up @@ -472,7 +479,7 @@ class TableModule {

// Assert the values of the row
Object.entries(assertionData).forEach(([key, value]) => {
expect(rowToAssert[key]).toBe(value);
expect(rowToAssert![key]).toBe(value);
});
}

Expand All @@ -483,7 +490,7 @@ class TableModule {
for (let i = 1; i <= count; i++) {
const fsp = this.page.locator(TableModule.getRow(i));
const fspText = (await fsp.textContent())?.trim();
const isVisaFsp = fspText?.includes(visaFspIntersolve.displayName.en);
const isVisaFsp = fspText?.includes(labelVisaEn!);

if (
(shouldSelectVisa && isVisaFsp) ||
Expand All @@ -503,7 +510,7 @@ class TableModule {
for (let i = 1; i <= count; i++) {
const fsp = this.page.locator(TableModule.getRow(i));
const fspText = (await fsp.textContent())?.trim();
const isVisaFsp = fspText?.includes(visaFspIntersolve.displayName.en);
const isVisaFsp = fspText?.includes(labelVisaEn!);

if (
(shouldIncludeVisa && isVisaFsp) ||
Expand Down
51 changes: 34 additions & 17 deletions e2e/portalicious/pages/RegistrationsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const expectedColumnsSelectedRegistrationsExport = [
'paymentAmountMultiplier',
'paymentCount',
'registrationCreatedDate',
'fspDisplayName',
'programFinancialServiceProviderConfigurationLabel',
'scope',
'namePartnerOrganization',
'fullName',
Expand All @@ -42,7 +42,8 @@ const expectedColumnsDuplicateRegistrationsExport = [
'referenceId',
'id',
'status',
'fsp',
'financialServiceProviderName',
'programFinancialServiceProviderConfigurationLabel',
'scope',
'phoneNumber',
'whatsappPhoneNumber',
Expand All @@ -55,12 +56,12 @@ interface ExportPaAssertionData {
id: number;
paymentAmountMultiplier: number;
preferredLanguage: string;
fspDisplayName: string;
programFinancialServiceProviderConfigurationLabel: string;
whatsappPhoneNumber?: string;
}

interface ExportStatusAndDataChangesData {
paId: number;
referenceId: string;
changedBy: string;
type: string;
newValue: string;
Expand All @@ -70,7 +71,7 @@ interface ExportStatusAndDataChangesData {
interface ExportDuplicateRegistrationsData {
id: number;
status: string;
fsp: string;
programFinancialServiceProviderConfigurationLabel: string;
name: string;
duplicateWithIds: string;
}
Expand Down Expand Up @@ -318,11 +319,27 @@ class RegistrationsPage extends BasePage {
col.toLowerCase().trim(),
);

if (
!normalizedExpectedColumns.every((col) => actualColumns.includes(col)) ||
normalizedExpectedColumns.length !== actualColumns.length
) {
throw new Error('Column validation failed');
const missingColumns = normalizedExpectedColumns.filter(
(col) => !actualColumns.includes(col),
);
const extraColumns = actualColumns.filter(
(col) => !normalizedExpectedColumns.includes(col),
);

if (missingColumns.length > 0 || extraColumns.length > 0) {
const errorMessage = [
'Column validation failed:',
missingColumns.length > 0
? `Missing columns: ${missingColumns.join(', ')}`
: '',
extraColumns.length > 0
? `Extra columns: ${extraColumns.join(', ')}`
: '',
]
.filter(Boolean)
.join(' ');

throw new Error(errorMessage);
}

const mappedAssertionData = Object.keys(assertionData).reduce(
Expand Down Expand Up @@ -354,7 +371,7 @@ class RegistrationsPage extends BasePage {
id,
paymentAmountMultiplier,
preferredLanguage,
fspDisplayName,
programFinancialServiceProviderConfigurationLabel,
}: ExportPaAssertionData,
validateRowCount?: { condition: boolean; minRowCount: number },
) {
Expand All @@ -363,7 +380,7 @@ class RegistrationsPage extends BasePage {
id,
paymentAmountMultiplier,
preferredLanguage,
fspDisplayName,
programFinancialServiceProviderConfigurationLabel,
};
await this.exportAndAssertData(
expectedColumnsSelectedRegistrationsExport,
Expand All @@ -377,7 +394,7 @@ class RegistrationsPage extends BasePage {
async exportAndAssertStatusAndDataChanges(
registrationIndex: number,
{
paId,
referenceId,
changedBy,
type,
newValue,
Expand All @@ -386,7 +403,7 @@ class RegistrationsPage extends BasePage {
validateRowCount?: { condition: boolean; minRowCount: number },
) {
const assertionData = {
paId,
referenceId,
changedBy,
type,
newValue,
Expand All @@ -396,7 +413,7 @@ class RegistrationsPage extends BasePage {
expectedColumnsStatusAndDataChangesExport,
assertionData,
registrationIndex,
undefined,
referenceId,
validateRowCount,
);
}
Expand All @@ -406,7 +423,7 @@ class RegistrationsPage extends BasePage {
{
id,
status,
fsp,
programFinancialServiceProviderConfigurationLabel,
name,
duplicateWithIds,
}: ExportDuplicateRegistrationsData,
Expand All @@ -415,7 +432,7 @@ class RegistrationsPage extends BasePage {
const assertionData = {
id,
status,
fsp,
programFinancialServiceProviderConfigurationLabel,
name,
duplicateWithIds,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import RegistrationsPage from '@121-e2e/portalicious/pages/RegistrationsPage';
// Export duplicate registrations
const id = 2;
const status = 'included';
const fsp = 'Albert Heijn voucher WhatsApp';
const programFinancialServiceProviderConfigurationLabel =
'Albert Heijn voucher WhatsApp';
const name = 'Jan Janssen';
const duplicateWithIds = '3';

Expand Down Expand Up @@ -53,7 +54,7 @@ test('[29318] Export duplicate people affected list', async ({ page }) => {
await registrations.exportAndAssertDuplicates(0, {
id,
status,
fsp,
programFinancialServiceProviderConfigurationLabel,
name,
duplicateWithIds,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test('[29359] Export inclusion list with 15000 PAs', async ({ page }) => {
status,
paymentAmountMultiplier,
preferredLanguage,
fspDisplayName,
programFinancialServiceProviderConfigurationLabel: fspDisplayName,
},
{ condition: true, minRowCount: 15000 },
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import LoginPage from '@121-e2e/portalicious/pages/LoginPage';
import RegistrationsPage from '@121-e2e/portalicious/pages/RegistrationsPage';

// Export status & data changes
const paId = 4;
const changedBy = 'admin@example.org';
const type = 'registrationStatusChange';
const newValue = 'included';
Expand Down Expand Up @@ -51,7 +50,7 @@ test('[29337] Export all People Affected data changes', async ({ page }) => {
'Export status & data changes',
);
await registrations.exportAndAssertStatusAndDataChanges(0, {
paId,
referenceId: registrationsPV[0].referenceId, // Assert only the first registration
changedBy,
type,
newValue,
Expand Down
Loading

0 comments on commit 6e2a9ec

Please sign in to comment.