-
Notifications
You must be signed in to change notification settings - Fork 7
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
[i18n-Audio] Add DB schemas and shared API/store stubs #3987
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Really liking the new sharing patterns, with one question around the testing pattern
apps/mark-scan/backend/schema.sql
Outdated
|
||
create table ui_string_audio_keys ( | ||
language_code text primary key, | ||
data text not null, -- JSON blob - see libs/types/UiStringTranslationsSchema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to reference libs/types/UiStringAudioKeysSchema
here (and same in the other schema.sql files)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for the catch!
); | ||
|
||
create table audio_clips ( | ||
id text not null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double checking my understanding: These id
values are the same as the audio keys as described in the spec, e.g. d5b21f
, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, these correspond the audio keys - and I'm realising the inconsistent naming is confusing (especially once I started building on this PR 😅 ). I think I'm going to settle on id
and change the property names in related schemas to id
/audioId
to make things more consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I like that!
return new Store(DbClient.fileClient(dbPath, SchemaPath)); | ||
const client = DbClient.fileClient(dbPath, SchemaPath); | ||
const uiStringsStore = createUiStringStore(client); | ||
return new Store(client, uiStringsStore); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I like these patterns that you're setting for shared store and API code. I'd been with experimenting with similar ideas recently, e.g.
vxsuite/apps/scan/backend/src/store.ts
Lines 36 to 40 in 6c454a5
import { | |
clearCastVoteRecordHashes, | |
getCastVoteRecordRootHash, | |
updateCastVoteRecordHashes, | |
} from '@votingworks/auth'; |
vxsuite/apps/scan/backend/src/store.ts
Lines 958 to 968 in 6c454a5
getCastVoteRecordRootHash(): string { | |
return getCastVoteRecordRootHash(this.client); | |
} | |
updateCastVoteRecordHashes(cvrId: string, cvrHash: string): void { | |
updateCastVoteRecordHashes(this.client, cvrId, cvrHash); | |
} | |
clearCastVoteRecordHashes(): void { | |
clearCastVoteRecordHashes(this.client); | |
} |
I like that what you're setting up is more automatic than what I'd set up. Looks like we can add new methods to libs/backend
and the app stores and APIs will automatically update 🪄.
Re SQL schemas, I too just copied the schemas since we don't yet have a clear pattern for sharing those - that seems fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I missed those - makes me feel better knowing that we have other instances where we're sharing the query code
@@ -240,3 +254,40 @@ test('configureWithSampleBallotPackageForIntegrationTest configures electionGene | |||
const electionDefinitionResult = await apiClient.getElectionDefinition(); | |||
expect(electionDefinitionResult).toEqual(electionGeneralDefinition); | |||
}); | |||
|
|||
test('installs UI Strings API', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm taking a sec to wrap my mind around the difference between these tests and the tests in app.ui_strings.test.ts
, specifically trying to understand why the former are necessary.
It seems like the main thing tested in this file that's not tested in app.ui_strings.test.ts
is the Grout client's ability to access the endpoints. Otherwise, app.ui_strings.test.ts
tests everything tested in here and more (installation of the UI strings API + actual implementation since it doesn't mock).
I wonder if we can just assume that the Grout client will work fine, given libs/grout
tests. Or alternatively, have the shared ui_strings_api_test_runner.ts
create a Grout client for testing.
I might be missing something! Just wondering if we can get rid of these app.test.ts
tests so that everything, tests included, really is automatic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks - I lost perspective on this after a couple iterations. Initially had the shared test runner just taking in a store
input and testing that, but you're spot on WRT not needing these tests since the test runner is testing against an app's actual API.
Will go ahead and drop these!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Figured that might've been the case re iterations!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Overview
🔍 Easier to review individual commits.
Related spec here.
Adding:
Mark
,Scan
,Mark-Scan
Scan
doesn't need the audio tables, but it made things simpler to have everything be identical across apps - the apps can then enable/disable audio functionality as needed).Testing Plan
Checklist
[ ] I have added logging where appropriate to any new user actions, system updates such as file reads or storage writes, or errors introduced.[ ] I have added a screenshot and/or video to this PR to demo the change[ ] I have added the "user_facing_change" label to this PR to automate an announcement in #machine-product-updates