Skip to content

Commit a005532

Browse files
committed
fix(cypress): streamline logging in media library and login functions for improved clarity
1 parent 17b2a48 commit a005532

File tree

4 files changed

+4
-48
lines changed

4 files changed

+4
-48
lines changed

cypress/e2e/common/media_library.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@ import {
1414
import { workflowStatus } from '../../utils/constants';
1515

1616
function uploadMediaFile() {
17-
cy.task('log', '[media_library] uploadMediaFile: start');
1817
assertNoImagesInLibrary();
19-
cy.task('log', '[media_library] uploadMediaFile: library empty confirmed');
2018

2119
const fixture = 'cypress/fixtures/media/netlify.png';
2220
cy.get('input[type="file"]').selectFile(fixture, { force: true });
23-
cy.task('log', '[media_library] uploadMediaFile: file selected');
2421
cy.contains('span', 'Uploading...').should('not.exist');
25-
cy.task('log', '[media_library] uploadMediaFile: upload finished');
2622

2723
assertImagesInLibrary();
28-
cy.task('log', '[media_library] uploadMediaFile: image present');
2924
}
3025

3126
function assertImagesInLibrary() {
@@ -107,19 +102,14 @@ function assertGridEntryImage(entry) {
107102

108103
export default function({ entries, getUser }) {
109104
beforeEach(() => {
110-
cy.task('log', '[media_library beforeEach] start login');
111105
login(getUser && getUser());
112-
cy.task('log', '[media_library beforeEach] login completed');
113106
});
114107

115108
it('can upload image from global media library', () => {
116-
cy.task('log', '[TEST] can upload image from global media library: start');
117109
goToMediaLibrary();
118-
cy.task('log', '[TEST] can upload image from global media library: media library opened');
119110
uploadMediaFile();
120111
matchImageSnapshot();
121112
closeMediaLibrary();
122-
cy.task('log', '[TEST] can upload image from global media library: end');
123113
});
124114

125115
it('can delete image from global media library', () => {

cypress/e2e/common/spec_utils.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,13 @@ export function afterEach(taskResult, backend) {
6565
const {
6666
suite: {
6767
ctx: {
68-
currentTest: { state, _retries: retries, _currentRetry: currentRetry, err },
68+
currentTest: { state, _retries: retries, _currentRetry: currentRetry },
6969
},
7070
},
7171
} = Cypress.mocha.getRunner();
7272

73-
cy.task(
74-
'log',
75-
`[afterEach] backend=${backend} test="${testName}" state=${state} retry=${currentRetry}/${retries}`,
76-
);
77-
if (state === 'failed' && err?.message) {
78-
cy.task('log', `[afterEach] failure: ${err.message}`);
79-
}
80-
8173
if (state === 'failed' && retries === currentRetry) {
82-
// Avoid deadlock in headless CI: runner.stop can leave recorded parallel runs hanging.
83-
if (Cypress.config('isInteractive')) {
84-
Cypress.runner.stop();
85-
}
74+
Cypress.runner.stop();
8675
}
8776
}
8877
}

cypress/support/e2e.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,6 @@ import './commands';
3333

3434
afterEach(function () {
3535
if (this.currentTest.state === 'failed') {
36-
const titlePath = this.currentTest.titlePath ? this.currentTest.titlePath().join(' > ') : '';
37-
// In headless CI, stopping the runner can leave the Cypress process hanging.
38-
if (Cypress.config('isInteractive')) {
39-
Cypress.runner.stop();
40-
} else {
41-
// eslint-disable-next-line no-console
42-
console.error(`[afterEach] Test failed in CI: ${titlePath || this.currentTest.title}`);
43-
if (this.currentTest.err?.message) {
44-
// eslint-disable-next-line no-console
45-
console.error(`[afterEach] Failure: ${this.currentTest.err.message}`);
46-
}
47-
}
36+
Cypress.runner.stop();
4837
}
4938
});

cypress/utils/steps.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@ const {
99
} = require('./constants');
1010

1111
function login(user) {
12-
cy.task(
13-
'log',
14-
`[login] start user=${user ? 'yes' : 'no'} netlifySiteURL=${user?.netlifySiteURL ? 'yes' : 'no'}`,
15-
);
1612
cy.viewport(1200, 1200);
1713
if (user) {
18-
cy.task('log', '[login] about to visit /');
1914
cy.visit('/', {
2015
onBeforeLoad: () => {
2116
// https://github.com/cypress-io/cypress/issues/1208
@@ -25,26 +20,19 @@ function login(user) {
2520
window.localStorage.setItem('netlifySiteURL', user.netlifySiteURL);
2621
}
2722
},
28-
}).then(() => {
29-
cy.task('log', '[login] visit completed');
3023
});
3124
if (user.netlifySiteURL && user.email && user.password) {
32-
cy.task('log', '[login] filling login form');
3325
cy.get('input[name="email"]', { timeout: 10000 }).clear();
3426
cy.get('input[name="email"]').type(user.email);
3527
cy.get('input[name="password"]').clear();
3628
cy.get('input[name="password"]').type(user.password);
3729
cy.contains('button', 'Login').click();
38-
cy.task('log', '[login] login button clicked');
3930
}
4031
} else {
4132
cy.visit('/');
4233
cy.contains('button', 'Login').click();
4334
}
44-
cy.task('log', '[login] waiting for New Post link');
45-
cy.contains('a', 'New Post', { timeout: 60000 }).then(() => {
46-
cy.task('log', '[login] New Post link found');
47-
});
35+
cy.contains('a', 'New Post');
4836
}
4937

5038
function assertNotification(message) {

0 commit comments

Comments
 (0)