Rewrite old E2E tests to use fixture-based API mocking, eliminating need for real credentials
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,22 +10,9 @@
|
||||
// -- This is a parent command --
|
||||
import '@4tw/cypress-drag-drop'
|
||||
|
||||
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,
|
||||
grant_type: 'password',
|
||||
}
|
||||
}).then(response => {
|
||||
const token = response.body.access_token;
|
||||
cy.setCookie('luciaToken', token);
|
||||
})
|
||||
cy.setCookie('luciaToken', 'fake-access-token-for-testing');
|
||||
cy.setCookie('isLuciaLoggedIn', 'true');
|
||||
});
|
||||
// 呼叫方式: cy.login()
|
||||
// -- This is a child command --
|
||||
|
||||
@@ -130,6 +130,11 @@ export function setupApiIntercepts() {
|
||||
fixture: 'api/filter-params.json',
|
||||
}).as('getFilterCheckParams');
|
||||
|
||||
// Compare dashboard
|
||||
cy.intercept('GET', /\/api\/compare\?datasets=/, {
|
||||
fixture: 'api/compare.json',
|
||||
}).as('getCompare');
|
||||
|
||||
// Dependents (for delete confirmation)
|
||||
cy.intercept('GET', '/api/logs/*/dependents', {
|
||||
statusCode: 200,
|
||||
|
||||
Reference in New Issue
Block a user