Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface CreateOptionsWithParentExternalId extends BaseCreateAuthorizati
}

export type CreateAuthorizationResourceOptions =
| BaseCreateAuthorizationResourceOptions
| CreateOptionsWithParentResourceId
| CreateOptionsWithParentExternalId;
Comment on lines 44 to 47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing test coverage for no-parent case

The type fix is correct and the serializer already handles the no-parent path (via 'parentResourceId' in options), but the createResource test suite in authorization.spec.ts has no test case that exercises creating a resource without any parent fields. It would be good to add one, for example:

it('creates an authorization resource without a parent', async () => {
  fetchOnce(authorizationResourceFixture, { status: 201 });

  await workos.authorization.createResource({
    organizationId: testOrgId,
    resourceTypeSlug: 'document',
    externalId: 'doc-456',
    name: 'Q4 Budget Report',
  });

  const body = fetchBody();
  expect(body).not.toHaveProperty('parent_resource_id');
  expect(body).not.toHaveProperty('parent_resource_external_id');
  expect(body).not.toHaveProperty('parent_resource_type_slug');
});

This confirms the serializer omits all parent fields when none are supplied.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


Expand Down