Bläddra i källkod

Merge remote-tracking branch 'origin/master' into feature/dlwork

Prevalence 7 år sedan
förälder
incheckning
d4036086f7

+ 0 - 4
package.json

@@ -34,13 +34,10 @@
     "@pollyjs/persister-fs": "^1.4.1",
     "@pollyjs/persister-local-storage": "^1.4.1",
     "@vue/cli-plugin-babel": "^3.2.0",
-    "@vue/cli-plugin-e2e-nightwatch": "^3.2.0",
     "@vue/cli-plugin-eslint": "^3.2.0",
     "@vue/cli-plugin-pwa": "^3.2.0",
-    "@vue/cli-plugin-unit-jest": "^3.2.0",
     "@vue/cli-service": "^3.2.0",
     "@vue/eslint-config-prettier": "^4.0.0",
-    "@vue/test-utils": "^1.0.0-beta.20",
     "babel-core": "7.0.0-bridge.0",
     "babel-eslint": "^10.0.1",
     "babel-jest": "^23.6.0",
@@ -52,7 +49,6 @@
     "lint-staged": "^7.2.2",
     "node-sass": "^4.9.0",
     "sass-loader": "^7.0.1",
-    "setup-polly-jest": "^0.5.2",
     "vue-cli-plugin-buefy": "^0.3.3",
     "vue-template-compiler": "^2.5.17",
     "winston": "^3.1.0"

+ 30 - 22
src/components/AssignmentCRUD/CreateAssignment/index.vue

