-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix(ashby): parse alternateEmailAddresses and socialLinks into arrays before dispatch #5621
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
Merged
+135
−22
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
083a140
fix(ashby): parse alternateEmailAddresses and socialLinks into arrays…
waleedlatif1 92cfb95
fix(ashby): drop json-object generationType from array-shaped wandCon…
waleedlatif1 7f70458
fix(ashby): remove the non-functional candidateId filter from list_ap…
waleedlatif1 78d47f7
fix(ashby): add subblock-id migration for the removed filterCandidate…
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /** | ||
| * @vitest-environment node | ||
| */ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { AshbyBlock } from './ashby' | ||
|
|
||
| describe('AshbyBlock', () => { | ||
| const buildParams = (operation: string, extra: Record<string, unknown>) => ({ | ||
| operation, | ||
| ...extra, | ||
| }) | ||
|
|
||
| describe('alternateEmailAddresses parsing (create_candidate)', () => { | ||
| it('parses a comma-separated string into an array', () => { | ||
| const result = AshbyBlock.tools.config.params!( | ||
| buildParams('create_candidate', { | ||
| alternateEmailAddresses: 'a@x.com, b@x.com', | ||
| }) | ||
| ) | ||
| expect(result.alternateEmailAddresses).toEqual(['a@x.com', 'b@x.com']) | ||
| }) | ||
|
|
||
| it('parses a JSON array string into an array', () => { | ||
| const result = AshbyBlock.tools.config.params!( | ||
| buildParams('create_candidate', { | ||
| alternateEmailAddresses: '["a@x.com","b@x.com"]', | ||
| }) | ||
| ) | ||
| expect(result.alternateEmailAddresses).toEqual(['a@x.com', 'b@x.com']) | ||
| }) | ||
|
|
||
| it('omits the field entirely when empty', () => { | ||
| const result = AshbyBlock.tools.config.params!( | ||
| buildParams('create_candidate', { alternateEmailAddresses: '' }) | ||
| ) | ||
| expect(result.alternateEmailAddresses).toBeUndefined() | ||
| }) | ||
| }) | ||
|
|
||
| describe('socialLinks parsing (update_candidate)', () => { | ||
| it('parses a JSON array of link objects', () => { | ||
| const result = AshbyBlock.tools.config.params!( | ||
| buildParams('update_candidate', { | ||
| socialLinks: '[{"type":"Twitter","url":"https://twitter.com/jane"}]', | ||
| }) | ||
| ) | ||
| expect(result.socialLinks).toEqual([{ type: 'Twitter', url: 'https://twitter.com/jane' }]) | ||
| }) | ||
|
|
||
| it('omits the field when the JSON is malformed', () => { | ||
| const result = AshbyBlock.tools.config.params!( | ||
| buildParams('update_candidate', { socialLinks: 'not json' }) | ||
| ) | ||
| expect(result.socialLinks).toBeUndefined() | ||
| }) | ||
| }) | ||
|
|
||
| describe('wandConfig on array-shaped fields', () => { | ||
| it('does not request object-wrapped output for alternateEmailAddresses or socialLinks', () => { | ||
| // generationType 'json-object' makes the wand API append "the response | ||
| // must start with { and end with }", which conflicts with these fields' | ||
| // array-or-comma-separated parsers (parseStringListInput/parseSocialLinksInput). | ||
| const alternateEmailAddresses = AshbyBlock.subBlocks.find( | ||
| (s) => s.id === 'alternateEmailAddresses' | ||
| ) | ||
| const socialLinks = AshbyBlock.subBlocks.find((s) => s.id === 'socialLinks') | ||
| expect(alternateEmailAddresses?.wandConfig?.generationType).not.toBe('json-object') | ||
| expect(socialLinks?.wandConfig?.generationType).not.toBe('json-object') | ||
| }) | ||
| }) | ||
|
|
||
| describe('list_applications candidateId filter', () => { | ||
| it('has no filterCandidateId subBlock or wiring', () => { | ||
| // Ashby's application.list endpoint silently ignores a candidateId | ||
| // body field (confirmed live: passing a nonexistent candidate UUID | ||
| // still returns unfiltered results) — the correct path for a | ||
| // candidate's applications is ashby_get_candidate's applicationIds. | ||
| expect(AshbyBlock.subBlocks.find((s) => s.id === 'filterCandidateId')).toBeUndefined() | ||
| const result = AshbyBlock.tools.config.params!( | ||
| buildParams('list_applications', { filterCandidateId: 'some-id' }) | ||
| ) | ||
| expect(result.candidateId).toBeUndefined() | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.