department-of-veterans-affairs/vets-website

View on GitHub
src/platform/mhv/api/mocks/user/index.js

Summary

Maintainability
F
5 days
Test Coverage
const defaultUser = {
  data: {
    id: '',
    type: 'user',
    attributes: {
      services: [
        'facilities',
        'hca',
        'edu-benefits',
        'form-save-in-progress',
        'form-prefill',
        'rx',
        'messaging',
        'medical-records',
        'health-records',
        'user-profile',
        'appeals-status',
        'identity-proofed',
        'vet360',
      ],
      account: {
        accountUuid: 'dcfcbb38-4879-4406-bfaf-2d86a62d9117',
      },
      profile: {
        email: 'marufsystb2allergy@id.me',
        firstName: 'Veteran',
        middleName: null,
        lastName: 'Maveteran',
        preferredName: 'VeeMav',
        birthDate: '1974-04-06',
        gender: 'M',
        zip: null,
        lastSignedIn: '2024-10-29T14:13:12.505Z',
        loa: {
          current: 3,
          highest: 3,
        },
        multifactor: true,
        verified: true,
        signIn: {
          serviceName: 'idme',
          clientId: 'vaweb',
          authBroker: 'sis',
        },
        authnContext: 'http://idmanagement.gov/ns/assurance/loa/3',
        claims: {
          appeals: true,
          coe: false,
          communicationPreferences: true,
          connectedApps: true,
          medicalCopays: false,
          militaryHistory: false,
          paymentHistory: false,
          personalInformation: true,
          ratingInfo: false,
          form526RequiredIdentifierPresence: {
            participantId: false,
            birlsId: false,
            ssn: true,
            birthDate: true,
            edipi: false,
          },
        },
        icn: '1013884191V012082',
        birlsId: null,
        edipi: null,
        secId: '1013884191',
        logingovUuid: null,
        idmeUuid: 'fd8efa99032b46b98beabac7b831f012',
        idTheftFlag: false,
        initialSignIn: '2023-09-13T18:49:23.788Z',
      },
      vaProfile: {
        status: 'OK',
        birthDate: '19740406',
        familyName: 'Maveteran',
        gender: 'M',
        givenNames: ['Veteran'],
        isCernerPatient: false,
        cernerId: null,
        cernerFacilityIds: [],
        facilities: [
          {
            facilityId: '979',
            isCerner: false,
          },
        ],
        vaPatient: true,
        mhvAccountState: 'MULTIPLE',
        activeMHVIds: ['22461761', '22461761'],
      },
      veteranStatus: null,
      inProgressForms: [],
      prefillsAvailable: [
        '21-686C',
        '40-10007',
        '0873',
        '22-1990',
        '22-1990N',
        '22-1990E',
        '22-1990EMEB',
        '22-1995',
        '22-5490',
        '22-5490E',
        '22-5495',
        '22-0993',
        '22-0994',
        'FEEDBACK-TOOL',
        '22-10203',
        '22-1990S',
        '22-1990EZ',
        '21-526EZ',
        '1010ez',
        '10-10EZR',
        '21P-530',
        '21P-527EZ',
        '21P-530EZ',
        '686C-674',
        '20-0995',
        '20-0996',
        '10182',
        'MDOT',
        '5655',
        '28-8832',
        '28-1900',
        '26-1880',
        '26-4555',
        '21-0966',
        '10-7959C',
        'FORM-UPLOAD-FLOW',
        '21-22',
        '21-22A',
        'FORM-MOCK-AE-DESIGN-PATTERNS',
      ],
      vet360ContactInformation: {
        vet360Id: '1513621',
        email: null,
        residentialAddress: null,
        mailingAddress: null,
        mobilePhone: null,
        homePhone: null,
        workPhone: null,
        temporaryPhone: null,
        faxNumber: null,
        textPermission: null,
      },
      session: {
        authBroker: 'sis',
        ssoe: false,
        transactionid: null,
      },
      onboarding: {
        show: null,
      },
    },
  },
  meta: {
    errors: [
      {
        externalService: 'VAProfile',
        startTime: '2024-10-29T14:14:14Z',
        endTime: null,
        description:
          'RuntimeError, User does not have a valid edipi, User does not have a valid edipi',
        status: 503,
      },
    ],
  },
};

