Преглед изворни кода

学生代码作业测试界面

靳炳淑 пре 6 година
родитељ
комит
7783d467ff
1 измењених фајлова са 110 додато и 24 уклоњено
  1. 110 24
      src/views/student/Code/ProjectDetail/TestDetail.vue

+ 110 - 24
src/views/student/Code/ProjectDetail/TestDetail.vue

@@ -17,24 +17,69 @@
           <div><strong>UNIT TEST : #</strong> {{ item.id }}</div>
           <pass-tag v-if="item.status == 1" :pass="item.passAll" />
           <b-tag v-else type="is-warning">RUNNING</b-tag>
-          <span style="padding-left: 10px">{{
-            displayUnixTime(item.time)
-          }}</span>
+          <span style="padding-left: 10px">
+            {{ displayUnixTime(item.time) }}
+          </span>
         </router-link>
       </div>
     </div>
     <div class="column">
       <div v-if="detailLoading"><page-section-loading show /></div>
-      <div v-else class="page-section">
+      <!--test-->
+      <div v-if="!detailLoading" class="page-section">
+        <h5 class="test-title title is-5">
+          Test环境页面测试:
+          <div
+            :class="{ 'is-loading': testTesting }"
+            @click="makeTestTest"
+            :disabled="
+              !(
+                projectDetail.deploy &&
+                projectDetail.deploy.latestTestDeploy &&
+                projectDetail.deploy.latestTestDeploy.status &&
+                projectDetail.deploy.latestTestDeploy.status == 'SUCCESS'
+              )
+            "
+            class="button is-primary test-title__action"
+          >
+            触发测试
+          </div>
+        </h5>
+        <div v-if="!(testFunctionTestList && testFunctionTestList.length > 0)">
+          <strong>当前暂无页面测试数据</strong>
+        </div>
+        <router-link
+          class="test-item"
+          :key="item.id"
+          :to="`${$route.path}/functional/${item.id}`"
+          v-for="item in testFunctionTestList"
+          tag="div"
+        >
+          <div><strong>FUNCTIONAL TEST : #</strong> {{ item.id }}</div>
+          <pass-tag v-if="item.status == 1" :pass="item.passAll" />
+          <b-tag v-else type="is-warning">RUNNING</b-tag>
+          <span style="padding-left: 10px">
+            {{ displayUnixTime(item.time) }}
+          </span>
+        </router-link>
+      </div>
+      <!--prod-->
+      <div
+        v-if="!detailLoading"
+        class="page-section"
+        :style="{ marginTop: '20px' }"
+      >
         <h5 class="test-title title is-5">
-          页面测试:
+          Prod环境页面测试:
           <div
-            :class="{ 'is-loading': testing }"
-            @click="makeTest"
+            :class="{ 'is-loading': prodTesting }"
+            @click="makeProdTest"
             :disabled="
               !(
-                projectDetail.latestDeploy &&
-                projectDetail.latestDeploy.status == 'SUCCESS'
+                projectDetail.deploy &&
+                projectDetail.deploy.latestProdDeploy &&
+                projectDetail.deploy.latestProdDeploy.status &&
+                projectDetail.deploy.latestProdDeploy.status == 'SUCCESS'
               )
             "
             class="button is-primary test-title__action"
@@ -42,22 +87,22 @@
             触发测试
           </div>
         </h5>
-        <div v-if="!(functionTestList && functionTestList.length > 0)">
+        <div v-if="!(prodFunctionTestList && prodFunctionTestList.length > 0)">
           <strong>当前暂无页面测试数据</strong>
         </div>
         <router-link
           class="test-item"
           :key="item.id"
           :to="`${$route.path}/functional/${item.id}`"
-          v-for="item in functionTestList"
+          v-for="item in prodFunctionTestList"
           tag="div"
         >
           <div><strong>FUNCTIONAL TEST : #</strong> {{ item.id }}</div>
           <pass-tag v-if="item.status == 1" :pass="item.passAll" />
           <b-tag v-else type="is-warning">RUNNING</b-tag>
-          <span style="padding-left: 10px">{{
-            displayUnixTime(item.time)
-          }}</span>
+          <span style="padding-left: 10px">
+            {{ displayUnixTime(item.time) }}
+          </span>
         </router-link>
       </div>
     </div>
@@ -82,7 +127,8 @@ export default {
       type: Object,
       default: () => ({
         unitTestList: [],
-        functionTestList: []
+        prodFunctionTestList: [],
+        testFunctionTestList: []
       })
     },
     detailLoading: {
@@ -94,35 +140,41 @@ export default {
     unitTestList() {
       return this.sortTestList(this.projectDetail.unitTestList);
     },
-    functionTestList() {
-      return this.sortTestList(this.projectDetail.functionTestList);
+    prodFunctionTestList() {
+      return this.sortTestList(this.projectDetail.prodFunctionTestList);
+    },
+    testFunctionTestList() {
+      return this.sortTestList(this.projectDetail.testFunctionTestList);
     }
   },
   data() {
     return {
-      testing: false
+      prodTesting: false,
+      testTesting: false
     };
   },
   mixins: [timeMixins],
   methods: {
-    async makeTest() {
+    async makeTestTest() {
       if (
         !(
-          this.projectDetail.latestDeploy &&
-          this.projectDetail.latestDeploy.status == "SUCCESS"
+          this.projectDetail.deploy &&
+          this.projectDetail.deploy.latestTestDeploy &&
+          this.projectDetail.deploy.latestTestDeploy.status &&
+          this.projectDetail.deploy.latestTestDeploy.status == "SUCCESS"
         )
       ) {
         return;
       }
-      this.testing = true;
-      const deployId = this.projectDetail.latestDeploy.id;
+      this.testTesting = true;
+      const deployId = this.projectDetail.deploy.latestTestDeploy.id;
       const { homeworkId, projectId } = this.$route.params;
       const { data } = await makeFunctionalTest({
         homeworkId,
         projectId,
         deployId
       });
-      this.testing = false;
+      this.testTesting = false;
       if (data.success) {
         this.$toast.open({
           message: `测试触发成功`,
@@ -135,6 +187,40 @@ export default {
         });
       }
     },
+
+    async makeProdTest() {
+      if (
+        !(
+          this.projectDetail.deploy &&
+          this.projectDetail.deploy.latestProdDeploy &&
+          this.projectDetail.deploy.latestProdDeploy.status &&
+          this.projectDetail.deploy.latestProdDeploy.status == "SUCCESS"
+        )
+      ) {
+        return;
+      }
+      this.prodTesting = true;
+      const deployId = this.projectDetail.deploy.latestProdDeploy.id;
+      const { homeworkId, projectId } = this.$route.params;
+      const { data } = await makeFunctionalTest({
+        homeworkId,
+        projectId,
+        deployId
+      });
+      this.prodTesting = false;
+      if (data.success) {
+        this.$toast.open({
+          message: `测试触发成功`,
+          type: "is-success"
+        });
+      } else {
+        this.$toast.open({
+          message: `测试触发失败`,
+          type: "is-danger"
+        });
+      }
+    },
+
     sortTestList(list) {
       if (!list) return [];
       const copyList = list.slice(0);