Skip to content

Commit 06d0911

Browse files
committed
Test fixes
1 parent 340daf0 commit 06d0911

File tree

2 files changed

+28
-60
lines changed

2 files changed

+28
-60
lines changed

packages/host/app/components/matrix/room-message-command.gts

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
CardHeader,
2020
} from '@cardstack/boxel-ui/components';
2121

22-
import { MenuItem, bool, cn } from '@cardstack/boxel-ui/helpers';
22+
import { MenuItem, bool, cn, eq, not } from '@cardstack/boxel-ui/helpers';
2323
import { ArrowLeft, Copy as CopyIcon } from '@cardstack/boxel-ui/icons';
2424

2525
import { cardTypeDisplayName, cardTypeIcon } from '@cardstack/runtime-common';
@@ -201,10 +201,9 @@ export default class RoomMessageCommand extends Component<Signature> {
201201
{{else}}
202202
<div
203203
class='command-button-bar'
204-
{{! In test, if we change this isIdle check to the task running locally on this component, it will fail because roomMessages get destroyed during re-indexing.
205-
Since services are long-lived so it we will not have this issue. I think this will go away when we convert our room field into a room component }}
206-
{{! TODO: Convert to non-EC async method after fixing CS-6987 }}
207-
data-test-command-card-idle={{this.commandService.run.isIdle}}
204+
data-test-command-card-idle={{not
205+
(eq @messageCommand.status 'applying')
206+
}}
208207
>
209208
<Button
210209
class='view-code-button'

packages/host/tests/integration/components/ai-assistant-panel-test.gts

+24-55
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
369369
msgtype: APP_BOXEL_MESSAGE_MSGTYPE,
370370
formatted_body: `question #${i + 1}`,
371371
format: 'org.matrix.custom.html',
372+
isStreamingFinished: true,
372373
});
373374
let eventId = simulateRemoteMessage(roomId, '@aibot:localhost', {
374375
body: `answer #${i + 1}`,
@@ -397,6 +398,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
397398
msgtype: APP_BOXEL_MESSAGE_MSGTYPE,
398399
formatted_body: 'A patch',
399400
format: 'org.matrix.custom.html',
401+
isStreamingFinished: true,
400402
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
401403
{
402404
name: 'patchCard',
@@ -425,7 +427,6 @@ module('Integration | ai-assistant-panel', function (hooks) {
425427
});
426428
await click('[data-test-command-apply]');
427429
await waitFor('[data-test-command-card-idle]');
428-
429430
assert.dom('[data-test-person]').hasText('Dave');
430431
});
431432

@@ -453,6 +454,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
453454
body: 'Incorrect command',
454455
formatted_body: 'Incorrect command',
455456
format: 'org.matrix.custom.html',
457+
isStreamingFinished: true,
456458
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
457459
{
458460
id: 'd60582a6-8792-4505-8d38-656c1167f00d',
@@ -463,17 +465,14 @@ module('Integration | ai-assistant-panel', function (hooks) {
463465
},
464466
},
465467
],
466-
'm.relates_to': {
467-
rel_type: 'm.replace',
468-
event_id: '__EVENT_ID__',
469-
},
470468
});
471469

472470
simulateRemoteMessage(room1Id, '@aibot:localhost', {
473471
msgtype: APP_BOXEL_MESSAGE_MSGTYPE,
474472
body: 'Changing first name to Evie',
475473
formatted_body: 'Changing first name to Evie',
476474
format: 'org.matrix.custom.html',
475+
isStreamingFinished: true,
477476
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
478477
{
479478
id: '444ac6ed-eea2-459b-93f7-56117bf54f50',
@@ -488,17 +487,14 @@ module('Integration | ai-assistant-panel', function (hooks) {
488487
},
489488
},
490489
],
491-
'm.relates_to': {
492-
rel_type: 'm.replace',
493-
event_id: '__EVENT_ID__',
494-
},
495490
});
496491

497492
simulateRemoteMessage(room1Id, '@aibot:localhost', {
498493
msgtype: APP_BOXEL_MESSAGE_MSGTYPE,
499494
body: 'Changing first name to Jackie',
500495
formatted_body: 'Changing first name to Jackie',
501496
format: 'org.matrix.custom.html',
497+
isStreamingFinished: true,
502498
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
503499
{
504500
id: 'cddecff1-8f26-4170-91bf-5a2192fb2459',
@@ -513,10 +509,6 @@ module('Integration | ai-assistant-panel', function (hooks) {
513509
},
514510
},
515511
],
516-
'm.relates_to': {
517-
rel_type: 'm.replace',
518-
event_id: '__EVENT_ID__',
519-
},
520512
});
521513