const cernerUser = {
  data: {
    attributes: {
      profile: {
        signIn: {
          serviceName: 'idme',
        },
        email: 'fake@fake.com',
        loa: { current: 3 },
        firstName: 'Cersei',
        middleName: '',
        lastName: 'Smith',
        gender: 'F',
        birthDate: '1985-01-01',
        verified: true,
      },
      veteranStatus: {
        status: 'OK',
        isVeteran: true,
        servedInMilitary: true,
      },
      inProgressForms: [],
      prefillsAvailable: ['21-526EZ'],
      services: [
        'facilities',
        'hca',
        'edu-benefits',
        'evss-claims',
        'form526',
        'user-profile',
        'health-records',
        'rx',
        'messaging',
        'medical-records',
      ],
      vaProfile: {
        status: 'OK',
        birthDate: '19511118',
        familyName: 'Hunter',
        gender: 'M',
        givenNames: ['Julio', 'E'],
        activeStatus: 'active',
        facilities: [
          {
            facilityId: '983',
            isCerner: false,
          },
          {
            facilityId: '984',
            isCerner: false,
          },
          {
            facilityId: '757',
            isCerner: true,
          },
        ],
      },
    },
  },
  meta: { errors: null },
};

const acceleratedCernerUser = {
  data: {
    id: '',
    type: 'user',
    attributes: {
      services: [
        'facilities',
        'hca',
        'edu-benefits',
        'form-save-in-progress',
        'form-prefill',
        'add-person',
        'user-profile',
        'appeals-status',
        'identity-proofed',
        'vet360',
        'medical-records',
      ],
      account: {
        accountUuid: '9b8a5a1f-d99f-4e03-9b43-4c689f3e4f00',
      },
      profile: {
        email: 'vagovohtestpatient+morkel@gmail.com',
        firstName: 'Andrew- Cerner',
        middleName: 'J',
        lastName: 'Morkel',
        birthDate: '1968-11-12',
        gender: 'M',
        zip: '85705',
        lastSignedIn: '2024-10-22T18:43:42.631Z',
        loa: {
          current: 3,
          highest: 3,
        },
        multifactor: true,
        verified: true,
        signIn: {
          serviceName: 'idme',
          clientId: 'vaweb',
          authBroker: 'sis',
        },
        authnContext: 'http://idmanagement.gov/ns/assurance/loa/3',
        claims: {
          appeals: true,
          coe: true,
          communicationPreferences: true,
          connectedApps: true,
          medicalCopays: true,
          militaryHistory: true,
          paymentHistory: false,
          personalInformation: true,
          ratingInfo: false,
          form526RequiredIdentifierPresence: {
            participantId: false,
            birlsId: false,
            ssn: true,
            birthDate: true,
            edipi: true,
          },
        },
        icn: '1013949209V185925',
        birlsId: null,
        edipi: '2116564958',
        secId: '1013949209',
        logingovUuid: null,
        idmeUuid: '0ef475cab2fb4df4bb79b8de6aca22dc',
        idTheftFlag: false,
        initialSignIn: '2024-05-07T18:15:52.894Z',
      },
      vaProfile: {
        status: 'OK',
        birthDate: '19681112',
        familyName: 'Morkel',
        gender: 'M',
        givenNames: ['Andrew', 'J'],
        isCernerPatient: true,
        cernerId: '2116564958',
        cernerFacilityIds: ['556'],
        facilities: [
          {
            facilityId: '556',
            isCerner: true,
          },
        ],
        vaPatient: true,
        mhvAccountState: 'OK',
        activeMHVIds: [],
      },
      veteranStatus: {
        status: 'OK',
        isVeteran: false,
        servedInMilitary: false,
      },
      inProgressForms: [],
      prefillsAvailable: [
        '21-686C',
        '40-10007',
        '0873',
        '22-1990',
        '22-1990N',
        '22-1990E',
        '22-1990EMEB',
        '22-1995',
        '22-5490',
        '22-5490E',
        '22-5495',
        '22-0993',
        '22-0994',
        'FEEDBACK-TOOL',
        '22-10203',
        '22-1990S',
        '22-1990EZ',
        '21-526EZ',
        '1010ez',
        '10-10EZR',
        '21P-530',
        '21P-527EZ',
        '21P-530EZ',
        '686C-674',
        '20-0995',
        '20-0996',
        '10182',
        'MDOT',
        '5655',
        '28-8832',
        '28-1900',
        '26-1880',
        '26-4555',
        '21-0966',
        '10-7959C',
        'FORM-UPLOAD-FLOW',
        '21-22',
        '21-22A',
        'FORM-MOCK-AE-DESIGN-PATTERNS',
      ],
      vet360ContactInformation: {
        vet360Id: '1548469',
        email: {
          createdAt: '2023-11-16T15:59:19.000Z',
          emailAddress: 'MORKEL4455@YAHOO.COM',
          effectiveEndDate: null,
          effectiveStartDate: '2023-11-16T15:58:15.000Z',
          id: 275981,
          sourceDate: '2023-11-16T15:58:15.000Z',
          sourceSystemUser: null,
          transactionId: '14b683c7-38c3-4679-9f19-137fdb78eada',
          updatedAt: '2023-11-16T15:59:19.000Z',
          vet360Id: '1548469',
          vaprofileId: null,
        },
        residentialAddress: {
          addressLine1: '11516 Sethwarner Dr',
          addressLine2: null,
          addressLine3: null,
          addressPou: 'RESIDENCE/CHOICE',
          addressType: 'DOMESTIC',
          city: 'Glen Allen',
          countryName: 'United States',
          countryCodeIso2: 'US',
          countryCodeIso3: 'USA',
          countryCodeFips: null,
          countyCode: '51087',
          countyName: 'Henrico County',
          createdAt: '2024-02-16T19:01:58.000Z',
          effectiveEndDate: null,
          effectiveStartDate: '2024-02-16T19:01:55.000Z',
          geocodeDate: '2024-02-16T19:01:58.000Z',
          geocodePrecision: 32.0,
          id: 506768,
          internationalPostalCode: null,
          latitude: 37.6834,
          longitude: -77.5104,
          province: null,
          sourceDate: '2024-02-16T19:01:55.000Z',
          sourceSystemUser: null,
          stateCode: 'VA',
          transactionId: '156ab419-a5e7-43a3-81e0-50a8d9c24797',
          updatedAt: '2024-02-16T19:01:58.000Z',
          validationKey: null,
          vet360Id: '1548469',
          zipCode: '23059',
          zipCodeSuffix: '4805',
          badAddress: false,
        },
        mailingAddress: {
          addressLine1: '11516 Sethwarner Dr',
          addressLine2: null,
          addressLine3: null,
          addressPou: 'CORRESPONDENCE',
          addressType: 'DOMESTIC',
          city: 'Glen Allen',
          countryName: 'United States',
          countryCodeIso2: 'US',
          countryCodeIso3: 'USA',
          countryCodeFips: null,
          countyCode: '51087',
          countyName: 'Henrico County',
          createdAt: '2024-02-16T19:01:58.000Z',
          effectiveEndDate: null,
          effectiveStartDate: '2024-02-16T19:01:55.000Z',
          geocodeDate: '2024-02-16T19:01:58.000Z',
          geocodePrecision: 32.0,
          id: 506809,
          internationalPostalCode: null,
          latitude: 37.6834,
          longitude: -77.5104,
          province: null,
          sourceDate: '2024-02-16T19:01:55.000Z',
          sourceSystemUser: null,
          stateCode: 'VA',
          transactionId: '156ab419-a5e7-43a3-81e0-50a8d9c24797',
          updatedAt: '2024-02-16T19:01:58.000Z',
          validationKey: null,
          vet360Id: '1548469',
          zipCode: '23059',
          zipCodeSuffix: '4805',
          badAddress: false,
        },
        mobilePhone: null,
        homePhone: null,
        workPhone: null,
        temporaryPhone: null,
        faxNumber: null,
        textPermission: null,
      },
      session: {
        authBroker: 'sis',
        ssoe: false,
        transactionid: null,
      },
      onboarding: {
        show: null,
      },
    },
  },
  meta: {
    errors: null,
  },
};

