@@ -727,6 +727,76 @@ module('Integration | ai-assistant-panel', function (hooks) {
727
727
assert .dom (` ${stackCard } [data-test-country="Indonesia"] ` ).exists ();
728
728
});
729
729
730
+ test (' it can apply change when the command event is not a replacement event' , async function (assert ) {
731
+ let roomId = await renderAiAssistantPanel (` ${testRealmURL }Person/fadhlan ` );
732
+
733
+ await waitFor (' [data-test-person="Fadhlan"]' );
734
+ assert .dom (` [data-test-preferredcarrier="DHL"] ` ).exists ();
735
+
736
+ let payload = {
737
+ name: ' patchCard' ,
738
+ arguments: {
739
+ attributes: {
740
+ cardId: ` ${testRealmURL }Person/fadhlan ` ,
741
+ patch: {
742
+ attributes: {
743
+ firstName: ' Joy' ,
744
+ address: { shippingInfo: { preferredCarrier: ' UPS' } },
745
+ },
746
+ },
747
+ },
748
+ },
749
+ eventId: ' event1' ,
750
+ };
751
+ await simulateRemoteMessage (roomId , ' @aibot:localhost' , {
752
+ body: ' A patch' ,
753
+ msgtype: APP_BOXEL_COMMAND_MSGTYPE ,
754
+ formatted_body: ' A patch' ,
755
+ format: ' org.matrix.custom.html' ,
756
+ data: JSON .stringify ({ toolCall: payload }),
757
+ });
758
+
759
+ await waitFor (' [data-test-view-code-button]' );
760
+ await click (' [data-test-view-code-button]' );
761
+
762
+ await waitForCodeEditor ();
763
+ assert .deepEqual (
764
+ JSON .parse (getMonacoContent ()),
765
+
766
+ {
767
+ name: ' patchCard' ,
768
+ payload: {
769
+ attributes: {
770
+ cardId: ' http://test-realm/test/Person/fadhlan' ,
771
+ patch: {
772
+ attributes: {
773
+ address: {
774
+ shippingInfo: {
775
+ preferredCarrier: ' UPS' ,
776
+ },
777
+ },
778
+ firstName: ' Joy' ,
779
+ },
780
+ },
781
+ },
782
+ },
783
+ },
784
+ ' it can preview code when a change is proposed' ,
785
+ );
786
+ assert .dom (' [data-test-copy-code]' ).isEnabled (' copy button is available' );
787
+
788
+ await click (' [data-test-view-code-button]' );
789
+ assert .dom (' [data-test-code-editor]' ).doesNotExist ();
790
+
791
+ await click (' [data-test-command-apply="ready"]' );
792
+ await waitFor (' [data-test-command-card-idle]' );
793
+ assert .dom (' [data-test-apply-state="applied"]' ).exists ();
794
+ assert .dom (' [data-test-person]' ).hasText (' Joy' );
795
+ assert .dom (` [data-test-preferredcarrier] ` ).hasText (' UPS' );
796
+ assert .dom (` [data-test-city="Bandung"] ` ).exists ();
797
+ assert .dom (` [data-test-country="Indonesia"] ` ).exists ();
798
+ });
799
+
730
800
test (' it does not crash when applying change to a card with preexisting nested linked card' , async function (assert ) {
731
801
let id = ` ${testRealmURL }Person/mickey ` ;
732
802
let roomId = await renderAiAssistantPanel (id );
0 commit comments