This commit is contained in:
tidusjar 2025-08-23 22:30:05 +01:00
commit de9cdf2984
5 changed files with 1300 additions and 442 deletions

View file

@ -29,7 +29,7 @@ export default defineConfig({
// Add test environment flags
isCI: process.env.CI === 'true',
// Add API base URL
apiBaseUrl: 'http://localhost:5000/api/v1'
apiBaseUrl: 'http://localhost:3577/api/v1'
},
// Project configuration
@ -66,7 +66,7 @@ export default defineConfig({
},
// Base configuration
baseUrl: 'http://localhost:5000',
baseUrl: 'http://localhost:3577',
specPattern: [
'cypress/tests/**/*.spec.ts*',
'cypress/features/**/*.feature'

View file

@ -28,7 +28,7 @@ export abstract class BasePage {
* Scroll to element with smooth behavior
*/
scrollToElement(selector: string): Cypress.Chainable<any> {
return cy.get(selector).scrollIntoView({ behavior: 'smooth' });
return cy.get(selector).scrollIntoView();
}
/**
@ -74,6 +74,7 @@ export abstract class BasePage {
* Log page action for debugging
*/
logAction(action: string, details?: any): void {
cy.log(`[${this.constructor.name}] ${action}`, details);
// Use console.log instead of cy.log to avoid promise/cy command mixing
console.log(`[${this.constructor.name}] ${action}`, details);
}
}

View file

@ -43,11 +43,11 @@ Cypress.Commands.add('loginWithCreds', (username: string, password: string) => {
}).then((resp) => {
if (resp.status === 200) {
window.localStorage.setItem('id_token', resp.body.access_token);
cy.log(`Successfully logged in as ${username}`);
} else {
cy.log(`Login failed for ${username}: ${resp.status}`);
}
});
// Log outside of the promise chain
cy.log(`Login attempt for user: ${username}`);
});
// Enhanced default login
@ -75,10 +75,7 @@ Cypress.Commands.add('removeLogin', () => {
// Enhanced notification verification with better error handling
Cypress.Commands.add('verifyNotification', (text: string) => {
cy.contains(text, { timeout: 10000 })
.should('be.visible')
.then(() => {
cy.log(`Notification "${text}" verified successfully`);
});
.should('be.visible');
});
// Enhanced user creation with better error handling
@ -101,12 +98,14 @@ Cypress.Commands.add('createUser', (username: string, password: string, claims:
},
failOnStatusCode: false
}).then((resp) => {
if (resp.status === 200) {
cy.log(`User ${username} created successfully`);
} else {
cy.log(`Failed to create user ${username}: ${resp.status}`);
if (resp.status !== 200) {
// Use console.log instead of cy.log inside promise
console.log(`Failed to create user ${username}: ${resp.status}`);
}
});
// Log outside of the promise chain
cy.log(`Creating user: ${username}`);
});
// Enhanced unique ID generation
@ -146,7 +145,7 @@ Cypress.Commands.add('waitForApiResponse', (alias: string, timeout: number = 100
Cypress.Commands.add('clearTestData', () => {
cy.clearLocalStorage();
cy.clearCookies();
cy.clearSessionStorage();
cy.clearAllSessionStorage();
cy.log('All test data cleared');
});
@ -154,21 +153,12 @@ Cypress.Commands.add('clearTestData', () => {
Cypress.Commands.add('seedTestData', (fixture: string) => {
cy.fixture(fixture).then((data) => {
// Implementation depends on your seeding strategy
cy.log(`Seeding test data from ${fixture}`);
// Example: cy.request('POST', '/api/v1/test/seed', data);
});
});
// Override visit command to add better logging
Cypress.Commands.overwrite('visit', (originalFn, url, options) => {
cy.log(`Visiting: ${url}`);
return originalFn(url, options);
});
// Override click command to add better logging
Cypress.Commands.overwrite('click', (originalFn, subject, options) => {
cy.log(`Clicking element: ${subject.selector || 'unknown'}`);
return originalFn(subject, options);
// Log outside of the promise chain
cy.log(`Seeding test data from ${fixture}`);
});

View file

@ -67,7 +67,7 @@ describe("TV Details Buttons", () => {
});
it.only("Issues Enabled", () => {
it("Issues Enabled", () => {
cy.intercept("GET", "**/Settings/issuesenabled", 'true').as('issuesEnabled');
cy.visit("/details/tv/1399");

File diff suppressed because it is too large Load diff