From 7a98f549b6cf5f3dfb48320f0bc642b30307b186 Mon Sep 17 00:00:00 2001 From: chiayin Date: Wed, 6 Dec 2023 17:26:55 +0800 Subject: [PATCH] test: E2E-conformance rule Have activity. --- cypress/e2e/conformanceRule.cy.js | 56 +++++++++++++++++++ .../{e2e => fixtures}/conformanceSave.cy.js | 0 .../ConformanceSidebar/ResultCheck.vue | 4 +- 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 cypress/e2e/conformanceRule.cy.js rename cypress/{e2e => fixtures}/conformanceSave.cy.js (100%) diff --git a/cypress/e2e/conformanceRule.cy.js b/cypress/e2e/conformanceRule.cy.js new file mode 100644 index 0000000..f5cda09 --- /dev/null +++ b/cypress/e2e/conformanceRule.cy.js @@ -0,0 +1,56 @@ +// 每一 describe 就是一個測試套件 +// 每一 it 就是一個測試命令 +describe('Conformance Save', ()=>{ + beforeEach(() => { + cy.visit('https://REDACTED-HOST/files'); + cy.login(); + cy.visit('https://REDACTED-HOST/files'); + }); + + it('Have activity', () => { + // enter Map + cy.url().should('include', 'files'); + cy.get('table tr') + .filter(':contains("Log")') // 選擇 type Log + .filter(':contains("random")') // 選擇 random log 檔 + .dblclick(); // 對選中的 tr 執行雙擊 + cy.contains('h2', 'DISCOVER'); // 斷言在 Discover 頁 + cy.url().should('include', 'discover/map/log'); // 斷言在 discover/map/log/:id 路徑 + cy.wait(2000) + + // enter Conformance + cy.contains('li', 'CONFORMANCE').click(); // 點擊 Conformance 頁 + cy.wait(2000); + cy.url().should('include', '/discover/conformance/log'); // 斷言在 discover/conformance/log/:id 路徑 + cy.get('.active').should('have.text', 'CONFORMANCE'); + + // select radio + cy.get('#cyp-conformance-type-radio').find('input').first().click({ force: true }).should('be.checked'); + + // select list checkbox + cy.get('#cyp-conformance-list-checkbox').find('input').first().click({ force: true }).should('be.checked'); + + // click apply + cy.contains('button', 'Apply').click(); + cy.contains('.v-toast', 'Rule applied'); + + // 是否有顯示選擇項目 + cy.get('#cyp-conformance-result-check') + + // save conformance log + cy.contains('button', 'Save').click(); + cy.contains('.swal2-title', 'SAVE NEW RULE'); + cy.contains('button', 'OK').click(); + cy.contains('#swal2-validation-message', 'You need to write something!'); // 不輸入要跳驗證 + cy.get('.swal2-input').clear().type('random-conformance-rule-E2Etesting'); + cy.contains('button', 'OK').click(); + cy.contains('#swal2-html-container', 'random-conformance-rule-E2Etesting'); + + // 回到 Files 檢查是否有新增 Filter 'random-conformance-log-E2Etesting'. + cy.visit('https://REDACTED-HOST/files'); + cy.url().should('include', 'files'); + cy.contains('.fileName', 'random-conformance-rule-E2Etesting'); + }); + + +}); diff --git a/cypress/e2e/conformanceSave.cy.js b/cypress/fixtures/conformanceSave.cy.js similarity index 100% rename from cypress/e2e/conformanceSave.cy.js rename to cypress/fixtures/conformanceSave.cy.js diff --git a/src/components/Discover/Conformance/ConformanceSidebar/ResultCheck.vue b/src/components/Discover/Conformance/ConformanceSidebar/ResultCheck.vue index 7433b73..a852d46 100644 --- a/src/components/Discover/Conformance/ConformanceSidebar/ResultCheck.vue +++ b/src/components/Discover/Conformance/ConformanceSidebar/ResultCheck.vue @@ -1,7 +1,7 @@