Forráskód Böngészése

[ui] Vue 3 - UTs - Fixed ExecutableActions UTs

sreenaths 4 éve
szülő
commit
44a96eddd8

+ 2 - 2
desktop/core/src/desktop/js/apps/editor/components/ExecutableActions.test.ts

@@ -99,10 +99,10 @@ describe('ExecutableActions.vue', () => {
       }
     });
 
-    expect(spy).toHaveBeenCalled();
-
     await nextTick();
 
+    expect(spy).toHaveBeenCalled();
+
     // Click play
     expect(executeCalled).toBeFalsy();
     expect(wrapper.get('button').text()).toContain('Execute');

+ 11 - 8
desktop/core/src/desktop/js/apps/editor/components/ExecutableActions.vue

@@ -43,7 +43,7 @@
       v-if="showStop && !stopping"
       key="stop-button"
       :small="true"
-      alert="true"
+      :alert="true"
       @click="stop"
     >
       <i class="fa fa-stop fa-fw" />
@@ -51,7 +51,7 @@
       <span v-else>{{ I18n('Stop') }}</span>
     </hue-button>
 
-    <hue-button v-if="showStop && stopping" key="stopping-button" small="true" alert="true">
+    <hue-button v-if="showStop && stopping" key="stopping-button" :small="true" :alert="true">
       <i class="fa fa-fw fa-spinner fa-spin" /> {{ I18n('Stopping') }}
     </hue-button>
 
@@ -152,22 +152,25 @@
     },
 
     watch: {
-      executable(): void {
-        if (this.executable) {
-          this.updateFromExecutable(this.executable);
-        }
+      executable: {
+        handler(): void {
+          if (this.executable) {
+            this.updateFromExecutable(this.executable);
+          }
+        },
+        immediate: true
       }
     },
 
     mounted(): void {
       this.subTracker.subscribe(EXECUTABLE_UPDATED_EVENT, executable => {
-        if (this.executable.id === executable.id) {
+        if (this.executable != undefined && this.executable.id === executable.id) {
           this.updateFromExecutable(executable);
         }
       });
 
       this.subTracker.subscribe(EXECUTE_ACTIVE_EXECUTABLE_EVENT, executable => {
-        if (this.executable === executable) {
+        if (this.executable != undefined && this.executable === executable) {
           this.execute();
         }
       });

+ 5 - 14
desktop/core/src/desktop/js/apps/editor/components/__snapshots__/ExecutableActions.test.ts.snap

@@ -33,23 +33,14 @@ exports[`ExecutableActions.vue should show execute once the session is loaded 1`
 <div
   class="snippet-execute-actions"
 >
-  <!---->
-   
+  <!--v-if-->
   <hue-button-stub
+    disabled="false"
     primary="true"
     small="true"
-  >
-    <i
-      class="fa fa-play fa-fw"
-    />
-     Execute
-  
-  </hue-button-stub>
-   
-  <!---->
-   
-  <!---->
-   
+  />
+  <!--v-if-->
+  <!--v-if-->
   <form
     autocomplete="off"
     class="inline-block margin-left-10"