message: test workflow calling milestone + epiloge resetFrom
diff: @@ -3,7 +3,9 @@ import { setupTest } from 'ember-qunit';
  import { Milestone } from '@cardstack/web-client/models/workflow/milestone';
  import { Workflow } from '@cardstack/web-client/models/workflow';
  import { WorkflowMessage } from '@cardstack/web-client/models/workflow/workflow-message';
  +import { WorkflowCard } from '@cardstack/web-client/models/workflow/workflow-card';
  import { WorkflowPostable } from '@cardstack/web-client/models/workflow/workflow-postable';
  +import PostableCollection from '@cardstack/web-client/models/workflow/postable-collection';
  module('Unit | Workflow model', function (hooks) {
  setupTest(hooks);
  @@ -114,4 +116,82 @@ module('Unit | Workflow model', function (hooks) {
  workflow.milestones = [exampleMilestone];
  assert.equal(workflow.progressStatus, 'Workflow Started');
  });
  +
  + test('Workflow.resetTo resets each milestone and its epilogue correctly', function (assert) {
  + const testWorkflow = new ConcreteWorkflow({});
  + let indicesArray: string[] = [];
  + let epilogueReset = false;
  +
  + class DummyResetFromEpilogue extends PostableCollection {
  + resetFrom() {
  + epilogueReset = true;
  + }
  + }
  +
  + class DummyResetFromMilestone extends Milestone {
  + milestoneIndex: number;
  + constructor(initArgs: any, milestoneIndex: number) {
  + super(initArgs);
  + this.milestoneIndex = milestoneIndex;
  + }
  +
  + resetFrom(index: number) {
  + indicesArray.push(`${this.milestoneIndex}-${index}`);
  + }
  + }
  +
  + const createPostable = () =>
  + new WorkflowCard({
  + author: { name: 'cardbot' },
  + componentName: 'foo/bar',
  + });
  +
  + let targetPostable1 = createPostable();
  + let targetPostable2 = createPostable();
  +
  + let milestones = [
  + new DummyResetFromMilestone(
  + {
  + title: 'Milestone 1',
  + postables: [createPostable(), createPostable(), targetPostable1],
  + completedDetail: 'Milestone 1 done',
  + },
  + 0
  + ),
  + new DummyResetFromMilestone(
  + {
  + title: 'Milestone 2',
  + postables: [createPostable(), targetPostable2, createPostable()],
  + completedDetail: 'Milestone 1 done',
  + },
  + 1
  + ),
  + new DummyResetFromMilestone(
  + {
  + title: 'Milestone 3',
  + postables: [createPostable(), createPostable()],
  + completedDetail: 'Milestone 3 done',
  + },
  + 2
  + ),
  + ];
  + testWorkflow.milestones = milestones;
  + testWorkflow.epilogue = new DummyResetFromEpilogue();
  + testWorkflow.attachWorkflow();
  + testWorkflow.resetTo(targetPostable1);
  + assert.equal(indicesArray.length, 3);
  + assert.ok(indicesArray.includes('0-2'));
  + assert.ok(indicesArray.includes('1-0'));
  + assert.ok(indicesArray.includes('2-0'));
  + assert.ok(epilogueReset);
  +
  + indicesArray = [];
  + epilogueReset = false;
  +
  + testWorkflow.resetTo(targetPostable2);
  + assert.equal(indicesArray.length, 2);
  + assert.ok(indicesArray.includes('1-1'));
  + assert.ok(indicesArray.includes('2-0'));
  + assert.ok(epilogueReset);
  + });
  });
  