Discover: SidebarFilter Timeframes fix startDate & endDate.

This commit is contained in:
chiayin
2023-06-07 12:19:03 +08:00
parent 9a403cce71
commit 8912ce6e8b
5 changed files with 86 additions and 7 deletions

View File

@@ -0,0 +1,78 @@
// 每一 describe 就是一個測試套件
// 每一 it 就是一個測試命令
describe('Save Log and Filter', ()=>{
beforeEach(() => {
cy.visit('https://REDACTED-HOST/files');
cy.login();
cy.visit('https://REDACTED-HOST/files');
// enter log
cy.url().should('include', 'files');
cy.contains('.fileName', 'random').dblclick(); // 選取 'random' log 檔
cy.contains('h2', 'DISCOVER'); // 斷言在 Discover 頁
cy.url().should('include', 'discover/logs'); // 斷言在 discover/logs/:id 路徑
cy.wait(3000)
cy.get('#iconFilter').click(); // 選取 Filter sidebar
});
it('Sequence, Have activity(s).', () => {
// select radio
cy.get('input#Sequence0').should('be.checked'); // 選取 Radio 'Sequence'
cy.contains('label', 'Have activity(s)') // 選取 Radio 'Have activity(s)'
.prev(2)
.find('input')
.should('have.attr', 'type', 'radio') // select the previous element
.should('be.checked'); // confirm it's type radio (optional)
// No selected.
cy.contains('button', 'Apply').click();
cy.get('.v-toast__text').should('contain', 'Not selected');
// Clear selected item.
cy.get('.allCheckboxAct') // 選取 all select
.find('input')
.should('not.be.visible').check({ force: true}).should('be.checked'); // 打開隱藏項目並選取
cy.contains('button', 'Clear').click();
cy.get('.allCheckboxAct') // 選取 all select
.find('input')
.should('not.be.visible')
.should('not.be.checked')
})
// it('save log', () => {
// // select radio
// cy.get('input#Sequence0').should('be.checked'); // 選取 Radio 'Sequence'
// cy.contains('label', 'Have activity(s)') // 選取 Radio 'Have activity(s)'
// .prev(2)
// .find('input')
// .should('have.attr', 'type', 'radio') // select the previous element
// .should('be.checked'); // confirm it's type radio (optional)
// select table item
// cy.get('.allCheckboxAct') // 選取 all select
// .find('input')
// .should('not.be.visible').check({ force: true}).should('be.checked'); // 打開隱藏項目並選取
// // click Alpay and click Alppy All
// cy.contains('button', 'Apply').click();
// cy.get('#tabFunnel').click();
// cy.contains('.p-timeline', 'Sequence');
// cy.contains('button', 'Apply All').click();
// // Save log
// cy.contains('button', 'Save').click();
// cy.contains('.swal2-title', 'SAVE NEW FILTER');
// cy.contains('button', 'OK').click();
// cy.contains('#swal2-validation-message', 'You need to write something!'); // 不輸入要跳驗證
// cy.get('.swal2-input').clear().type('random-E2Etesting');
// cy.contains('button', 'OK').click();
// cy.contains('#swal2-html-container', 'random-E2Etesting');
// // 回到 Files 檢查是否有新增 Filter 'random-E2Etesting'.
// cy.visit('https://REDACTED-HOST/files');
// cy.url().should('include', 'files');
// cy.contains('.fileName', 'random-E2Etesting');
// });
});

View File

@@ -1,44 +0,0 @@
// 之後要優化: 每一個測試步驟要分開寫,不寫在同一個 it 裡面、將測試寫成 report 輸出成 html(嘗試)、功能模組化
const baseUrl = Cypress.env('baseUrl');
describe("Login to Logout", () => {
before(() => {
cy.visit(baseUrl); // 測試可否進入網站
cy.contains("h2", "LOGIN"); // 是否轉址到 /login 並顯示畫面
cy.url().should('include', 'login') // url path 要有 'Login',確定進入 login page
})
it("test login success and error", () => {
// 驗證帳密是否刪除前後空白、錯誤帳密是否顯示驗證、Button display
cy.fixture('users/id-not-exists').then(({username, password}) => {
cy.get('.btn-lg').should('be.disabled');
cy.get('#account').should('have.focus').type(username);
cy.get('.btn-lg').should('be.disabled');
cy.get('#password').type(password);
cy.get('.btn-lg').click();
cy.get('#account').should('have.value', 'test');
cy.get('#password').should('have.value', 'test');
cy.get('form').submit();
cy.contains("p", "Incorrect account or password.");
cy.url().should('include', 'login');
});
// 正確帳密登入
cy.get('#account').clear().type(` ${Cypress.env('user').username} `);
cy.get('#password').clear().type(` ${Cypress.env('user').password} `);
cy.get('.btn-lg').click();
cy.get('#account').should('have.value', Cypress.env('user').username);
cy.get('#password').should('have.value', Cypress.env('user').password);
cy.get('form').submit(); // 選取 form 表單並發送
// 轉址到 files 頁
cy.url().should('include', 'files');
cy.get('a #iconMember').scrollIntoView().click();
// 轉址到會員頁
cy.url().should('include', 'member-area');
// 登出
cy.get('.btn-sm').contains('log out').click();
});
});

