Dashboard API explorer

/api/user/create-profile (POST)

Account information like email addresses is generated with faker-js it is not real user information.

await global.api.user.CreateProfile.post(req)

Returns object

{
  "profileid": "prof_85c4ab238086a0c1",
  "object": "profile",
  "appid": "tests_1656038575",
  "accountid": "acct_1ea11afc71452f0b",
  "companyName": "Test company",
  "fullName": "Test Person",
  "contactEmail": "test1@test.com",
  "displayEmail": "test2@test.com",
  "displayName": "tester",
  "phone": "456-789-0123",
  "occupation": "Programmer",
  "location": "USA",
  "dob": "2000-01-01",
  "website": "https://example.com",
  "fields": null,
  "createdAt": "2022-06-24T02:42:55.991Z",
  "updatedAt": "2022-06-24T02:42:55.991Z"
}

Receives

API routes may receive parameters from the URL and POST supporting simple and multipart:

Field Value Required Type
company-name string configurable as required POST
contact-email string configurable as required POST
display-email string configurable as required POST
display-name string configurable as required POST
dob string configurable as required POST
full-name string configurable as required POST
location string configurable as required POST
occupation string configurable as required POST
phone string configurable as required POST

Exceptions

These exceptions are thrown (NodeJS) or returned as JSON (HTTP) if you provide incorrect data or do not meet the requirements:

Exception Circumstances
invalid-accountid missing querystring accountid
invalid querystring accountid
ineligible accessing account
invalid-company-name-length posted company-name too short
posted company-name too long
invalid-contact-email missing posted contact-email
invalid-display-email missing posted display-email
invalid-display-name missing posted display-name
invalid-display-name-length posted display-name too short
posted display-name too long
invalid-dob missing posted dob
invalid-full-name missing posted full-name
invalid-full-name-length posted full-name too short
posted full-name too long
invalid-location missing posted location
invalid-occupation missing posted occupation
invalid-phone missing posted phone

NodeJS source (view on github)

const dashboard = require('../../../../index.js')

module.exports = {
  post: async (req) => {
    if (!req.query || !req.query.accountid) {
      throw new Error('invalid-accountid')
    }
    const account = await global.api.user.Account.get(req)
    if (!account) {
      throw new Error('invalid-accountid')
    }
    req.body = req.body || {}
    const profileInfo = {
      accountid: req.query.accountid,
      appid: req.appid || global.appid
    }
    const profileFields = req.userProfileFields || global.userProfileFields
    for (const field of profileFields) {
      const displayName = global.profileFieldMap[field]
      switch (field) {
        case 'full-name':
          if (!req.body['full-name'] || !req.body['full-name'].length) {
            throw new Error('invalid-full-name')
          }
          if (global.minimumProfileFullNameLength > req.body['full-name'].length ||
            global.maximumProfileFullNameLength < req.body['full-name'].length) {
            throw new Error('invalid-full-name-length')
          }
          profileInfo.fullName = req.body['full-name']
          continue
        case 'contact-email':
          if (!req.body[field] || req.body[field].indexOf('@') < 1 || !dashboard.Validate.emailAddress(req.body[field])) {
            throw new Error(`invalid-${field}`)
          }
          profileInfo.contactEmail = req.body[field]
          continue
        case 'display-email':
          if (!req.body[field] || req.body[field].indexOf('@') < 1 || !dashboard.Validate.emailAddress(req.body[field])) {
            throw new Error(`invalid-${field}`)
          }
          profileInfo.displayEmail = req.body[field]
          continue
        case 'display-name':
          if (!req.body[field] || !req.body[field].length) {
            throw new Error(`invalid-${field}`)
          }
          if (global.minimumProfileDisplayNameLength > req.body[field].length ||
            global.maximumProfileDisplayNameLength < req.body[field].length) {
            throw new Error('invalid-display-name-length')
          }
          profileInfo.displayName = req.body[field]
          continue
        case 'company-name':
          if (!req.body[field] || !req.body[field].length) {
            throw new Error(`invalid-${field}`)
          }
          if (global.minimumProfileCompanyNameLength > req.body[field].length ||
            global.maximumProfileCompanyNameLength < req.body[field].length) {
            throw new Error('invalid-company-name-length')
          }
          profileInfo.companyName = req.body[field]
          continue
        case 'dob':
          if (!req.body[field] || !req.body[field].length) {
            throw new Error(`invalid-${field}`)
          }
          try {
            const date = dashboard.Format.parseDate(req.body[field])
            if (!date || !date.getFullYear) {
              throw new Error(`invalid-${field}`)
            }
            profileInfo.dob = dashboard.Format.date(date)
          } catch (error) {
            throw new Error(`invalid-${field}`)
          }
          continue
        default:
          if (!req.body || !req.body[field]) {
            throw new Error(`invalid-${field}`)
          }
          profileInfo[displayName] = req.body[field]
          continue
      }
    }
    const profile = await dashboard.Storage.Profile.create(profileInfo)
    if (req.body.default === 'true') {
      await dashboard.Storage.Account.update({
        profileid: profile.dataValues.profileid
      }, {
        where: {
          accountid: req.query.accountid,
          appid: req.appid || global.appid
        }
      })
      await dashboard.StorageCache.remove(profile.dataValues.accountid)
    }
    req.query.profileid = profile.dataValues.profileid
    return global.api.user.Profile.get(req)
  }
}

