Ver Fonte

[更新] 单元测试列表

WuXinyu há 7 anos atrás
pai
commit
9b01debc44

+ 2 - 0
mock/serializers/codehw/FunctionalTestSerializer.js

@@ -6,6 +6,7 @@ const dayjs = require("dayjs");
  * @typedef {Object} FunctionalTestSerializerType
  * @property {number} id 代码作业一次功能测试的 id
  * @property {number} time 测试时间
+ * @property {boolean} isPassAll 是否全部通过
  * @property {string|number} deployId 对应的部署 id
  * @property {OneFunctionalTestSerializerType[]} detail 所有测试用例列表
  */
@@ -37,6 +38,7 @@ module.exports = ({ id = makeId(), deployId = makeId() }) => {
     id,
     time: dayjs("2018-9-21").unix(),
     deployId,
+    isPassAll: id % 2 === 1,
     detail: [
       getOneFunctionalTestSerializer(),
       getOneFunctionalTestSerializer(),

+ 2 - 0
mock/serializers/codehw/UnitTestSerializer.js

@@ -6,6 +6,7 @@ const dayjs = require("dayjs");
  * @typedef {Object} UnitTestSerializerType
  * @property {number} id 代码作业一次单元测试的 id
  * @property {number} time 测试时间
+ * @property {boolean} isPassAll 是否全部通过
  * @property {string|number} buildId 对应的构建 id
  * @property {OneUnitTestSerializerType[]} detail 所有测试用例列表
  */
@@ -37,6 +38,7 @@ module.exports = ({ id = makeId(), buildId = makeId() }) => {
     id,
     buildId,
     time: dayjs("2018-9-21").unix(),
+    isPassAll: id % 2 === 1,
     detail: [
       getOneUnitTestSerializer(),
       getOneUnitTestSerializer(),

+ 2 - 4
src/api/codehw.js

@@ -31,15 +31,13 @@ export const getProjectList = homeworkId => {
 };
 
 /**
- * TODO:请确认 homeworkId 是否有用
  * 获得 Project 的详细信息
- * @param homeworkId
  * @param {string|number} projectId
  * @return {Promise<{id:string,data:ProjectSerializerType}>}
  */
-export const getProjectDetail = ({ homeworkId, projectId }) => {
+export const getProjectDetail = projectId => {
   //TODO:delete this before deploy
-  console.log(homeworkId, projectId);
+  console.log(projectId);
   return request(`${CODE_HOMEWORK_MODULE}/project/${projectId}`);
 };
 

+ 45 - 1
src/views/student/Code/ProjectDetail/TestDetail.vue

@@ -1,3 +1,47 @@
 <template>
-  <h1>TEST</h1>
+  <div class="columns is-desktop">
+    <div class="column">
+      <div class="page-section">
+        <h5 class="title is-5">单元测试:</h5>
+        <div
+          class="test-item"
+          :key="item.id"
+          v-for="item in projectDetail.unitTestList"
+        >
+          <div><strong>UNIT TEST : #</strong> {{ item.id }}</div>
+          <pass-tag :pass="item.isPassAll" />
+          <span>{{ item.time }}</span>
+        </div>
+      </div>
+    </div>
+    <div class="column"><div class="page-section">b</div></div>
+  </div>
 </template>
+
+<script>
+import PassTag from "@/views/student/Code/ProjectDetail/components/PassTag";
+export default {
+  components: { PassTag },
+  props: {
+    projectDetail: {
+      type: Object,
+      default: () => ({
+        unitTestList: [],
+        functionTestList: []
+      })
+    }
+  }
+};
+</script>
+
+<style lang="scss" scoped>
+@import "../../../../assets/scss/app";
+.test-item {
+  padding: $default-margin $default-margin-between;
+  margin: 0 -#{$default-margin-between};
+}
+
+.test-item:nth-child(odd) {
+  background-color: blue;
+}
+</style>

+ 20 - 0
src/views/student/Code/ProjectDetail/components/PassTag.vue

@@ -0,0 +1,20 @@
+<template>
+  <div v-if="pass" class="tag is-success" style="width: 55px;">
+    <strong style="color: white;">PASS</strong>
+  </div>
+  <div v-else class="tag is-danger" style="width: 55px;">
+    <strong style="color: white;">FAIL</strong>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "PassTag",
+  props: {
+    pass: {
+      type: Boolean,
+      default: false
+    }
+  }
+};
+</script>

+ 2 - 7
src/views/student/Code/ProjectDetail/index.vue

@@ -35,7 +35,6 @@
 </template>
 
 <script>
-import { mapState } from "vuex";
 import { getProjectDetail } from "@/api/codehw";
 import PageHeader from "@/components/PageHeader";
 import PageBody from "@/components/PageBody/index";
@@ -44,18 +43,14 @@ export default {
     PageBody,
     PageHeader
   },
-  computed: {
-    ...mapState({
-      course: state => state.course.currentCourse
-    })
-  },
   data() {
     return {
       projectDetail: {}
     };
   },
   async mounted() {
-    const detail = await getProjectDetail(this.course.id);
+    const { projectId } = this.$route.params;
+    const detail = await getProjectDetail(projectId);
     this.projectDetail = detail.data;
   }
 };

+ 1 - 1
src/views/student/Code/ProjectList/index.vue

@@ -16,7 +16,7 @@
           class="column is-4"
         >
           <router-link :to="`${$route.path}/${item.projectId}`">
-            <card hoverable>{{ item.projectName }}</card>
+            <card hoverable>{{ item.name }}</card>
           </router-link>
         </div>
       </div>