Add external import sources, work history, screening fields and Phase 1 docs
- New ExternalImportSource and ExternalWorkHistoryEntry models, controller and migrations - Screening fields on external profile imports - Admin and provider profile views, routes and workflow tests updated - Phase 1 validation, route inventory, gap report template and roadmap docs - Add the Google Sheets work-order parser tool (tools/google-sheets-wo-parser)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
module.exports = {
|
||||
fieldNationNew: {
|
||||
id: 'field-nation-message-001',
|
||||
from: 'Field Nation <notifications@fieldnation.example>',
|
||||
subject: 'New Work Order: Network troubleshooting',
|
||||
date: new Date('2026-08-02T14:00:00Z'),
|
||||
plainBody: `Field Nation\nNew work order available\nWork Order #19660234\nTitle: Network troubleshooting\nBuyer: Example Field Services\nLocation: Raleigh, NC 27609\nService Date: Monday, Aug 3 @ 8:00 AM\nPay Total: $225.00\nPay Type: Hourly Rate\nEstimated 3 hours\nView work order: https://app.fieldnation.com/workorders/19660234`
|
||||
},
|
||||
workMarketRouted: {
|
||||
id: 'workmarket-message-002',
|
||||
from: 'WorkMarket <no-reply@workmarket.example>',
|
||||
subject: 'You have been routed a work order',
|
||||
date: new Date('2026-08-02T14:05:00Z'),
|
||||
plainBody: `WorkMarket\nYou have been routed a work order.\nWork Order ID: WM-884221\nJob Title: POS terminal swap\nCompany: Example Buyer LLC\nService Location: Durham, NC 27713\nScheduled Time: Tuesday, Aug 4 @ 10:00 AM\nTotal Pay: $180.00\nFixed Rate\nOpen assignment: https://www.workmarket.com/work-orders/WM-884221`
|
||||
},
|
||||
unknown: {
|
||||
id: 'unknown-message-003',
|
||||
from: 'Some Sender <example@example.com>',
|
||||
subject: 'Hello',
|
||||
date: new Date('2026-08-02T14:10:00Z'),
|
||||
plainBody: 'This is not a work-order notification.'
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const vm = require('vm');
|
||||
const assert = require('assert/strict');
|
||||
const fixtures = require('./fixtures.cjs');
|
||||
|
||||
const context = { console, Date, Math, Number, String, Object, RegExp };
|
||||
vm.createContext(context);
|
||||
for (const file of ['Config.gs', 'Parsers.gs', 'Code.gs']) {
|
||||
const source = fs.readFileSync(path.join(__dirname, '..', 'src', file), 'utf8')
|
||||
.replace(/^const /gm, 'var ');
|
||||
vm.runInContext(source, context, { filename: file });
|
||||
}
|
||||
|
||||
const fieldNation = context.parseWorkOrderMessage_(fixtures.fieldNationNew);
|
||||
assert.equal(fieldNation.ok, true);
|
||||
assert.equal(fieldNation.record.platform, 'Field Nation');
|
||||
assert.equal(fieldNation.record.workOrderId, '19660234');
|
||||
assert.equal(fieldNation.record.payTotal, 225);
|
||||
assert.equal(fieldNation.record.effectiveRate, 75);
|
||||
assert.equal(fieldNation.record.city, 'Raleigh');
|
||||
|
||||
const workMarket = context.parseWorkOrderMessage_(fixtures.workMarketRouted);
|
||||
assert.equal(workMarket.ok, true);
|
||||
assert.equal(workMarket.record.platform, 'WorkMarket');
|
||||
assert.equal(workMarket.record.notificationType, 'Routed');
|
||||
assert.equal(workMarket.record.workOrderId, 'WM-884221');
|
||||
assert.equal(workMarket.record.payType, 'Fixed Rate');
|
||||
|
||||
const unknown = context.parseWorkOrderMessage_(fixtures.unknown);
|
||||
assert.equal(unknown.ok, false);
|
||||
|
||||
assert.equal(context.isSupportedPlatformSender_('Field Nation <alerts@fieldnation.com>'), true);
|
||||
assert.equal(context.isSupportedPlatformSender_('WorkMarket <no-reply@workmarket.com>'), true);
|
||||
assert.equal(context.isSupportedPlatformSender_('Unrelated sender <alerts@example.com>'), false);
|
||||
assert.equal(
|
||||
context.buildPlatformInboxQuery_({ lookbackDays: 7 }, { getName: () => 'WO Parser/Processed' }),
|
||||
'in:inbox {from:fieldnation from:workmarket} -label:"WO Parser/Processed" newer_than:7d'
|
||||
);
|
||||
assert.equal(context.isPublicTemplate_({ getId: () => context.WO_PARSER.TEMPLATE_SPREADSHEET_ID }), true);
|
||||
assert.equal(context.isPublicTemplate_({ getId: () => 'recipient-copy-id' }), false);
|
||||
|
||||
console.log('Parser fixtures passed.');
|
||||
Reference in New Issue
Block a user