-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix route parsing in form filler view. * Create new pattern constructor that validates the config data, and wire up to the external PDF parsing library. Context: we haven't been validating input from the PDF parsing process, and there were hard to debug issues. A remaining issue that this identified is the presence of spaces in some option IDs. These, and other errors, are currently being logged to the console, and the corresponding pattern is ignored (not added to the form blueprint). Follow-up work should include fixes this issue, and also presentation of these validation errors to the user. * Split api call and api response processing * Fix test * Add mock-response.ts
- Loading branch information
1 parent
765a74c
commit ffdcb85
Showing
16 changed files
with
1,404 additions
and
126 deletions.
There are no files selected for viewing
This file contains 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
11 changes: 11 additions & 0 deletions
11
packages/design/src/FormManager/FormInspect/FormInspect.tsx
This file contains 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,11 @@ | ||
import { useFormManagerStore } from '../store'; | ||
import React from 'react'; | ||
|
||
export const FormInspect = () => { | ||
const form = useFormManagerStore(state => state.session.form); | ||
return ( | ||
<pre> | ||
<code>{JSON.stringify(form, null, 2)}</code> | ||
</pre> | ||
); | ||
}; |
This file contains 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 @@ | ||
export { FormInspect } from './FormInspect'; |
This file contains 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 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 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 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,50 @@ | ||
/** | ||
* @vitest-environment jsdom | ||
*/ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { getPattern } from '../..'; | ||
import { BlueprintBuilder } from '../../builder'; | ||
import { defaultFormConfig } from '../../patterns'; | ||
import { type PageSetPattern } from '../../patterns/page-set/config'; | ||
import { type PagePattern } from '../../patterns/page/config'; | ||
|
||
import { addDocument } from '../document'; | ||
import { loadSamplePDF } from './sample-data'; | ||
|
||
describe('addDocument document processing', () => { | ||
it('creates expected blueprint', async () => { | ||
const builder = new BlueprintBuilder(defaultFormConfig); | ||
const pdfBytes = await loadSamplePDF( | ||
'doj-pardon-marijuana/application_for_certificate_of_pardon_for_simple_marijuana_possession.pdf' | ||
); | ||
const { updatedForm, errors } = await addDocument( | ||
builder.form, | ||
{ | ||
name: 'test.pdf', | ||
data: new Uint8Array(pdfBytes), | ||
}, | ||
{ | ||
fetchPdfApiResponse: async () => { | ||
const { mockResponse } = await import('../pdf/mock-response'); | ||
return mockResponse; | ||
}, | ||
} | ||
); | ||
const rootPattern = getPattern<PageSetPattern>( | ||
updatedForm, | ||
updatedForm.root | ||
); | ||
|
||
console.error(JSON.stringify(errors, null, 2)); // Fix these | ||
expect(rootPattern).toEqual(expect.objectContaining({ type: 'page-set' })); | ||
expect(rootPattern.data.pages.length).toEqual(1); | ||
const pagePattern = getPattern<PagePattern>( | ||
updatedForm, | ||
rootPattern.data.pages[0] | ||
); | ||
|
||
// As a sanity check, just confirm that there is content on the first page. | ||
expect(pagePattern.data.patterns.length).toBeGreaterThan(1); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains 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 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
1,127 changes: 1,127 additions & 0 deletions
1,127
packages/forms/src/documents/pdf/mock-response.ts
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.