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

test advanced checkpoints #230

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

test advanced checkpoints #230

wants to merge 2 commits into from

Conversation

trieloff
Copy link
Contributor

@trieloff trieloff commented Jul 4, 2024

  • test(index): test block visibility, resource loading
  • test(index): add test for form submissions

Copy link

codecov bot commented Jul 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.17%. Comparing base (2b28ca8) to head (03c9e94).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #230      +/-   ##
==========================================
+ Coverage   93.37%   94.17%   +0.80%     
==========================================
  Files           5        5              
  Lines         498      498              
==========================================
+ Hits          465      469       +4     
+ Misses         33       29       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@trieloff trieloff requested a review from kptdobe July 5, 2024 10:34

await sendMouse({ type: 'click', position: [10, 10] });

assert(window.called.some((call) => call.checkpoint === 'viewmedia'), 'viewmedia checkpoint missing');
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bad practice: the tests share the same execution context, i.e. they can interfere between each others. This one can for example trigger a missingresource you do not check here. If implementation for next test is broken (i.e. fetch does not fire a missingresouce, test will be successful but implementation is wrong.

Several todos:

  • before / after each test, clean up the called stack
  • in each test, test for exact equality - if order is random, at least test for window.called.length === 4

If this is not doable in one file, split into multiple files

setTimeout(resolve, 100);
});

assert(window.called.some((call) => call.checkpoint === 'missingresource'), 'missingresource checkpoint missing');
Copy link
Contributor

Choose a reason for hiding this comment

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

You are testing missingresource in a loadblock test file. Either rename the file or move to dedicated test file.

await new Promise((resolve) => {
setTimeout(resolve, 2000);
});
assert(window.called.some((call) => call.checkpoint === 'formsubmit'), 'formsubmit checkpoint missing');
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, testing formsubmit in loadblockfile...

@@ -0,0 +1,4 @@
<div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Move file into a fixtures subfolder to separate test files and resources (same for image)

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.

None yet

2 participants