-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: page router validations and add test cases (#720)
This PR starts the chain of PRs for adding test cases for all our procedures in the Studio application so we can be more confident when shipping code. ## Solution **Breaking Changes** - [x] No - this PR is backwards compatible **Features**: - Details ... **Improvements**: - Add Tagged types to `jsonb` columns so we remember to call `jsonb()` function before insertion into the database. This prevents runtime errors. - Update `updatePageBlobSchema` to validate the type of `content` in the schema itself. - Update all `*select` constants to use `satisfies` keyword for better type inference when used. - Throw 404 errors when resource is not found in all `page.router` procedures - Validate whether `folderId` is a folder when calling `createPage` procedure and passing the `folderId` arg. - use transaction when updating page in `updatePage` procedure - add foreign key violation error handling **Bug Fixes**: - use correct `fullPage.publishedVersionId` check in `readPageAndBlob` procedure ## Tests Tests are added for all procedures in the page router. A few tests regarding permissions are skipped until permissions are in cc @seaerchin
Showing
20 changed files
with
1,792 additions
and
209 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
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
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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import type { SelectExpression } from "kysely" | ||
|
||
import type { DB } from "~prisma/generated/generatedTypes" | ||
|
||
type ResourceProperties = keyof DB["Resource"] | ||
export const defaultFolderSelect: readonly ResourceProperties[] = [ | ||
"id", | ||
"parentId", | ||
"permalink", | ||
"title", | ||
"siteId", | ||
"state", | ||
"type", | ||
"draftBlobId", | ||
] as const | ||
export const defaultFolderSelect = [ | ||
"Resource.id", | ||
"Resource.parentId", | ||
"Resource.permalink", | ||
"Resource.title", | ||
"Resource.siteId", | ||
"Resource.state", | ||
"Resource.type", | ||
"Resource.draftBlobId", | ||
] satisfies SelectExpression<DB, "Resource">[] |
Oops, something went wrong.