Translate Cypress support comments and add command JSDoc

Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
2026-03-08 11:57:58 +08:00
parent ef9cf2de8c
commit 7c48faaa3d
2 changed files with 14 additions and 4 deletions

View File

@@ -16,15 +16,25 @@
// -- This is a parent command --
import '@4tw/cypress-drag-drop'
/**
* Sets authentication cookies to simulate a logged-in user.
*
* @returns {void}
*/
Cypress.Commands.add('login', () => {
cy.setCookie('luciaToken', 'fake-access-token-for-testing');
cy.setCookie('isLuciaLoggedIn', 'true');
});
// 呼叫方式: cy.login()
// Usage: cy.login()
// -- This is a child command --
// 點擊空白區關閉 Modalcy.closePopup()
// Click a blank area to close an opened modal: cy.closePopup()
/**
* Closes the active popup by clicking the top-left area of the page.
*
* @returns {void}
*/
Cypress.Commands.add('closePopup', () => {
// 點擊 body 以外的區域,使用 force: true 強制觸發點擊
// Trigger a forced click to close modal overlays consistently.
cy.get('body').click({ position: 'topLeft'});
cy.wait(1000);
})

View File

@@ -27,4 +27,4 @@ Cypress.on('uncaught:exception', (err, runnable) => {
// Alternatively you can use CommonJS syntax:
// require('./commands')
require('cypress-xpath') // 順利執行.trigger('mouseup')
require('cypress-xpath') // Enables xpath helpers used in pointer event checks.