View File

@@ -1,125 +0,0 @@
// 每一 describe 就是一個測試套件
// 每一 it 就是一個測試命令
describe('Save Log and Filter', ()=>{
beforeEach(() => {
cy.visit('https://REDACTED-HOST/files');
cy.login();
cy.visit('https://REDACTED-HOST/files');
});
it('save log', () => {
// enter log
cy.url().should('include', 'files');
cy.contains('.fileName', 'random').dblclick(); // 選取 'random' log 檔
cy.contains('h2', 'DISCOVER'); // 斷言在 Discover 頁
cy.url().should('include', 'discover/logs'); // 斷言在 discover/logs/:id 路徑
cy.wait(3000)
// select radio
cy.get('#iconFilter').click(); // 選取 Filter sidebar
cy.get('input#Sequence0').should('be.checked'); // 選取 Radio 'Sequence'
cy.contains('label', 'Have activity(s)') // 選取 Radio 'Have activity(s)'
.prev(2)
.find('input')
.should('have.attr', 'type', 'radio') // select the previous element
.should('be.checked'); // confirm it's type radio (optional)
// select table item
cy.get('.allCheckboxAct') // 選取 all select
.find('input')
.should('not.be.visible').check({ force: true}).should('be.checked'); // 打開隱藏項目並選取
// click Alpay and click Alppy All
cy.contains('button', 'Apply').click();
cy.get('#tabFunnel').click();
cy.contains('.p-timeline', 'Sequence');
cy.contains('button', 'Apply All').click();
// Save log
cy.contains('button', 'Save').click();
cy.contains('.swal2-title', 'SAVE NEW FILTER');
cy.contains('button', 'OK').click();
cy.contains('#swal2-validation-message', 'You need to write something!'); // 不輸入要跳驗證
cy.get('.swal2-input').clear().type('random-E2Etesting');
cy.contains('button', 'OK').click();
cy.contains('#swal2-html-container', 'random-E2Etesting');
// 回到 Files 檢查是否有新增 Filter 'random-E2Etesting'.
cy.visit('https://REDACTED-HOST/files');
cy.url().should('include', 'files');
cy.contains('.fileName', 'random-E2Etesting');
});
it('save filter', () => {
// enter log
cy.url().should('include', 'files');
cy.contains('.fileName', 'random-E2Etesting').dblclick(); // 選取 'random' log 檔
cy.contains('h2', 'DISCOVER'); // 斷言在 Discover 頁
cy.url().should('include', 'discover/filters'); // 斷言在 discover/logs/:id 路徑
cy.wait(3000)
// Delete All
cy.get('#iconFilter').click(); // 選取 Filter sidebar
cy.get('#tabFunnel').click();
cy.contains('button', 'Delete All').click();
// select radio
cy.get('#tabFilter').click();
cy.get('input#Sequence0').should('be.checked'); // 選取 Radio 'Sequence'
cy.contains('label', 'Have activity(s)') // 選取 Radio 'Have activity(s)'
.prev(2)
.find('input')
.should('have.attr', 'type', 'radio') // select the previous element
.should('be.checked'); // confirm it's type radio (optional)
// select table item
cy.get('.allCheckboxAct') // 選取 all select
.find('input')
.should('not.be.visible').check({ force: true}).should('be.checked'); // 打開隱藏項目並選取
// click Alpay and click Alppy All
cy.contains('button', 'Apply').click();
cy.get('#tabFunnel').click();
cy.contains('.p-timeline', 'Sequence');
cy.contains('button', 'Apply All').click();
// save filter
cy.contains('button', 'Save').click();
cy.contains('#swal2-html-container', 'random-E2Etesting');
});
it('no save log', () => {
// enter log
cy.url().should('include', 'files');
cy.contains('.fileName', 'random').dblclick(); // 選取 'random' log 檔
cy.contains('h2', 'DISCOVER'); // 斷言在 Discover 頁
cy.url().should('include', 'discover/logs'); // 斷言在 discover/logs/:id 路徑
cy.wait(3000)
// select radio
cy.get('#iconFilter').click(); // 選取 Filter sidebar
cy.get('input#Sequence0').should('be.checked'); // 選取 Radio 'Sequence'
cy.contains('label', 'Have activity(s)') // 選取 Radio 'Have activity(s)'
.prev(2)
.find('input')
.should('have.attr', 'type', 'radio') // select the previous element
.should('be.checked'); // confirm it's type radio (optional)
// select table item
cy.get('.allCheckboxAct') // 選取 all select
.find('input')
.should('not.be.visible').check({ force: true}).should('be.checked'); // 打開隱藏項目並選取
// click Alpay and click Alppy All
cy.contains('button', 'Apply').click();
cy.get('#tabFunnel').click();
cy.contains('.p-timeline', 'Sequence');
cy.contains('button', 'Apply All').click();
cy.wait(3000)
cy.get('#backPage').click();
cy.contains('.swal2-title', 'LEAVE MAP');
cy.contains('button', 'OK').click();
cy.url().should('include', 'files');
})
});