@@ -8,6 +8,10 @@ import {
88 FlagCreatedEvent ,
99 FlagCreatedEventResponse ,
1010 ListResponse ,
11+ OrganizationDomainCreatedEvent ,
12+ OrganizationDomainCreatedEventResponse ,
13+ OrganizationDomainVerificationFailedEvent ,
14+ OrganizationDomainVerificationFailedEventResponse ,
1115 VaultDataCreatedEvent ,
1216 VaultDataCreatedEventResponse ,
1317 VaultDataUpdatedEvent ,
@@ -31,6 +35,10 @@ import {
3135} from '../common/interfaces' ;
3236import { WorkOS } from '../workos' ;
3337import { ConnectionType } from '../sso/interfaces' ;
38+ import {
39+ OrganizationDomainState ,
40+ OrganizationDomainVerificationStrategy ,
41+ } from '../organization-domains/interfaces' ;
3442
3543describe ( 'Event' , ( ) => {
3644 beforeEach ( ( ) => fetch . resetMocks ( ) ) ;
@@ -736,5 +744,120 @@ describe('Event', () => {
736744 } ) ;
737745 } ) ;
738746 } ) ;
747+
748+ describe ( 'organization domain events' , ( ) => {
749+ it ( 'deserializes organization_domain.created events' , async ( ) => {
750+ const response : OrganizationDomainCreatedEventResponse = {
751+ event : 'organization_domain.created' ,
752+ id : 'event_01DOMAINCREATED001' ,
753+ data : {
754+ id : 'org_domain_01TESTDOMAIN' ,
755+ state : OrganizationDomainState . Pending ,
756+ domain : 'example.com' ,
757+ object : 'organization_domain' ,
758+ created_at : '2026-04-06T06:24:06.749Z' ,
759+ updated_at : '2026-04-06T06:24:06.749Z' ,
760+ organization_id : 'org_01TESTORGANIZATION' ,
761+ verification_strategy :
762+ OrganizationDomainVerificationStrategy . Manual ,
763+ } ,
764+ context : { } ,
765+ created_at : '2026-04-06T06:24:06.776Z' ,
766+ } ;
767+
768+ const expected : OrganizationDomainCreatedEvent = {
769+ event : 'organization_domain.created' ,
770+ id : 'event_01DOMAINCREATED001' ,
771+ data : {
772+ id : 'org_domain_01TESTDOMAIN' ,
773+ state : OrganizationDomainState . Pending ,
774+ domain : 'example.com' ,
775+ object : 'organization_domain' ,
776+ createdAt : '2026-04-06T06:24:06.749Z' ,
777+ updatedAt : '2026-04-06T06:24:06.749Z' ,
778+ organizationId : 'org_01TESTORGANIZATION' ,
779+ verificationStrategy : OrganizationDomainVerificationStrategy . Manual ,
780+ } ,
781+ context : { } ,
782+ createdAt : '2026-04-06T06:24:06.776Z' ,
783+ } ;
784+
785+ fetchOnce ( {
786+ object : 'list' ,
787+ data : [ response ] ,
788+ list_metadata : { } ,
789+ } ) ;
790+
791+ const list = await workos . events . listEvents ( {
792+ events : [ 'organization_domain.created' ] ,
793+ } ) ;
794+
795+ expect ( list ) . toEqual ( {
796+ object : 'list' ,
797+ data : [ expected ] ,
798+ listMetadata : { } ,
799+ } ) ;
800+ } ) ;
801+
802+ it ( 'deserializes organization_domain.verification_failed events' , async ( ) => {
803+ const response : OrganizationDomainVerificationFailedEventResponse = {
804+ event : 'organization_domain.verification_failed' ,
805+ id : 'event_01DOMAIN0002' ,
806+ data : {
807+ reason : 'domain_verification_period_expired' ,
808+ organization_domain : {
809+ id : 'org_domain_0TESTDOMAIN' ,
810+ state : OrganizationDomainState . Failed ,
811+ domain : 'example.com' ,
812+ object : 'organization_domain' ,
813+ created_at : '2026-03-07T02:24:56.621Z' ,
814+ updated_at : '2026-04-06T02:25:00.494Z' ,
815+ organization_id : 'org_01TESTORGANIZATION' ,
816+ verification_token : 'FAKETOKEN' ,
817+ verification_strategy : OrganizationDomainVerificationStrategy . Dns ,
818+ } ,
819+ } ,
820+ context : { } ,
821+ created_at : '2026-04-06T02:26:05.430Z' ,
822+ } ;
823+
824+ const expected : OrganizationDomainVerificationFailedEvent = {
825+ event : 'organization_domain.verification_failed' ,
826+ id : 'event_01DOMAIN0002' ,
827+ data : {
828+ reason : 'domain_verification_period_expired' ,
829+ organizationDomain : {
830+ id : 'org_domain_0TESTDOMAIN' ,
831+ state : OrganizationDomainState . Failed ,
832+ domain : 'example.com' ,
833+ object : 'organization_domain' ,
834+ createdAt : '2026-03-07T02:24:56.621Z' ,
835+ updatedAt : '2026-04-06T02:25:00.494Z' ,
836+ organizationId : 'org_01TESTORGANIZATION' ,
837+ verificationToken : 'FAKETOKEN' ,
838+ verificationStrategy : OrganizationDomainVerificationStrategy . Dns ,
839+ } ,
840+ } ,
841+ context : { } ,
842+ createdAt : '2026-04-06T02:26:05.430Z' ,
843+ } ;
844+
845+ fetchOnce ( {
846+ object : 'list' ,
847+ data : [ response ] ,
848+ list_metadata : { } ,
849+ } ) ;
850+
851+ const list = await workos . events . listEvents ( {
852+ events : [ 'organization_domain.verification_failed' ] ,
853+ } ) ;
854+
855+ expect ( list ) . toEqual ( {
856+ object : 'list' ,
857+ data : [ expected ] ,
858+ listMetadata : { } ,
859+ } ) ;
860+ } ) ;
861+ } ) ;
739862 } ) ;
740863} ) ;
0 commit comments