Skip to content

Commit

Permalink
Figured out 1 way that doesn't work to get actor ref and 2 that do
Browse files Browse the repository at this point in the history
  • Loading branch information
technoplato committed Apr 8, 2024
1 parent 73c1312 commit 044c7b5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ export const applicationMachine = setup({
}).createMachine({
invoke: [
{
id: ActorSystemIds.features,
systemId: ActorSystemIds.features,
src: 'featuresMachine',
},
{
id: ActorSystemIds.systemManagement,
systemId: ActorSystemIds.systemManagement,
src: 'topLevelSystemStuff',
},
Expand Down
39 changes: 29 additions & 10 deletions libs/permissions/permissionLogic/src/lib/permission-logic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,38 @@ import {
} from './permissionMonitor.machine';
import { someFeatureMachine } from './features/someFeature/someFeature.machine';
import { countingMachineThatNeedsPermissionAt3 } from './features/counting/counting.machine';
import { applicationMachine } from './application/application.machine';

describe('Counting Machine That Needs Permission At 3', () => {
it('should increment count to 3, ask for permission, and continue counting to 5 when permission is granted', async () => {
const permissionMonitorActor = createActor(
permissionMonitoringMachine.provide({
actors: {
features: countingMachineThatNeedsPermissionAt3,
},
}),
{
systemId: ActorSystemIds.permissionMonitoring,
}
).start();
const applicationActor = createActor(applicationMachine, {
systemId: ActorSystemIds.application,
});

// const permissionMonitorActor = applicationActor.system.get(ActorSystemIds.permissionMonitoring)

// const permissionMonitorActor = applicationActor
// .getSnapshot()
// .children[ActorSystemIds.systemManagement].getSnapshot().children[
// ActorSystemIds.permissionMonitoring
// ];

const permissionMonitorActor = applicationActor.system
.get(ActorSystemIds.systemManagement)
.getSnapshot().children[ActorSystemIds.permissionMonitoring];

console.log({ permissionMonitorActor });
// const permissionMonitorActor = createActor(
// permissionMonitoringMachine,
// // permissionMonitoringMachine.provide({
// // actors: {
// // features: countingMachineThatNeedsPermissionAt3,
// // },
// // }),
// {
// systemId: ActorSystemIds.permissionMonitoring,
// }
// ).start();

const state = permissionMonitorActor.getSnapshot();
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const systemManagementMachine = setup({
}).createMachine({
invoke: [
{
id: ActorSystemIds.permissionMonitoring,
systemId: ActorSystemIds.permissionMonitoring,
src: 'permissionMonitoringMachine',
},
Expand Down

0 comments on commit 044c7b5

Please sign in to comment.