522514
// let the room events all process before we open the assistant, so it will
@@ -596,6 +588,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
596588
msgtype: APP_BOXEL_MESSAGE_MSGTYPE,
597589
formatted_body: 'A patch',
598590
format: 'org.matrix.custom.html',
591+
isStreamingFinished: true,
599592
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [payload],
600593
'm.relates_to': {
601594
rel_type: 'm.replace',
@@ -655,6 +648,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
655648
body: 'Removing pet and changing preferred carrier',
656649
formatted_body: 'Removing pet and changing preferred carrier',
657650
format: 'org.matrix.custom.html',
651+
isStreamingFinished: true,
658652
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
659653
{
660654
name: 'patchCard',
@@ -673,10 +667,6 @@ module('Integration | ai-assistant-panel', function (hooks) {
673667
},
674668
},
675669
],
676-
'm.relates_to': {
677-
rel_type: 'm.replace',
678-
event_id: '__EVENT_ID__',
679-
},
680670
});
681671

682672
const stackCard = `[data-test-stack-card="${id}"]`;
@@ -696,6 +686,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
696686
body: 'Link to pet and change preferred carrier',
697687
formatted_body: 'Link to pet and change preferred carrier',
698688
format: 'org.matrix.custom.html',
689+
isStreamingFinished: true,
699690
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
700691
{
701692
name: 'patchCard',
@@ -762,6 +753,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
762753
msgtype: APP_BOXEL_MESSAGE_MSGTYPE,
763754
formatted_body: 'A patch',
764755
format: 'org.matrix.custom.html',
756+
isStreamingFinished: true,
765757
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [payload],
766758
});
767759

@@ -818,6 +810,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
818810
body: 'Change tripTitle to Trip to Japan',
819811
formatted_body: 'Change tripTitle to Trip to Japan',
820812
format: 'org.matrix.custom.html',
813+
isStreamingFinished: true,
821814
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
822815
{
823816
name: 'patchCard',
@@ -835,10 +828,6 @@ module('Integration | ai-assistant-panel', function (hooks) {
835828
},
836829
},
837830
],
838-
'm.relates_to': {
839-
rel_type: 'm.replace',
840-
event_id: '__EVENT_ID__',
841-
},
842831
});
843832

844833
await waitFor('[data-test-command-apply="ready"]');
@@ -859,6 +848,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
859848
body: 'Change first name to Dave',
860849
formatted_body: 'Change first name to Dave',
861850
format: 'org.matrix.custom.html',
851+
isStreamingFinished: true,
862852
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
863853
{
864854
id: '8c848ebb-3e09-4ba3-b21d-348bdd7bd1ff',
@@ -873,16 +863,13 @@ module('Integration | ai-assistant-panel', function (hooks) {
873863
},
874864
},
875865
],
876-
'm.relates_to': {
877-
rel_type: 'm.replace',
878-
event_id: '__EVENT_ID__',
879-
},
880866
});
881867
simulateRemoteMessage(roomId, '@aibot:localhost', {
882868
msgtype: APP_BOXEL_MESSAGE_MSGTYPE,
883869
body: 'Incorrect patch command',
884870
formatted_body: 'Incorrect patch command',
885871
format: 'org.matrix.custom.html',
872+
isStreamingFinished: true,
886873
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
887874
{
888875
id: '773c6c9b-a247-4099-8ec0-44f3ea197938',
@@ -893,16 +880,13 @@ module('Integration | ai-assistant-panel', function (hooks) {
893880
},
894881
},
895882
],
896-
'm.relates_to': {
897-
rel_type: 'm.replace',
898-
event_id: '__EVENT_ID__',
899-
},
900883
});
901884
simulateRemoteMessage(roomId, '@aibot:localhost', {
902885
msgtype: APP_BOXEL_MESSAGE_MSGTYPE,
903886
body: 'Change first name to Jackie and switch to code mode',
904887
formatted_body: 'Change first name to Jackie and switch to code mode',
905888
format: 'org.matrix.custom.html',
889+
isStreamingFinished: true,
906890
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
907891
{
908892
id: '127538b2-b0d1-4902-bd09-1fdf55063f07',
@@ -926,10 +910,6 @@ module('Integration | ai-assistant-panel', function (hooks) {
926910
},
927911
},
928912
],
929-
'm.relates_to': {
930-
rel_type: 'm.replace',
931-
event_id: '__EVENT_ID__',
932-
},
933913
});
934914

935915
await waitFor('[data-test-command-apply="ready"]', { count: 4 });
@@ -985,6 +965,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
985965
body: 'Change first name to Dave',
986966
formatted_body: 'Change first name to Dave',
987967
format: 'org.matrix.custom.html',
968+
isStreamingFinished: true,
988969
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
989970
{
990971
name: 'patchCard',
@@ -998,10 +979,6 @@ module('Integration | ai-assistant-panel', function (hooks) {
998979
},
999980
},
1000981
],
1001-
'm.relates_to': {
1002-
rel_type: 'm.replace',
1003-
event_id: '__EVENT_ID__',
1004-
},
1005982
});
1006983

