Move CSS to CSS files and add new tests for stylesheets#1082
Move CSS to CSS files and add new tests for stylesheets#1082
Conversation
|
This looks like a good idea. But we must start working on proper screenshot based testing of the application to make sure that they widgets look proper in the real application. |
Absolutely! The tests in this PR aim to cover all our GUI component fonts and styles, but we still need tests to cover issues like text getting cut off when the window is its min size, or certain strings no longer wrapping because of a change in Qt or something. So far this PR focuses on getting full test coverage around fonts, colors, and widget sizes. Testing borders, margins, padding, and a few other styles might be easier to test with screenshots actually since it's not super obvious to me how to get these properties from the widget in Qt. |
4ef2c7f to
bc24eea
Compare
1b2b5a5 to
e0ec19f
Compare
|
For the 5/20-6/3 sprint, our goal is to get this PR to "Ready for review" (out of draft): tests pass, up-to-date with master, and the test plan is complete and enumerates manual regression test procedures for any missing coverage. |
|
adding a test for every UI element takes a long time which is why we decided to just add a manual test to this pr's test plan to fill in the gap (we still get a lot of new coverage here) and to continue to add automated UI tests in separate PRs. |
356932b to
6ba2f65
Compare
| file_widget.eventFilter(download_button, QEvent(QEvent.HoverEnter)) | ||
| expected_image = load_icon('download_file_hover.svg').pixmap(20, 20).toImage() | ||
| assert download_button.icon().pixmap(20, 20).toImage() == expected_image | ||
| # assert '#05a6fe' == download_button.palette().color(QPalette.Foreground).name() |
There was a problem hiding this comment.
HoverEnter is the right event for to test the setting of the icon since that logic is explicit here, but it's not obvious to me where the application of the hover selector is happening since it's not done in the eventFilter, so I'm not sure how to test this properly (i.e. is HoverEnter the right event?).
One thought prior to spending more time on this: it seems like the easiest way to test more dynamic behavior would be to actually move the cursor to hover over the download_button (similar to this but using pyautogui.moveTo) and then assert the color on the widget (and ultimately take screenshots). This doesn't necessarily need to be part of this change, but what do you think @creviera @kushaldas ?
There was a problem hiding this comment.
I think it makes sense to test longer sequences of client behavior using pyautogui or some other similar tool. Here we just want to check the that a button's hover event or pressed event updates the button's palette color correctly. I'm surprised there isn't an easy way to do this without actually moving the mouse cursor. Just for a little background, here are two things I tried for the login button:
-
Creating a mouse event and triggering it.
event = QMouseEvent(QEvent.MouseButtonPress, login_button.pos(), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) login_button.mousePressEvent(event)
Or triggering it this way:
event = QMouseEvent(QEvent.MouseButtonPress, login_button.pos(), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) QCoreApplication.postEvent(main_window, event)
-
Using Qt's QTest unit testing framework which offers functionality for mouse and keyboard simulation.
QTest.mousePress(login_button, Qt.LeftButton)
Or, for the download button scenario a mouse hover event:
QTest.mouseMove(download_button)
But these simulations don't cause the buttons to update their palette color, even though it clearly works when we run the client. I'm starting to wonder if there is another color property somewhere... At this point I think it would be good to get @kushaldas's eyes on this PR and to move forward without full coverage. I'll create a couple followup issues for addressing the remaining work.
|
In order to move this PR along I created the following followup issues: |
kushaldas
left a comment
There was a problem hiding this comment.
Main window looked good. But, there is issue with the export dialog. I used the attached patch to verify against the master branch. First, I took only the screenshots (using the commented lines), and then tried to match.
First this what we see in the master branch.
The following is what I am getting in this branch.
|
I'm unable to repro but will keep trying. Does this consistently happen for you? I'm curious if it's intermittent and if it could happen on |
|
I'm also unable to repro. I've tested both branches ( Here's what it looks like to me in Qubes: On |
|
The screenshots show what may be a regression, though, note that the journalist designation in the "Compose a reply to" placeholder is cut off in the |
The patch is not for the code, that patch is for automated screenshot based tests. I wanted to make sure that the UI looks the same in both branches while inside of the tests. |
I see this too and will fix. @kushaldas - are you taking the screenshots via |
6ba2f65 to
4b7531d
Compare
|
Notes about where we could use coverage via screenshot tests here: #1004 (comment) |
|
I took the current branch through its paces in Qubes, validating standard client functionality such as login, errors, export, and deletion, and comparing screenshots against the behavior in Above: (I almost need to use a color picker to even notice the difference.) |
|
thank you for the great review! moving this back into development and will have to address the issues found next week. |
|
@creviera I just now pushed the code to generate screenshots for the export dialog at https://github.com/freedomofpress/securedrop-client/tree/selfie_for_1082 You will have to install The above command will generate 4 screenshots. |
|
OK I just finished testing this a bunch in Qubes, comparing with the latest client deb (0.2.0). I cannot reproduce your report @kushaldas - I tested the USB export in Qubes and I do not see any style regressions: all works as expected. I also don't really see any difference in the message bubbles - color bar is the same expected color and fonts weights seem to be the same in messages vs replies. However I did notice that on Otherwise, I would be in favor at this point of merging this given its size and then we can improve the tests in the followup issues @creviera created. |
That explanation makes sense to me, looking closely at |
d35e145 to
db43939
Compare
redshiftzero
left a comment
There was a problem hiding this comment.
checking the reply behavior by logging in, sending a reply, logging back out, and logging back in. All works as advertised. Thanks!
@kushaldas if you agree this is ready, feel free to dismiss your review or re-review (whichever you prefer) - also want to post a link to your screenshot branch in #1004? we can continue that discussion there
| # Awaiting key | ||
| awaiting_key = QLabel('Awaiting encryption key') | ||
| awaiting_key.setObjectName('ReplyTextEditPlaceholder_bold_blue') | ||
| from_server = QLabel(_(' from server to enable replies')) |
There was a problem hiding this comment.
These strings are hardcoded, so OK to use QLabel here
| font-family: 'Montserrat'; | ||
| font-weight: 600; | ||
| font-size: 18px; | ||
| color: #2a319d; |
There was a problem hiding this comment.
✅ this is much nicer than having the style inline
kushaldas
left a comment
There was a problem hiding this comment.
I did one more round of testing locally, looks good. Approving.





Description
Towards #1078
Goals behind this PR:
.cssfiles instead of strings or dictionaries of strings or dictionaries of dictionaries of stringsTest Plan
There are many integration tests that you'll see check to see that the widget styles are what we expect them to be. We are almost at 100% UI style coverage now. Since it's difficult to keep track of where we have coverage for stylesheets, I left comments in the test code for assertions that will get us to 100% coverage. The comments all relate to the following types of tests:
menu-indicatortestsimage: none;andshow-decoration-selected: 0;testsThere are also comments in the test code for unexpected test failures, e.g. a background color of a disabled button should return gray but instead returns white. There aren't that many of these and it could be because of test writing fatigue that these are broken, however, in order to make sure the client looks like what we expect it to look like, the test plan is to compare master to this pr branch by following this plan:
masterand take screenshotsChecklist
If these changes modify code paths involving cryptography, the opening of files in VMs or network (via the RPC service) traffic, Qubes testing in the staging environment is required. For fine tuning of the graphical user interface, testing in any environment in Qubes is required. Please check as applicable:
If these changes add or remove files other than client code, the AppArmor profile may need to be updated. Please check as applicable:
If these changes modify the database schema, you should include a database migration. Please check as applicable:
masterand confirmed that the migration applies cleanlymasterand would like the reviewer to do so