const generateUserWithFacilities = ({ facilities = [], name = 'Harry' }) => {
  const vaPatient = facilities.length > 0;
  return {
    ...defaultUser,
    data: {
      ...defaultUser.data,
      attributes: {
        ...defaultUser.data.attributes,
        vaProfile: {
          ...defaultUser.data.attributes.va_profile,
          facilities,
          vaPatient,
        },
        profile: {
          ...defaultUser.data.attributes.profile,
          facilities,
          firstName: name,
        },
      },
    },
  };
};

const generateUserWithServiceProvider = ({ serviceProvider = 'idme' }) => {
  return {
    ...defaultUser,
    data: {
      ...defaultUser.data,
      attributes: {
        ...defaultUser.data.attributes,
        profile: {
          ...defaultUser.data.attributes.profile,
          signIn: {
            serviceName: serviceProvider,
          },
        },
      },
    },
  };
};

const generateUser = ({ serviceProvider = 'idme', facilities, loa = 3 }) => {
  return {
    ...defaultUser,
    data: {
      ...defaultUser.data,
      attributes: {
        ...defaultUser.data.attributes,
        vaProfile: {
          ...defaultUser.data.attributes.va_profile,
          facilities:
            facilities || defaultUser.data.attributes.va_profile.facilities,
        },
        profile: {
          ...defaultUser.data.attributes.profile,
          loa: { current: loa },
          signIn: {
            serviceName: serviceProvider,
          },
        },
      },
    },
  };
};

const noFacilityUser = generateUserWithFacilities({ facilities: [] });

module.exports = {
  defaultUser,
  cernerUser,
  noFacilityUser,
  acceleratedCernerUser,
  generateUser,
  generateUserWithServiceProvider,
  generateUserWithFacilities,
};