Skip to content

chore(tests): cleanup and toolbox drag tests#7350

Merged
rachel-fenichel merged 7 commits intoRaspberryPiFoundation:developfrom
rachel-fenichel:test_cleanup
Aug 3, 2023
Merged

chore(tests): cleanup and toolbox drag tests#7350
rachel-fenichel merged 7 commits intoRaspberryPiFoundation:developfrom
rachel-fenichel:test_cleanup

Conversation

@rachel-fenichel
Copy link
Copy Markdown
Collaborator

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Closes #7327
Closes #7347
Closes #7346

Proposed Changes

In order of commits:

  • Test cleanup: use helpers
  • Test cleanup: miscellaneous
  • Format
  • Add test to drag out every block from the toolbox, with associated helpers
  • Make toolbox drag tests work in RTL
  • Lint

Test Coverage

The toolbox drag tests open every category in the basic toolbox and test blocks toolbox, and drag out every (non-disabled) block.
These tests take a long time (>100 seconds for the test blocks ones) so I have set them to be skipped right now.
The verification step simply checks whether there is a single top block on the workspace after the drag. As written, these tests will tell us about some catastrophic failures but won't guarantee that everything about block initialization works. Having a human watch the tests, with PAUSE_TIME set to more than 50 ms, is the best way to actually verify that the blocks that are created look right.

In particular, there is a block in the test blocks that has an invalid image URL. Blockly drops an error into the console for that, but the tests don't notice it. Ideally the tests would also monitor the browser console and forward any issues there.

Additional Information

The helpers I added make some strong assumptions about the state of the workspace during the test. I documented the assumptions but did not try to make the helpers more general-purpose. We can generalize them if a specific need comes up.

@rachel-fenichel rachel-fenichel requested a review from a team as a code owner August 1, 2023 23:12
@github-actions github-actions Bot added the PR: chore General chores (dependencies, typos, etc) label Aug 1, 2023
Copy link
Copy Markdown
Contributor

@BeksOmega BeksOmega left a comment

Choose a reason for hiding this comment

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

This generally LGTM! There are still lots of things about these tests I'd like to clean up :P but I don't want to block this on those! Feel free to ignore any nitpicky things about formatting/naming.

I am pretty confused about why the tests are skipped though. Is it just while we're building out the tests? I don't think there's anything wrong with them taking a long time, especially since we're only running them nightly.

Comment thread tests/browser/test/basic_playground_test.js Outdated
Comment thread tests/browser/test/basic_playground_test.js Outdated
Comment thread tests/browser/test/field_edits_test.js Outdated
Comment thread tests/browser/test/test_setup.js Outdated
Comment thread tests/browser/test/toolbox_drag_test.js
Comment thread tests/browser/test/toolbox_drag_test.js Outdated
if (await isBlockDisabled(browser, i)) {
// Unicode escape to close flyout.
await browser.keys(['\uE00C']);
await browser.pause(PAUSE_TIME);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you use a continue here instead of wrapping the rest of the method in an else?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I like else more than continue :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think for long term code health it's better to keep conditional blocks short: https://testing.googleblog.com/2017/06/code-health-reduce-nesting-reduce.html

For smaller things I can see how else is clearer. But in this case (especially since it is already wrapped in a try...catch) I would really prefer to de-dent it.

Comment thread tests/browser/test/toolbox_drag_test.js Outdated
@rachel-fenichel
Copy link
Copy Markdown
Collaborator Author

I am pretty confused about why the tests are skipped though. Is it just while we're building out the tests? I don't think there's anything wrong with them taking a long time, especially since we're only running them nightly.

Yes, for while we're building out the tests. I think our teammates will quickly tire of running the tests locally if they always have to sit through how long these tests take. When we're not actively developing them + have sorted out some of the flakiness, I'll turn these on to run nightly.

@rachel-fenichel rachel-fenichel enabled auto-merge (squash) August 3, 2023 00:31
@rachel-fenichel rachel-fenichel merged commit 8241fca into RaspberryPiFoundation:develop Aug 3, 2023
@rachel-fenichel
Copy link
Copy Markdown
Collaborator Author

@BeksOmega please feel free to leave more comments here telling me what else you would like to see cleaned up, so I can get to them on my return.

@rachel-fenichel rachel-fenichel deleted the test_cleanup branch August 16, 2023 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: chore General chores (dependencies, typos, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Browser test helper: scroll flyout Browser test helper: isBlockVisible Browser test: open all categories and drag out all blocks

2 participants