Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support a city/state composite value #1158

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions injected/integration-test/page-objects/broker-protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,21 @@ export class BrokerProtectionPage {
* @return {Promise<void>}
*/
async isFormFilled () {
await expect(this.page.getByLabel('First Name:')).toHaveValue('John')
await expect(this.page.getByLabel('Last Name:')).toHaveValue('Smith')
await expect(this.page.getByLabel('Phone Number:')).toHaveValue(/^\d{10}$/)
await expect(this.page.getByLabel('Street Address:')).toHaveValue(/^\d+ [A-Za-z]+(?: [A-Za-z]+)?$/)
await expect(this.page.getByLabel('State:')).toHaveValue('IL')
await expect(this.page.getByLabel('Zip Code:')).toHaveValue(/^\d{5}$/)
await expect(this.page.getByLabel('First Name:', { exact: true })).toHaveValue('John')
await expect(this.page.getByLabel('Last Name:', { exact: true })).toHaveValue('Smith')
await expect(this.page.getByLabel('Phone Number:', { exact: true })).toHaveValue(/^\d{10}$/)
await expect(this.page.getByLabel('Street Address:', { exact: true })).toHaveValue(/^\d+ [A-Za-z]+(?: [A-Za-z]+)?$/)
await expect(this.page.locator('#state')).toHaveValue('IL')
shakyShane marked this conversation as resolved.
Show resolved Hide resolved
await expect(this.page.getByLabel('Zip Code:', { exact: true })).toHaveValue(/^\d{5}$/)

const randomValue = await this.page.getByLabel('Random number between 5 and 15:').inputValue()
const randomValueInt = parseInt(randomValue)

expect(Number.isInteger(randomValueInt)).toBe(true)
expect(randomValueInt).toBeGreaterThanOrEqual(5)
expect(randomValueInt).toBeLessThanOrEqual(15)

await expect(this.page.getByLabel('City & State:', { exact: true })).toHaveValue('Chicago, IL')
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"selector": "#random_number",
"min": "5",
"max": "15"
},
{
"type": "cityState",
"selector": "#city_state"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
Random number between 5 and 15:
<input type="text" name="random_number" id="random_number">
</label>
<label>
City & State:
<input type="text" name="city_state" id="city_state">
</label>
<button class="btn-sbmt">Submit</button>
</form>
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ export function fillMany (root, elements, data) {
results.push(setValueForInput(inputElem, generateRandomInt(parseInt(element.min), parseInt(element.max)).toString()))
} else if (element.type === '$generated_street_address$') {
results.push(setValueForInput(inputElem, generateStreetAddress()))

// This is a composite of existing (but separate) city and state fields
} else if (element.type === 'cityState') {
if (!Object.prototype.hasOwnProperty.call(data, 'city') || !Object.prototype.hasOwnProperty.call(data, 'state')) {
results.push({ result: false, error: `element found with selector '${element.selector}', but data didn't contain the keys 'city' and 'state'` })
continue
}
results.push(setValueForInput(inputElem, data.city + ', ' + data.state))
} else {
if (!Object.prototype.hasOwnProperty.call(data, element.type)) {
results.push({ result: false, error: `element found with selector '${element.selector}', but data didn't contain the key '${element.type}'` })
Expand Down
Loading