Test source (view on github)

/* eslint-env mocha */
const assert = require('assert')
const TestHelper = require('../../../../test-helper.js')

describe('/api/user/create-profile', () => {
  describe('exceptions', () => {
    describe('invalid-accountid', () => {
      it('missing querystring accountid', async () => {
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest('/api/user/create-profile')
        req.account = user.account
        req.session = user.session
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-accountid')
      })

      it('invalid querystring accountid', async () => {
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest('/api/user/create-profile?accountid=invalid')
        req.account = user.account
        req.session = user.session
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-accountid')
      })
    })

    describe('invalid-accountid', () => {
      it('ineligible accessing account', async () => {
        const user = await TestHelper.createUser()
        const user2 = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user2.account.accountid}`)
        req.account = user.account
        req.session = user.session
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-account')
      })
    })

    describe('invalid-full-name', () => {
      it('missing posted full-name', async () => {
        global.requireProfile = true
        global.userProfileFields = ['full-name']
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        req.body = {
          'full-name': ''
        }
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-full-name')
      })
    })

    describe('invalid-full-name-length', () => {
      it('posted full-name too short', async () => {
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        req.body = {
          'full-name': 'Test Person'
        }
        global.requireProfile = true
        global.userProfileFields = ['full-name']
        global.minimumProfileFullNameLength = 100
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-full-name-length')
      })

      it('posted full-name too long', async () => {
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        req.body = {
          'full-name': 'Test Person'
        }
        global.requireProfile = true
        global.userProfileFields = ['full-name']
        global.maximumProfileFullNameLength = 1
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-full-name-length')
      })
    })

    describe('invalid-display-name', () => {
      it('missing posted display-name', async () => {
        global.requireProfile = true
        global.userProfileFields = ['display-name']
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-display-name')
      })
    })

    describe('invalid-display-name-length', () => {
      it('posted display-name too short', async () => {
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        req.body = {
          'display-name': 'Test'
        }
        global.requireProfile = true
        global.userProfileFields = ['display-name']
        global.minimumProfileDisplayNameLength = 100
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-display-name-length')
      })

      it('posted display-name too long', async () => {
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        req.body = {
          'display-name': 'Test'
        }
        global.requireProfile = true
        global.userProfileFields = ['display-name']
        global.maximumProfileDisplayNameLength = 1
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-display-name-length')
      })
    })

    describe('invalid-company-name-length', () => {
      it('posted company-name too short', async () => {
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        req.body = {
          'company-name': 'Test'
        }
        global.requireProfile = true
        global.userProfileFields = ['company-name']
        global.minimumProfileCompanyNameLength = 100
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-company-name-length')
      })

      it('posted company-name too long', async () => {
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        req.body = {
          'company-name': 'Test'
        }
        global.requireProfile = true
        global.userProfileFields = ['company-name']
        global.maximumProfileCompanyNameLength = 1
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-company-name-length')
      })
    })

    describe('invalid-company-name-length', () => {
      it('invalid-company-name-length', async () => {
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        req.body = {
          'company-name': 'Test'
        }
        global.requireProfile = true
        global.userProfileFields = ['company-name']
        global.maximumProfileCompanyNameLength = 1
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-company-name-length')
      })
    })

    describe('invalid-contact-email', () => {
      it('missing posted contact-email', async () => {
        global.requireProfile = true
        global.userProfileFields = ['contact-email']
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-contact-email')
      })
    })

    describe('invalid-display-email', () => {
      it('missing posted display-email', async () => {
        global.requireProfile = true
        global.userProfileFields = ['display-email']
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-display-email')
      })
    })

    describe('invalid-location', () => {
      it('missing posted location', async () => {
        global.requireProfile = true
        global.userProfileFields = ['location']
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-location')
      })
    })

    describe('invalid-occupation', () => {
      it('missing posted occupation', async () => {
        global.requireProfile = true
        global.userProfileFields = ['occupation']
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-occupation')
      })
    })

    describe('invalid-phone', () => {
      it('missing posted phone', async () => {
        global.requireProfile = true
        global.userProfileFields = ['phone']
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-phone')
      })
    })

    describe('invalid-dob', () => {
      it('missing posted dob', async () => {
        global.requireProfile = true
        global.userProfileFields = ['dob']
        const user = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
        req.account = user.account
        req.session = user.session
        let errorMessage
        try {
          await req.post()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-dob')
      })
    })
  })

  describe('receives', () => {
    it('optionally-required posted full-name', async () => {
      global.requireProfile = true
      global.userProfileFields = ['full-name']
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        'full-name': 'Testing Person'
      }
      const profile = await req.post()
      assert.strictEqual(profile.fullName, 'Testing Person')
    })

    it('optionally-required posted display-name', async () => {
      global.requireProfile = true
      global.userProfileFields = ['display-name']
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        'display-name': 'Testing'
      }
      const profile = await req.post()
      assert.strictEqual(profile.displayName, 'Testing')
    })

    it('optionally-required posted company-name', async () => {
      global.requireProfile = true
      global.userProfileFields = ['company-name']
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        'company-name': 'Testing'
      }
      const profile = await req.post()
      assert.strictEqual(profile.companyName, 'Testing')
    })

    it('optionally-required posted contact-email', async () => {
      global.requireProfile = true
      global.userProfileFields = ['contact-email']
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        'contact-email': 'test@test.com'
      }
      const profile = await req.post()
      assert.strictEqual(profile.contactEmail, 'test@test.com')
    })

    it('optionally-required posted display-email', async () => {
      global.requireProfile = true
      global.userProfileFields = ['display-email']
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        'display-email': 'test@test.com'
      }
      const profile = await req.post()
      assert.strictEqual(profile.displayEmail, 'test@test.com')
    })

    it('optionally-required posted location', async () => {
      global.requireProfile = true
      global.userProfileFields = ['location']
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        location: 'Testing'
      }
      const profile = await req.post()
      assert.strictEqual(profile.location, 'Testing')
    })

    it('optionally-required posted occupation', async () => {
      global.requireProfile = true
      global.userProfileFields = ['occupation']
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        occupation: 'Testing'
      }
      const profile = await req.post()
      assert.strictEqual(profile.occupation, 'Testing')
    })

    it('optionally-required posted phone', async () => {
      global.requireProfile = true
      global.userProfileFields = ['phone']
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        phone: '456-789-0123'
      }
      const profile = await req.post()
      assert.strictEqual(profile.phone, '456-789-0123')
    })

    it('optionally-required posted dob', async () => {
      global.requireProfile = true
      global.userProfileFields = ['dob']
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        dob: '1950-01-01'
      }
      const profile = await req.post()
      assert.strictEqual(profile.dob, '1950-01-01')
    })
  })

  describe('returns', () => {
    it('object', async () => {
      global.requireProfile = true
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      global.userProfileFields = ['full-name', 'display-name', 'contact-email', 'display-email', 'dob', 'phone', 'occupation', 'location', 'company-name', 'website']
      req.filename = __filename
      req.saveResponse = true
      req.body = {
        'full-name': 'Test Person',
        'contact-email': 'test1@test.com',
        'display-email': 'test2@test.com',
        dob: '2000-01-01',
        'display-name': 'tester',
        phone: '456-789-0123',
        occupation: 'Programmer',
        location: 'USA',
        'company-name': 'Test company',
        website: 'https://example.com'
      }
      const profile = await req.post()
      assert.strictEqual(profile.object, 'profile')
    })
  })

  describe('configuration', () => {
    it('environment USER_PROFILE_FIELDS', async () => {
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      const fields = ['full-name', 'display-name', 'contact-email', 'display-email', 'dob', 'phone', 'occupation', 'location', 'company-name', 'website']
      const body = {
        'full-name': 'Test Person',
        'contact-email': 'test1@test.com',
        'display-email': 'test2@test.com',
        dob: '2000-01-01',
        'display-name': 'tester',
        phone: '456-789-0123',
        occupation: 'Programmer',
        location: 'USA',
        'company-name': 'Test company',
        website: 'https://example.com'
      }
      for (const field of fields) {
        req.body = {
          confirm: 'password1234',
          [field]: body[field]
        }
        global.userProfileFields = [field]
        const displayName = global.profileFieldMap[field]
        const account = await req.post()
        assert.strictEqual(account[displayName], body[field])
      }
    })

    it('environment MINIMUM_PROFILE_FULL_NAME_LENGTH', async () => {
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        'full-name': 'Test Person'
      }
      global.userProfileFields = ['full-name']
      global.minimumProfileFullNameLength = 100
      let errorMessage
      try {
        await req.post()
      } catch (error) {
        errorMessage = error.message
      }
      assert.strictEqual(errorMessage, 'invalid-full-name-length')
    })

    it('environment MAXIMUM_PROFILE_FULL_NAME_LENGTH', async () => {
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        'full-name': 'Test Person'
      }
      global.userProfileFields = ['full-name']
      global.maximumProfileFullNameLength = 1
      let errorMessage
      try {
        await req.post()
      } catch (error) {
        errorMessage = error.message
      }
      assert.strictEqual(errorMessage, 'invalid-full-name-length')
    })

    it('environment MINIMUM_PROFILE_DISPLAY_NAME_LENGTH', async () => {
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        'display-name': '1'
      }
      global.userProfileFields = ['display-name']
      global.minimumProfileDisplayNameLength = 100
      let errorMessage
      try {
        await req.post()
      } catch (error) {
        errorMessage = error.message
      }
      assert.strictEqual(errorMessage, 'invalid-display-name-length')
    })

    it('environment MAXIMUM_PROFILE_DISPLAY_NAME_LENGTH', async () => {
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        'display-name': 'meeeee123'
      }
      global.userProfileFields = ['display-name']
      global.maximumProfileDisplayNameLength = 1
      let errorMessage
      try {
        await req.post()
      } catch (error) {
        errorMessage = error.message
      }
      assert.strictEqual(errorMessage, 'invalid-display-name-length')
    })

    it('environment MINIMUM_PROFILE_COMPANY_NAME_LENGTH', async () => {
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        'company-name': '1'
      }
      global.userProfileFields = ['company-name']
      global.minimumProfileCompanyNameLength = 100
      let errorMessage
      try {
        await req.post()
      } catch (error) {
        errorMessage = error.message
      }
      assert.strictEqual(errorMessage, 'invalid-company-name-length')
    })

    it('environment MAXIMUM_PROFILE_COMPANY_NAME_LENGTH', async () => {
      const user = await TestHelper.createUser()
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      req.body = {
        'company-name': 'acme inc'
      }
      global.userProfileFields = ['company-name']
      global.maximumProfileCompanyNameLength = 1
      let errorMessage
      try {
        await req.post()
      } catch (error) {
        errorMessage = error.message
      }
      assert.strictEqual(errorMessage, 'invalid-company-name-length')
    })

    it('override req.userProfileFields', async () => {
      const user = await TestHelper.createUser()
      global.userProfileFields = ['full-name', 'display-name', 'contact-email', 'display-email', 'dob', 'phone', 'occupation', 'location', 'company-name', 'website']
      const req = TestHelper.createRequest(`/api/user/create-profile?accountid=${user.account.accountid}`)
      req.account = user.account
      req.session = user.session
      const body = {
        'full-name': 'Test Person',
        'contact-email': 'test1@test.com',
        'display-email': 'test2@test.com',
        dob: '2000-01-01',
        'display-name': 'tester',
        phone: '456-789-0123',
        occupation: 'Programmer',
        location: 'USA',
        'company-name': 'Test company',
        website: 'https://example.com'
      }
      for (const field of global.userProfileFields) {
        req.userProfileFields = [field]
        req.body = {
          [field]: body[field]
        }
        const displayName = global.profileFieldMap[field]
        const account = await req.route.api.post(req)
        assert.strictEqual(account[displayName], body[field])
      }
    })
  })
})