Selaa lähdekoodia

添加 MarkHeader 测试

Michael Wang 2 vuotta sitten
vanhempi
commit
a8ae5b9ef9

+ 35 - 0
cypress/e2e/login.cy.ts

@@ -0,0 +1,35 @@
+describe("The /web/mark Page", () => {
+  it("logs in programmatically without using the UI", function () {
+    const user = {
+      loginType: "mark-login",
+      loginName: "1-431-2-1",
+      password: "123456",
+      examId: "1",
+      markerId: "451",
+    };
+
+    const { loginType, loginName, password, examId, markerId } = user;
+    const form = new FormData();
+    form.append("loginType", loginType);
+    form.append("loginName", loginName);
+    form.append("password", password);
+
+    // programmatically log us in without needing the UI
+    cy.request("POST", "/login", form);
+
+    const formSubject = new FormData();
+    formSubject.append("examId", examId);
+    formSubject.append("markerId", markerId);
+    cy.request("POST", "/mark/subject-select", formSubject);
+
+    // now that we're logged in, we can visit
+    // any kind of restricted route!
+    cy.visit("/");
+
+    // our auth cookie should be present
+    // cy.getCookie("").should("exist");
+
+    // UI should reflect this user being logged in
+    cy.get(".header-container").should("contain", "张小兰");
+  });
+});

+ 21 - 0
cypress/e2e/mark-header.spec.cy.ts

@@ -0,0 +1,21 @@
+describe("评卷页面", () => {
+  it("成功加载", () => {
+    cy.visit("/"); // change URL to match your dev URL
+  });
+
+  it("科目代码和名称显示", () => {
+    cy.visit("/");
+    cy.get(".header-container a").should("contain", "431-金融学综合");
+  });
+
+  it("用户姓名显示", () => {
+    cy.visit("/");
+    cy.get(".header-container").should("contain", "张小兰");
+  });
+
+  it("小助手显示", () => {
+    cy.visit("/");
+    cy.get(".header-container .assistant-text").click();
+    cy.get(".assistant-table").should("contain", "全卷");
+  });
+});

+ 0 - 16
cypress/e2e/spec.cy.ts

@@ -1,16 +0,0 @@
-// describe("empty spec", () => {
-//   it("passes", () => {
-//     cy.visit("https://example.cypress.io");
-//   });
-// });
-
-describe("My First Test", () => {
-  it("Does not do much!", () => {
-    expect(true).to.equal(true);
-  });
-});
-describe("The Home Page", () => {
-  it("successfully loads", () => {
-    cy.visit("/"); // change URL to match your dev URL
-  });
-});

+ 1 - 11
src/features/mark/MarkHeader.vue

@@ -189,16 +189,6 @@
       trigger="hover"
       class="tw-cursor-pointer"
     >
-      <template #title>
-        <span
-          style="
-            color: var(--app-main-text-color);
-            font-size: var(--app-title-font-size);
-          "
-        >
-          小助手
-        </span>
-      </template>
       <template #content>
         <table class="assistant-table">
           <tr v-if="store.setting.subject.paperUrl">
@@ -281,7 +271,7 @@
           </tr>
         </table>
       </template>
-      <div class="tw-flex tw-items-center">
+      <div class="tw-flex tw-items-center assistant-text">
         <img
           src="./images/assistant.png"
           style="width: 10px; height: 12px; margin-right: 2px"