cypress-saveLogAndFilter: post logine api done.
This commit is contained in:
@@ -6,3 +6,18 @@ module.exports = defineConfig({
|
|||||||
specPattern: "cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}",
|
specPattern: "cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// {
|
||||||
|
// "video": false,
|
||||||
|
// "env": {
|
||||||
|
// "DISPLAY": ":99"
|
||||||
|
// },
|
||||||
|
// "chromeWebSecurity": false,
|
||||||
|
// "viewportHeight": 1080,
|
||||||
|
// "viewportWidth": 1920,
|
||||||
|
// "numTestsKeptInMemory": 10,
|
||||||
|
// "browser": "chrome",
|
||||||
|
// "headless": true,
|
||||||
|
// "includeShadowDom": true,
|
||||||
|
// "watchForFileChanges": true
|
||||||
|
// }
|
||||||
|
|||||||
@@ -4,5 +4,9 @@
|
|||||||
"lib": ["es5", "dom"],
|
"lib": ["es5", "dom"],
|
||||||
"types": ["cypress"]
|
"types": ["cypress"]
|
||||||
},
|
},
|
||||||
"include": ["./**/*", "../support/**/*"]
|
"include": [
|
||||||
|
"./**/*",
|
||||||
|
"../support/**/*",
|
||||||
|
"/node_modules/cypress",
|
||||||
|
"cypress/**/*.js"]
|
||||||
}
|
}
|
||||||
|
|||||||
65
cypress/e2e/saveLogAndFilter.cy.js
Normal file
65
cypress/e2e/saveLogAndFilter.cy.js
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
|
||||||
|
// 每一 describe 就是一個測試套件
|
||||||
|
describe('Save Log and Filter', ()=>{
|
||||||
|
// 每一 it 就是一個測試命令
|
||||||
|
// it('test', () => {
|
||||||
|
|
||||||
|
// cy.visit('http://');
|
||||||
|
// cy.get('#id').click();
|
||||||
|
// cy.title().shoule('include', 'DISCOVER') // 檢查標題看是否有點擊成功
|
||||||
|
// cy.url().should('include', 'discover/logs') // url 需要一個斷言
|
||||||
|
// });
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://REDACTED-HOST/files');
|
||||||
|
cy.login();
|
||||||
|
cy.visit('https://REDACTED-HOST/files');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('log', () => {
|
||||||
|
cy.visit('https://REDACTED-HOST/files');
|
||||||
|
console.log(cy.title());
|
||||||
|
console.log(cy.url());
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// cy.visit('https://REDACTED-HOST/files');
|
||||||
|
// cy.get('.min-w-\[216px\]:nth-child(1) > div > .text-neutral-500').click();
|
||||||
|
// cy.get('.text-primary').click();
|
||||||
|
// cy.get('.p-focus').click();
|
||||||
|
// cy.get('.float-right > .btn:nth-child(2)').click();
|
||||||
|
// cy.get('.text-neutral-900').click();
|
||||||
|
// cy.get('.float-right > .btn:nth-child(2)').click();
|
||||||
|
// cy.get('.leading-loose').click();
|
||||||
|
// cy.get('.swal2-container').click();
|
||||||
|
// cy.get('.leading-loose').click();
|
||||||
|
// cy.get('.swal2-cancel').click();
|
||||||
|
// cy.get('.min-w-\[216px\]:nth-child(1) > div').click();
|
||||||
|
// cy.get('.text-primary').click();
|
||||||
|
// cy.get('.text-neutral-900').click();
|
||||||
|
// cy.get('.text-neutral-900').click();
|
||||||
|
// cy.get('.p-focus').click();
|
||||||
|
// cy.get('.float-right > .btn:nth-child(2)').click();
|
||||||
|
// cy.get('.text-neutral-900').click();
|
||||||
|
// cy.get('.float-right > .btn:nth-child(2)').click();
|
||||||
|
// cy.get('.leading-loose').click();
|
||||||
|
// cy.get('.swal2-confirm').click();
|
||||||
|
// cy.get('.swal2-input').type('aaa');
|
||||||
|
// cy.get('.swal2-confirm').click();
|
||||||
|
// cy.get('.swal2-container').click();
|
||||||
|
|
||||||
|
// 進入 fils 頁
|
||||||
|
// 點擊 log / 點擊 filter
|
||||||
|
// 斷言: 編寫程式碼時,我們總是會做出一些假設,斷言就是用於在程式碼中捕捉這些假設。使用時機在該表達式值為真時使用。
|
||||||
|
// 沒有操作
|
||||||
|
// 有操作沒存檔
|
||||||
|
// 有操作有存檔
|
||||||
|
// 有操作重複存檔
|
||||||
|
// 有重複操作 沒有存檔
|
||||||
|
// Funnle 規則檢查
|
||||||
|
|
||||||
|
// dbclick() 雙擊
|
||||||
|
// 多選 單選
|
||||||
|
// npx cypress run --spec "cypress/e2e/saveLogAndFilter.cy.js"
|
||||||
|
// 分 無頭模式/瀏覽器介面模式,無頭模式更快,因為不用渲染瀏覽器介面
|
||||||
|
// 上傳文件
|
||||||
|
// $npm install --save cypress-file-upload
|
||||||
@@ -10,7 +10,24 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
// -- This is a parent command --
|
// -- This is a parent command --
|
||||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
const loginApiUrl = Cypress.env('loginApiUrl');
|
||||||
|
Cypress.Commands.add('login', () => {
|
||||||
|
cy.request({
|
||||||
|
method: 'POST',
|
||||||
|
url: loginApiUrl,
|
||||||
|
form: true,
|
||||||
|
body: {
|
||||||
|
username: Cypress.env('user').username,
|
||||||
|
password: Cypress.env('user').password
|
||||||
|
}
|
||||||
|
}).then(response => {
|
||||||
|
console.log(response);
|
||||||
|
cy.log(response)
|
||||||
|
const token = response.body.access_token;
|
||||||
|
cy.setCookie('luciaToken', token);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
// 呼叫方式: cy.login()
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// -- This is a child command --
|
// -- This is a child command --
|
||||||
|
|||||||
Reference in New Issue
Block a user