@@ -232,7 +232,6 @@ export default {
       errorMassage: null,
       isServerError: false,
       submitting: false,
-
       // 转圈圈
       loadingSearchQuestions: false,
       loadingCreateAssignment: false
@@ -318,30 +317,39 @@ export default {
           // 代码作业
           this.myPromise = postCodeAssignment(param, this.courseId);
         }
-        this.myPromise.then(res => {
-          //创建成功
-          this.isCreateModalActive = false;
-          if (res.code === 0) {
-            if (this.assignType === 1) {
-              this.$router.push({
-                path: `${this.prefix}/review?documentHwId=${res.data.id}`
+        this.myPromise
+          .then(res => {
+            //创建成功
+            this.isCreateModalActive = false;
+            this.submitting = false;
+            if (res.code === 0) {
+              if (this.assignType === 1) {
+                this.$router.push({
+                  path: `${this.prefix}/review?documentHwId=${res.data.id}`
+                });
+              }
+              this.$emit("sendCreatedAssignment", res.data);
+              this.loadingCreateAssignment = false;
+            } else {
+              //创建失败
+              this.isCreateModalActive = false;
+              this.loadingCreateAssignment = false;
+
+              this.$dialog.alert({
+                title: "创建失败",
+                message: res.message,
+                type: "is-danger",
+                hasIcon: true
               });
             }
-            this.$emit("sendCreatedAssignment", res.data);
-            this.loadingCreateAssignment = false;
-          } else {
-            //创建失败
-            this.isCreateModalActive = false;
-            this.loadingCreateAssignment = false;
-            this.$dialog.alert({
-              title: "创建失败",
-              message: res.message,
-              type: "is-danger",
-              hasIcon: true
+          })
+          .catch(e => {
+            this.submitting = false;
+            this.$toast.open({
+              message: e.message || "服务器未知错误",
+              type: "is-danger"
             });
-          }
-        });
-        this.submitting = false;
+          });
       }
     },
     getDifficultyType(level) {

+ 1 - 1
src/mixins/time.js

@@ -11,7 +11,7 @@ export default {
       return {
         enableTime: true,
         dateFormat: "U",
-        altFormat: "M	j, Y  H:i",
+        altFormat: "Y年n月J h:i K",
         altInput: true,
         locale: Mandarin
       };

+ 2 - 2
src/views/login/Register.vue

@@ -5,13 +5,13 @@
       {{ errorMassage }}
     </b-notification>
     <b-field
-      label="昵称"
+      label="学号"
       :type="$v.nickname.$error ? 'is-danger' : ''"
       :message="$v.nickname.$error ? '昵称须由长度为4至16的字母或数字组成' : ''"
     >
       <b-input
         v-model="$v.nickname.$model"
-        placeholder="在此输入昵称"
+        placeholder="在此输入学号"
       ></b-input>
     </b-field>
     <b-field

+ 8 - 13
src/views/student/Code/ProjectDetail/DeployDetail.vue

@@ -37,7 +37,7 @@
         </div>
       </div>
       <button
-        :class="['button', 'block', 'is-link', { 'is-loading': isRunning }]"
+        :class="['button', 'block', 'is-link', { 'is-loading': isRunning || deployButtonDisabled }]"
         @click="startDeploy"
         style="margin-top: 20px;"
       >
@@ -116,7 +116,8 @@ export default {
       latestMirrorIdList: [],
       radio: -1,
       isfetchLog: false,
-      latestDeployId: 0
+      latestDeployId: 0,
+      deployButtonDisabled: false
     };
   },
   props: {
@@ -131,13 +132,6 @@ export default {
   },
   watch: {
     projectDetail: function() {
-      // console.log(newVal);
-      //获取最新一次部署详细信息
-      // if (newVal.latestDeploy && newVal.latestDeploy.id) {
-      //   // this.haveDeployRecord = true;
-      //
-      //   // this.getDeployLogInfo(this.projectDetail.latestDeploy.id);
-      // }
       this.getLatestDeployInfo();
       this.getLatestBuildInfo(this.projectDetail && this.projectDetail.id, 5);
       this.getLastNDeployInfoList(
@@ -199,11 +193,13 @@ export default {
     },
     //开始部署
     startDeploy() {
+      this.deployButtonDisabled = true;
       if (this.radio == -1) {
         this.$toast.open({
           message: "请先选择镜像",
           type: "is-danger"
         });
+        this.deployButtonDisabled = false;
         return;
       } else {
         let mirrorId = this.getSelectedMirrorId();
@@ -214,6 +210,7 @@ export default {
           replicas: 1
         })
           .then(res => {
+            this.deployButtonDisabled = false;
             if (res.data.status == "SUCCESS") {
               this.$toast.open({
                 message: "不要重复部署哦~",
@@ -221,18 +218,16 @@ export default {
               });
               return;
             }
-            // console.log(res);
             this.$toast.open({
               message: "开始部署",
               type: "is-success"
             });
             this.isRunning = true;
             this.deployInfo = res.data;
-            // setTimeout(() => {
-            //   this.getLatestDeployInfo(this.projectDetail.latestDeploy.id);
-            // }, 1000);
+            this.latestDeployId = res.data.id;
           })
           .catch(e => {
+            this.deployButtonDisabled = false;
             this.$toast.open({
               message: e.message || "服务器未知错误",
               type: "is-danger"

+ 2 - 1
src/views/student/Code/ProjectDetail/Test/FunctionalTestDetail.vue

@@ -18,7 +18,8 @@
         页面测试 #{{ testDetail.id }}
       </template>
       <template slot="content">
-        <pass-tag :pass="testDetail.passAll" />
+        <pass-tag v-if="testDetail.status == 1" :pass="testDetail.passAll" />
+        <b-tag v-else type="is-warning">RUNNING</b-tag>
       </template>
       <template slot="extraContent">
         <div class="tag">{{ displayUnixTime(testDetail.time) }}</div>

+ 10 - 2
src/views/student/Code/ProjectDetail/Test/UnitTestDetail.vue

@@ -18,7 +18,8 @@
         单元测试 #{{ testDetail.id }}
       </template>
       <template slot="content">
-        <pass-tag :pass="testDetail.passAll" />
+        <pass-tag v-if="testDetail.status == 1" :pass="testDetail.passAll" />
+        <b-tag v-else type="is-warning">RUNNING</b-tag>
       </template>
       <template slot="extraContent">
         <div class="tag">{{ displayUnixTime(testDetail.time) }}</div>
@@ -69,8 +70,15 @@ import { getUnitTestDetail } from "@/api/codehw";
 import timeMixins from "@/mixins/time";
 import PassTag from "@/views/student/Code/ProjectDetail/components/PassTag";
 import PageSectionLoading from "@/components/PageBody/PageSectionLoading/index";
+import BTag from "buefy/src/components/tag/Tag";
 export default {
-  components: { PageSectionLoading, PassTag, PageBody, PageHeader },
+  components: {
+    BTag,
+    PageSectionLoading,
+    PassTag,
+    PageBody,
+    PageHeader
+  },
   data() {
     return {
       testDetail: { detail: [] },

+ 4 - 0
src/views/student/Code/ProjectDetail/TestDetail.vue

@@ -16,6 +16,7 @@
         >
           <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>
@@ -53,6 +54,7 @@
         >
           <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>
@@ -67,9 +69,11 @@ import PassTag from "@/views/student/Code/ProjectDetail/components/PassTag";
 import timeMixins from "@/mixins/time";
 import { makeFunctionalTest } from "@/api/codehw";
 import PageSectionLoading from "@/components/PageBody/PageSectionLoading/index";
+import BTag from "buefy/src/components/tag/Tag";
 
 export default {
   components: {
+    BTag,
     PageSectionLoading,
     PassTag
   },

+ 0 - 19
tests/e2e/custom-assertions/elementCount.js

@@ -1,19 +0,0 @@
-// A custom Nightwatch assertion.
-// The assertion name is the filename.
-// Example usage:
-//
-//   browser.assert.elementCount(selector, count)
-//
-// For more information on custom assertions see:
-// http://nightwatchjs.org/guide#writing-custom-assertions
-
-exports.assertion = function elementCount(selector, count) {
-  this.message = `Testing if element <${selector}> has count: ${count}`;
-  this.expected = count;
-  this.pass = val => val === count;
-  this.value = res => res.value;
-  function evaluator(_selector) {
-    return document.querySelectorAll(_selector).length;
-  }
-  this.command = cb => this.api.execute(evaluator, [selector], cb);
-};

+ 0 - 14
tests/e2e/specs/test.js

@@ -1,14 +0,0 @@
-// For authoring Nightwatch tests, see
-// http://nightwatchjs.org/guide#usage
-
-module.exports = {
-  "default e2e tests": browser => {
-    browser
-      .url(process.env.VUE_DEV_SERVER_URL)
-      .waitForElementVisible("#app", 5000)
-      .assert.elementPresent(".hello")
-      .assert.containsText("h1", "Welcome to Your Vue.js App")
-      .assert.elementCount("img", 1)
-      .end();
-  }
-};

+ 0 - 5
tests/unit/.eslintrc.js

@@ -1,5 +0,0 @@
-module.exports = {
-  env: {
-    jest: true
-  }
-};

+ 0 - 15
tests/unit/api/polly.config.js

@@ -1,15 +0,0 @@
-import { Polly } from "@pollyjs/core";
-import FetchAdapter from "@pollyjs/adapter-fetch";
-import XHRAdapter from "@pollyjs/adapter-xhr";
-import LocalStoragePersister from "@pollyjs/persister-local-storage";
-
-Polly.register(FetchAdapter);
-Polly.register(XHRAdapter);
-Polly.register(LocalStoragePersister);
-
-export default Polly;
-
-export const pollyConfig = {
-  adapters: ["fetch", "xhr"],
-  persister: "local-storage"
-};

+ 0 - 22
tests/unit/api/user.spec.js

@@ -1,22 +0,0 @@
-import { setupPolly } from "setup-polly-jest";
-import "whatwg-fetch";
-const getPost = async id => {
-  const response = await fetch(`/posts/${id}`);
-
-  const json = await response.json();
-
-  return Object.assign(json, { ok: response.ok, status: response.status });
-};
-describe("user api test", () => {
-  let context = setupPolly({
-    /* default configuration options */
-  });
-
-  test("should have polly running with `test`", async () => {
-    const { server } = context.polly;
-    server.get("/posts/*path").intercept((req, res) => {
-      res.send(1);
-    });
-    expect(await getPost(1)).toHaveProperty("id", 1);
-  });
-});

+ 0 - 12
tests/unit/example.spec.js

@@ -1,12 +0,0 @@
-import { shallowMount } from "@vue/test-utils";
-import HelloWorld from "@/components/HelloWorld.vue";
-
-describe("HelloWorld.vue", () => {
-  it("renders props.msg when passed", () => {
-    const msg = "new message";
-    const wrapper = shallowMount(HelloWorld, {
-      propsData: { msg }
-    });
-    expect(wrapper.text()).toMatch(msg);
-  });
-});

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 31 - 472
yarn.lock


Vissa filer visades inte eftersom för många filer har ändrats