Skip to content

Commit

Permalink
fix: resolve CRs
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrogelmi committed Mar 29, 2024
1 parent d8018a7 commit 306458f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
7 changes: 1 addition & 6 deletions packages/pn-commons/src/models/MixpanelEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ export type TrackedEvent<T extends object | undefined = undefined> = T extends u
? Partial<Record<EventPropertyType, BaseTrackedEvent | string | boolean>>
: Partial<Record<EventPropertyType, (BaseTrackedEvent & T) | string | boolean>>;

export type ProfileMapAttributes = {
profilePropertyType: Array<EventPropertyType>;
getAttributes: (payload?: any, meta?: any) => Record<string, string>;
shouldBlock?: (payload?: any, meta?: any) => boolean;
};

export type ActionMeta = {
requestId: string;
requestStatus: string;
Expand Down Expand Up @@ -119,6 +113,7 @@ export type EventCreatedDelegationType = {
mandate_type: string;
};

// TODO: review that enum when implementing PG events
export enum EventPaymentRecipientType {
SEND_PAYMENT_DETAIL_REFRESH = 'SEND_PAYMENT_DETAIL_REFRESH',
SEND_CANCELLED_NOTIFICATION_REFOUND_INFO = 'SEND_CANCELLED_NOTIFICATION_REFOUND_INFO',
Expand Down
2 changes: 0 additions & 2 deletions packages/pn-commons/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
EventPaymentStatusType,
EventPropertyType,
EventsType,
ProfileMapAttributes,
TrackedEvent,
} from './MixpanelEvents';
import {
Expand Down Expand Up @@ -198,7 +197,6 @@ export type {
PartyEntityWithUrl,
Product,
PaymentCache,
ProfileMapAttributes,
TrackedEvent,
EventStrategy,
EventType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { EventPropertyType } from '@pagopa-pn/pn-commons';

import { arrayOfDelegators } from '../../../../__mocks__/Delegations.mock';
import { DelegationStatus } from '../../../status.utility';
import { SendHasMandateGivenStrategy } from '../SendHasMandateGivensStrategy';

describe('Mixpanel - Has Mandate Given Strategy', () => {
Expand All @@ -11,10 +10,18 @@ describe('Mixpanel - Has Mandate Given Strategy', () => {
const mandateGiven = strategy.performComputations({ payload: arrayOfDelegators });
expect(mandateGiven).toEqual({
[EventPropertyType.PROFILE]: {
SEND_MANDATE_GIVEN:
arrayOfDelegators.filter((d) => d.status === DelegationStatus.ACTIVE).length > 0
? 'yes'
: 'no',
SEND_MANDATE_GIVEN: 'yes',
},
});
});

it('should return no if there are no active mandates', () => {
const strategy = new SendHasMandateGivenStrategy();

const mandateGiven = strategy.performComputations({ payload: [] });
expect(mandateGiven).toEqual({
[EventPropertyType.PROFILE]: {
SEND_MANDATE_GIVEN: 'no',
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ describe('Mixpanel - Has Mandate Login Strategy', () => {
const mandateGiven = strategy.performComputations({ payload: arrayOfDelegators });
expect(mandateGiven).toEqual({
[EventPropertyType.PROFILE]: {
SEND_HAS_MANDATE: arrayOfDelegators.length > 0 ? 'yes' : 'no',
SEND_HAS_MANDATE: 'yes',
},
});
});

it('should return no if there are no active mandates', () => {
const strategy = new SendHasMandateLoginStrategy();

const mandateGiven = strategy.performComputations({ payload: [] });
expect(mandateGiven).toEqual({
[EventPropertyType.PROFILE]: {
SEND_HAS_MANDATE: 'no',
},
});
});
Expand Down

0 comments on commit 306458f

Please sign in to comment.