1007984
await waitFor('[data-test-command-apply="ready"]', { count: 1 });
@@ -1083,6 +1060,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
10831060
data: JSON.stringify({
10841061
attachedCardsEventIds: [cardFragmentsEventId],
10851062
}),
1063+
isStreamingFinished: true,
10861064
},
10871065
{ origin_server_ts: now + 60000 },
10881066
);
@@ -1128,6 +1106,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
11281106
msgtype: APP_BOXEL_MESSAGE_MSGTYPE,
11291107
formatted_body: `question #1`,
11301108
format: 'org.matrix.custom.html',
1109+
isStreamingFinished: true,
11311110
});
11321111
let messageEventId = simulateRemoteMessage(roomId, '@aibot:localhost', {
11331112
body: `Thinking...`,
@@ -1141,6 +1120,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
11411120
msgtype: APP_BOXEL_MESSAGE_MSGTYPE,
11421121
formatted_body: `Thinking...`,
11431122
format: 'org.matrix.custom.html',
1123+
isStreamingFinished: true,
11441124
});
11451125
setReadReceipt(roomId, messageEventId, '@testuser:localhost');
11461126
setReadReceipt(roomId, commandEventId, '@testuser:localhost');
@@ -1181,6 +1161,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
11811161
event_id: commandEventId,
11821162
rel_type: 'm.replace',
11831163
},
1164+
isStreamingFinished: true,
11841165
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
11851166
{
11861167
name: 'patchCard',
@@ -1630,6 +1611,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
16301611
msgtype: APP_BOXEL_MESSAGE_MSGTYPE,
16311612
formatted_body: 'A patch',
16321613
format: 'org.matrix.custom.html',
1614+
isStreamingFinished: true,
16331615
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
16341616
{
16351617
id: 'fb8fef81-2142-4861-a902-d5614b0aea52',
@@ -1644,10 +1626,6 @@ module('Integration | ai-assistant-panel', function (hooks) {
16441626
},
16451627
},
16461628
],
1647-
'm.relates_to': {
1648-
rel_type: 'm.replace',
1649-
event_id: 'patch1',
1650-
},
16511629
});
16521630

16531631
await waitFor('[data-test-message-idx="0"]');
@@ -2471,7 +2449,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
24712449
);
24722450
await waitFor('[data-test-person="Fadhlan"]');
24732451
let roomId = createAndJoinRoom({
2474-
sender: '@testuser:staging',
2452+
sender: '@testuser:localhost',
24752453
name: 'test room 1',
24762454
});
24772455
let initialEventId = simulateRemoteMessage(roomId, '@aibot:localhost', {
@@ -2510,7 +2488,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
25102488
.exists();
25112489
});
25122490

2513-
test('after command is issued, a reaction event will be dispatched', async function (assert) {
2491+
test('when command is done streaming, apply button is shown in ready state', async function (assert) {
25142492
await setCardInOperatorModeState(`${testRealmURL}Person/fadhlan`);
25152493
await renderComponent(
25162494
class TestDriver extends GlimmerComponent {
@@ -2670,6 +2648,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
26702648
body: 'Changing first name to Evie',
26712649
formatted_body: 'Changing first name to Evie',
26722650
format: 'org.matrix.custom.html',
2651+
isStreamingFinished: true,
26732652
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
26742653
{
26752654
name: 'patchCard',
@@ -2683,10 +2662,6 @@ module('Integration | ai-assistant-panel', function (hooks) {
26832662
},
26842663
},
26852664
],
2686-
'm.relates_to': {
2687-
rel_type: 'm.replace',
2688-
event_id: '__EVENT_ID__',
2689-
},
26902665
});
26912666
let commandResultEvents = getRoomEvents(roomId).filter(
26922667
(event) =>
@@ -2747,6 +2722,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
27472722
msgtype: APP_BOXEL_MESSAGE_MSGTYPE,
27482723
formatted_body: 'Changing first name to Evie',
27492724
format: 'org.matrix.custom.html',
2725+
isStreamingFinished: true,
27502726
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
27512727
{
27522728
name: 'patchCard',
@@ -2760,10 +2736,6 @@ module('Integration | ai-assistant-panel', function (hooks) {
27602736
},
27612737
},
27622738
],
2763-
'm.relates_to': {
2764-
rel_type: 'm.replace',
2765-
event_id: '__EVENT_ID__',
2766-
},
27672739
});
27682740
let commandResultEvents = getRoomEvents(roomId).filter(
27692741
(event) => event.type === APP_BOXEL_COMMAND_RESULT_EVENT_TYPE,
@@ -3092,6 +3064,7 @@ module('Integration | ai-assistant-panel', function (hooks) {
30923064
body: 'Changing first name to Evie',
30933065
formatted_body: 'Changing first name to Evie',
30943066
format: 'org.matrix.custom.html',
3067+
isStreamingFinished: true,
30953068
[APP_BOXEL_COMMAND_REQUESTS_KEY]: [
30963069
{
30973070
name: 'patchCard',
@@ -3105,10 +3078,6 @@ module('Integration | ai-assistant-panel', function (hooks) {
31053078
},
31063079
},
31073080
],
3108-
'm.relates_to': {
3109-
rel_type: 'm.replace',
3110-
event_id: '__EVENT_ID__',
3111-
},
31123081
});
31133082

31143083
await settled();

0 commit comments

Comments
 (0)