Skip to content

Commit 641f846

Browse files
noisysocksclaude
andcommitted
Support filling a generated date of birth
Adds a `$generated_dob$` fillForm element type that fills an `<input type="date">` with a random date of birth consistent with the age on the extracted profile, resolved through the same lookup chain as every other field. Also replaces the real-looking street addresses in the broker-protection test fixtures with obviously synthetic ones. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent c61f13f commit 641f846

15 files changed

Lines changed: 179 additions & 32 deletions

injected/integration-test/broker-protection-tests/broker-protection.spec.js

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,9 @@ test.describe('Broker Protection communications', () => {
441441
name: 'John B Sample',
442442
alternativeNames: [],
443443
addresses: [
444-
{ city: 'Acworth', state: 'GA', extras: { street: '1591 Oakmont Dr', zip: '30102' } },
444+
{ city: 'Acworth', state: 'GA', extras: { street: '100 Sample Dr', zip: '30102' } },
445445
{ city: 'Dayton', state: 'OH', extras: { street: 'Po-Box 42', zip: '45402' } },
446-
{ city: 'Franklin', state: 'TN', extras: { street: '250 Elm St', zip: '37064' } },
446+
{ city: 'Franklin', state: 'TN', extras: { street: '250 Example St', zip: '37064' } },
447447
],
448448
phoneNumbers: [],
449449
relatives: [],
@@ -465,10 +465,10 @@ test.describe('Broker Protection communications', () => {
465465
name: 'John Sample',
466466
alternativeNames: [],
467467
addresses: [
468-
{ city: 'Baytown', state: 'TX', extras: { street: '2323 Bay Hill Dr', zip: '77523' } },
469-
{ city: 'Baytown', state: 'TX', extras: { street: '1810 Bayou Breeze Dr', zip: '77523' } },
470-
{ city: 'Livingston', state: 'TX', extras: { street: '197 Carlisle Rd', zip: '77351' } },
471-
{ city: 'Livingston', state: 'TX', extras: { street: '455 Pine Grove Ln', zip: '77351' } },
468+
{ city: 'Baytown', state: 'TX', extras: { street: '100 Sample Dr', zip: '77523' } },
469+
{ city: 'Baytown', state: 'TX', extras: { street: '200 Sample Ct', zip: '77523' } },
470+
{ city: 'Livingston', state: 'TX', extras: { street: '300 Example Rd', zip: '77351' } },
471+
{ city: 'Livingston', state: 'TX', extras: { street: '400 Example Ln', zip: '77351' } },
472472
],
473473
phoneNumbers: [],
474474
relatives: [],
@@ -489,9 +489,9 @@ test.describe('Broker Protection communications', () => {
489489
age: '40',
490490
alternativeNames: [],
491491
addresses: [
492-
{ city: 'Baytown', state: 'TX', extras: { street: '2323 Bay Hill Dr', zip: '77523' } },
493-
{ city: 'Livingston', state: 'TX', extras: { street: '197 Carlisle Rd', zip: '77351' } },
494-
{ city: 'Livingston', state: 'TX', extras: { street: '455 Pine Grove Ln', zip: '77351' } },
492+
{ city: 'Baytown', state: 'TX', extras: { street: '100 Sample Dr', zip: '77523' } },
493+
{ city: 'Livingston', state: 'TX', extras: { street: '300 Example Rd', zip: '77351' } },
494+
{ city: 'Livingston', state: 'TX', extras: { street: '400 Example Ln', zip: '77351' } },
495495
],
496496
phoneNumbers: [],
497497
relatives: [],
@@ -806,7 +806,7 @@ test.describe('Broker Protection communications', () => {
806806
await dbp.doesInputValueEqual('#FirstName', 'John');
807807
await dbp.doesInputValueEqual('#MiddleName', 'Andrew');
808808
await dbp.doesInputValueEqual('#LastName', 'Sample');
809-
await dbp.doesInputValueEqual('#StreetAddress', '2323 Bay Hill Dr');
809+
await dbp.doesInputValueEqual('#StreetAddress', '100 Sample Dr');
810810
await dbp.doesInputValueEqual('#City', 'Baytown');
811811
await dbp.doesInputValueEqual('#State', 'TX');
812812
});
@@ -818,7 +818,7 @@ test.describe('Broker Protection communications', () => {
818818
await dbp.receivesAction('fill-form-extras-address-selection.json');
819819
const response = await dbp.collector.waitForMessage('actionCompleted');
820820
dbp.isSuccessMessage(response);
821-
await dbp.doesInputValueEqual('#StreetAddress', '197 Carlisle Rd');
821+
await dbp.doesInputValueEqual('#StreetAddress', '300 Example Rd');
822822
await dbp.doesInputValueEqual('#City', 'Livingston');
823823
await dbp.doesInputValueEqual('#State', 'TX');
824824
});
@@ -830,7 +830,7 @@ test.describe('Broker Protection communications', () => {
830830
await dbp.receivesAction('fill-form-extras-no-user-profile.json');
831831
const response = await dbp.collector.waitForMessage('actionCompleted');
832832
dbp.isSuccessMessage(response);
833-
await dbp.doesInputValueEqual('#StreetAddress', '2323 Bay Hill Dr');
833+
await dbp.doesInputValueEqual('#StreetAddress', '100 Sample Dr');
834834
await dbp.doesInputValueEqual('#City', 'Baytown');
835835
});
836836

@@ -846,6 +846,29 @@ test.describe('Broker Protection communications', () => {
846846
await dbp.doesInputValueEqual('#FirstName', 'John');
847847
});
848848

849+
test('fillForm generates a date of birth matching the extracted age', async ({ page }, workerInfo) => {
850+
const dbp = BrokerProtectionPage.create(page, workerInfo.project.use);
851+
await dbp.enabled();
852+
await dbp.navigatesTo('opt-out-form.html');
853+
await dbp.receivesAction('fill-form-generated-dob.json');
854+
const response = await dbp.collector.waitForMessage('actionCompleted');
855+
dbp.isSuccessMessage(response);
856+
await dbp.isDateOfBirthForAge('#Dob', 51);
857+
await dbp.doesInputValueEqual('#StreetAddress', '100 Sample Dr');
858+
await dbp.doesInputValueEqual('#City', 'Baytown');
859+
await dbp.doesInputValueEqual('#State', 'TX');
860+
});
861+
862+
test('fillForm errors when a generated date of birth has no age to work from', async ({ page }, workerInfo) => {
863+
const dbp = BrokerProtectionPage.create(page, workerInfo.project.use);
864+
await dbp.enabled();
865+
await dbp.navigatesTo('opt-out-form.html');
866+
await dbp.receivesAction('fill-form-generated-dob-no-age.json');
867+
const response = await dbp.collector.waitForMessage('actionCompleted');
868+
dbp.isErrorMessage(response);
869+
await dbp.doesInputValueEqual('#Dob', '');
870+
});
871+
849872
test('fillForm errors when an element type is in neither known keys nor extras', async ({ page }, workerInfo) => {
850873
const dbp = BrokerProtectionPage.create(page, workerInfo.project.use);
851874
await dbp.enabled();

injected/integration-test/page-objects/broker-protection.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@ export class BrokerProtectionPage {
9090
expect(actualValue).toEqual(desiredValue);
9191
}
9292

93+
/**
94+
* @param {string} selector - the selector for an `<input type="date">`
95+
* @param {number} age - the age the filled date of birth should imply as of today
96+
* @return {Promise<void>}
97+
*/
98+
async isDateOfBirthForAge(selector, age) {
99+
const value = await this.getFormFieldValue(selector);
100+
expect(value).toMatch(/^\d{4}-\d{2}-\d{2}$/);
101+
102+
const [year, month, day] = value.split('-').map(Number);
103+
const today = new Date();
104+
const birthdayThisYear = new Date(today.getFullYear(), month - 1, day);
105+
expect(today.getFullYear() - year - (today < birthdayThisYear ? 1 : 0)).toBe(age);
106+
}
107+
93108
/**
94109
* @param {string} responseElementSelector
95110
* @return {Promise<void>}

injected/integration-test/test-pages/broker-protection/actions/fill-form-extras-address-selection.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"extractedProfile": {
1616
"name": "John Sample",
1717
"addresses": [
18-
{ "city": "Baytown", "state": "TX", "extras": { "street": "2323 Bay Hill Dr", "zip": "77523" } },
19-
{ "city": "Livingston", "state": "TX", "extras": { "street": "197 Carlisle Rd", "zip": "77351" } }
18+
{ "city": "Baytown", "state": "TX", "extras": { "street": "100 Sample Dr", "zip": "77523" } },
19+
{ "city": "Livingston", "state": "TX", "extras": { "street": "300 Example Rd", "zip": "77351" } }
2020
]
2121
},
2222
"userProfile": {

injected/integration-test/test-pages/broker-protection/actions/fill-form-extras-missing.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"extractedProfile": {
1212
"name": "John Sample",
1313
"addresses": [
14-
{ "city": "Baytown", "state": "TX", "extras": { "street": "2323 Bay Hill Dr", "zip": "77523" } }
14+
{ "city": "Baytown", "state": "TX", "extras": { "street": "100 Sample Dr", "zip": "77523" } }
1515
]
1616
},
1717
"userProfile": {

injected/integration-test/test-pages/broker-protection/actions/fill-form-extras-no-user-profile.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"extractedProfile": {
1515
"name": "John Sample",
1616
"addresses": [
17-
{ "city": "Baytown", "state": "TX", "extras": { "street": "2323 Bay Hill Dr", "zip": "77523" } },
18-
{ "city": "Livingston", "state": "TX", "extras": { "street": "197 Carlisle Rd", "zip": "77351" } }
17+
{ "city": "Baytown", "state": "TX", "extras": { "street": "100 Sample Dr", "zip": "77523" } },
18+
{ "city": "Livingston", "state": "TX", "extras": { "street": "300 Example Rd", "zip": "77351" } }
1919
]
2020
}
2121
}

injected/integration-test/test-pages/broker-protection/actions/fill-form-extras.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"middleName": "Andrew",
2121
"lastName": "Sample",
2222
"name": "John Sample",
23-
"addresses": [{ "city": "Baytown", "state": "TX", "extras": { "street": "2323 Bay Hill Dr", "zip": "77523" } }]
23+
"addresses": [{ "city": "Baytown", "state": "TX", "extras": { "street": "100 Sample Dr", "zip": "77523" } }]
2424
},
2525
"userProfile": {
2626
"firstName": "John",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"state": {
3+
"action": {
4+
"actionType": "fillForm",
5+
"id": "fill-generated-dob-no-age",
6+
"selector": "#contact-form",
7+
"dataSource": "extractedProfile",
8+
"elements": [{ "type": "$generated_dob$", "selector": ".//input[@id='Dob']" }]
9+
},
10+
"data": {
11+
"extractedProfile": {
12+
"name": "John Sample",
13+
"addresses": [{ "city": "Baytown", "state": "TX" }]
14+
}
15+
}
16+
}
17+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"state": {
3+
"action": {
4+
"actionType": "fillForm",
5+
"id": "fill-generated-dob",
6+
"selector": "#contact-form",
7+
"dataSource": "extractedProfile",
8+
"elements": [
9+
{ "type": "$generated_dob$", "selector": ".//input[@id='Dob']" },
10+
{ "type": "street", "selector": ".//input[@id='StreetAddress']" },
11+
{ "type": "city", "selector": ".//input[@id='City']" },
12+
{ "type": "state", "selector": ".//input[@id='State']" }
13+
]
14+
},
15+
"data": {
16+
"extractedProfile": {
17+
"name": "John Sample",
18+
"age": "51",
19+
"addresses": [
20+
{ "city": "Baytown", "state": "TX", "extras": { "street": "100 Sample Dr", "zip": "77523" } }
21+
]
22+
},
23+
"userProfile": {
24+
"firstName": "John",
25+
"lastName": "Sample",
26+
"addresses": [{ "city": "Baytown", "state": "TX" }]
27+
}
28+
}
29+
}
30+
}

injected/integration-test/test-pages/broker-protection/pages/opt-out-form.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
</head>
77
<body>
88
<!--
9-
A simplified version of the CyberBackgroundChecks opt-out form with plain text
10-
Street/City/State inputs (and no zip field), for exercising the fillForm extras/address
11-
path.
9+
A simplified version of the CyberBackgroundChecks opt-out form.
1210
-->
1311
<div class="card-body">
1412
<h1 class="card-title">Record Suppression Form</h1>
@@ -22,6 +20,9 @@ <h1 class="card-title">Record Suppression Form</h1>
2220
<label for="LastName">Last Name</label>
2321
<input class="form-control" id="LastName" maxlength="50" name="LastName" type="text" value="" />
2422

23+
<label for="Dob">Date of Birth</label>
24+
<input class="form-control" id="Dob" name="Dob" type="date" value="" />
25+
2526
<label for="StreetAddress">Street Address</label>
2627
<input class="form-control" id="StreetAddress" maxlength="50" name="StreetAddress" type="text" value="" />
2728

injected/integration-test/test-pages/broker-protection/pages/results-address-href.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ <h2>
2020

2121
<div class="text-base">
2222
<h3 class="inline">Past Addresses:</h3>
23-
<a href="/address/1591-oakmont-dr/acworth-ga-30102" title="">Acworth, GA</a>
23+
<a href="/address/100-sample-dr/acworth-ga-30102" title="">Acworth, GA</a>
2424
<a href="/address/po-box-42/dayton-oh-45402" title="">Dayton, OH</a>
25-
<a href="/address/250-elm-st/franklin-tn-37064" title="">Franklin, TN</a>
25+
<a href="/address/250-example-st/franklin-tn-37064" title="">Franklin, TN</a>
2626
</div>
2727

2828
<div class="text-base">

0 commit comments

Comments
 (0)