Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate cy.log() in Command Log to 50 lines instead of 1 #5630

Merged
merged 3 commits into from
Jan 9, 2020

Conversation

pitgrap
Copy link
Contributor

@pitgrap pitgrap commented Nov 7, 2019

User facing changelog

Messages from cy.log() are now truncated at 50 lines the Command Log instead of the 1 line.

How has the user experience changed?

Before:
screenshot_174

After:

Truncates the log to 50 lines and shows ellipsis to indicate truncation.

Clicking to log to console will log full cy.log() content.

Screen Shot 2020-01-09 at 12 40 53 PM

PR Tasks

none.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 7, 2019

Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.

  • Please write [WIP] in the title of your Pull Request if your PR is not ready for review - someone will review your PR as soon as the [WIP] is removed.
  • Please familiarize yourself with the PR Review Checklist and feel free to make updates on your PR based on these guidelines.

PR Review Checklist

If any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'.

User Experience

  • The feature/bugfix is self-documenting from within the product.
  • The change provides the end user with a way to fix their problem (no dead ends).

Functionality

  • The code works and performs its intended function with the correct logic.
  • Performance has been factored in (for example, the code cleans up after itself to not cause memory leaks).
  • The code guards against edge cases and invalid input and has tests to cover it.

Maintainability

  • The code is readable (too many nested 'if's are a bad sign).
  • Names used for variables, methods, etc, clearly describe their function.
  • The code is easy to understood and there are relevant comments explaining.
  • New algorithms are documented in the code with link(s) to external docs (flowcharts, w3c, chrome, firefox).
  • There are comments containing link(s) to the addressed issue (in tests and code).

Quality

  • The change does not reimplement code.
  • There's not a module from the ecosystem that should be used instead.
  • There is no redundant or duplicate code.
  • There are no irrelevant comments left in the code.
  • Tests are testing the code’s intended functionality in the best way possible.

Internal

  • The original issue has been tagged with a release in ZenHub.

@CLAassistant
Copy link

CLAassistant commented Nov 7, 2019

CLA assistant check
All committers have signed the CLA.

@brian-mann
Copy link
Member

@jennifer-shehane shouldn't there be some kind of upper maximum here? Seems slightly irresponsible to display all of the log message regardless of how long it is.

With this PR, if you shrink the reporter, the text will wrap really far and make the command log pretty unusable at smaller sizes. Could we truncate the log message to a more reasonable point so we avoid that problem?

@pitgrap
Copy link
Contributor Author

pitgrap commented Nov 8, 2019

@brian-mann As a cypress test code writer, I would like to have control of the log messages of my own tests. This change does not affect any other message types. Just my own written cy.log(). I don't know why cypress should restrict me as developer? Also the Command Log has a minimum width of 170px.
But if I still couldn't convince you, a simple max-height: 300px; should do it, because the default overflow/text-overflow rules would apply.

@jennifer-shehane
Copy link
Member

@pitgrap The restriction would be a very large one, like 2,000 characters. The purpose of restriction would be to prevent the reporter from printing a gigantic log, like if someone accidentally printed a large Object, that may lock up the browser during rendering. Something more than this amount of characters wouldn't even be visible in a single frame of the test runner for review. Users can open a new issue if they need this to be larger and handled in some other way.

I'll update the PR for this.

@pitgrap
Copy link
Contributor Author

pitgrap commented Nov 20, 2019

Do you have any updates? Can I do anything to get this PR merged?

@gabbersepp
Copy link
Contributor

Hello, can this PR be merged? Please have a look at this screenshot, taken from one of our testruns:
image

I have no chance to check if the lcoator and the element in the UI are correct. My assumption is, that the element was replaced dynamically but as I can not see the full locator of the get I have no chance to confirm this.

@jennifer-shehane
Copy link
Member

There were changes requested for this PR that were never implemented. Implement the changes and we can move forward.

Likely relevant to this work #5762

@gabbersepp
Copy link
Contributor

@jennifer-shehane Thanks for pointing that out.
@pitgrap Can you have a look again? Would be nice!

@pitgrap
Copy link
Contributor Author

pitgrap commented Dec 20, 2019

Rebased on develop branch, added the feedback and updated the screenshots.
Used a simple CSS solution for the upper limit based on https://caniuse.com/#feat=css-line-clamp

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see the line-clamp style have any effect. As can be seen in the image below, the log is printing 50+ lines, not truncating at line 50.

If you are going to truncate, we also need some ellipsis to indicate that the log was truncated otherwise the users will have no way of knowing whether it is the end of the log or truncated.

Screen Shot 2020-01-08 at 4 53 55 PM

@pitgrap
Copy link
Contributor Author

pitgrap commented Jan 8, 2020

If you are going to truncate, we also need some ellipsis to indicate that the log was truncated otherwise the users will have no way of knowing whether it is the end of the log or truncated.

I agree, and that's what should happen. See my screenshot in the description.

I do not see the line-clamp style have any effect. As can be seen in the image below, the log is printing 50+ lines, not truncating at line 50.

That's weird. I will retest it.

- add line-height: 1.5
- set upper limit of 50 lines (~ 2000), works in all browsers except IE11
@pitgrap
Copy link
Contributor Author

pitgrap commented Jan 8, 2020

Ok, sorry. My new styles has been overwritten by another CSS rule with a "display: block". Now it should be finally fixed and working.

@jennifer-shehane jennifer-shehane dismissed chrisbreiding’s stale review January 9, 2020 06:14

Changes were made to address Chris original comment

@jennifer-shehane jennifer-shehane changed the title Do not truncate cy.log() in Command Log Truncate cy.log() in Command Log to 50 lines instead of 1 Jan 9, 2020
@jennifer-shehane jennifer-shehane merged commit ab7cc5f into cypress-io:develop Jan 9, 2020
@pitgrap pitgrap deleted the issue-5625 branch January 9, 2020 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not truncate cy.log() in Command Log
6 participants