PDF JS tests#257
Conversation
|
Thanks for the pull request, @Kelketek! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
3f30cc1 to
7ec98e1
Compare
|
@kdmccormick I could use your advice (and perhaps preliminary review) here. As requested, I've added JS tests for the PDF block. I noted the following:
The other blocks do work currently, right? How are they ensuring their files are built before serving them? Am I taking a totally backward approach? |
dad29e5 to
672ef99
Compare
|
@kdmccormick Nevermind-- decided not to have the bootstrapper built, nor use the 'public' folder, and instead only add tests rather than a build system for the general case, since it's not really necessary here anyway. |
|
@kdmccormick Oh, and-- ready for you :) |
samuelallan72
left a comment
There was a problem hiding this comment.
On a clean clone, the tests fail with:
node:fs:1350
const result = binding.mkdir(
^
Error: ENOENT: no such file or directory, mkdir '/home/samuel/proj/opencraft/xblocks-core/xblocks_contrib/video/public/js'
I don't think this is related to this PR though, since this is for the video xblock. These tests pass if I manually created that dir. Although it passes in CI, so I'm not sure what I missed here.
Please see other comments/questions inline. :)
| const tag = document.createElement('div') | ||
| tag.setAttribute('data-testid', 'jquery-loaded') | ||
| document.body.appendChild(tag) | ||
| clearInterval(id) |
There was a problem hiding this comment.
The scope of id is in the parent, so it's available to the child. const allows shadowing and global access if the name is defined higher. It prevents polluting outer scopes and redefinition, though.
Try this in your browser console:
const id = setInterval(() => console.log(id), 100)There was a problem hiding this comment.
@Kelketek that's so weird! I knew about the scopes, but it felt weird that it was fine accessing the variable that was defined here (after or at the same time as the function was defined). I see that this also works which feels even more wrong:
const id = setInterval(() => console.log(foo), 100)
const foo = "hello";
🤔 🤔
| "scripts": { | ||
| "setup": "playwright install", | ||
| "check": "tsc --noEmit", | ||
| "test": "npm run build && vitest run", |
There was a problem hiding this comment.
Does the build subcommand call need to be there? Currently it fails for me because there's no build subcommand. (not sure why it succeeds in CI)
There was a problem hiding this comment.
Nope, I forgot to replace it with check and only tested test-ci after I did it there.
| @@ -1,58 +0,0 @@ | |||
| {% load i18n %} | |||
There was a problem hiding this comment.
Does this then drop support for openedx < ulmo?
There was a problem hiding this comment.
< Verawood. The included PDF feature only arrived in Verawood, and had the MFE editing when Verawood was cut. It didn't have it when initially merged, which means no release has had the included PDF block with the backend-rendered editor. Only master has had it briefly.
It is possible to override use of the PDF block with one of the older versions, though, if you need to.
| return new Promise((resolve) => setTimeout(resolve, ms)); | ||
| } | ||
|
|
||
| const waitFor = async <T>(func: () => T, timeout: number = 1000) => { |
There was a problem hiding this comment.
vitest includes a waitFor function: https://vitest.dev/api/vi.html#vi-waitfor . Can we use that instead of implementing our own?
There was a problem hiding this comment.
Ah! I thought it was only available in testing-library, and I didn't want to add an entire library for one function.
| document.body.appendChild(block) | ||
| } | ||
|
|
||
| const loadJsPayload = async (path: string, id?: string) => { |
There was a problem hiding this comment.
Could you add a comment about why we need this kind of loading? I found it confusing.
|
@samuelallan72 This is ready for another look. Thanks! |
|
(please link to https://tasks.opencraft.com/browse/BB-10571 from the PR description :) )
|
Description
This merge request adds tests for the PDF Block initializer. It also removes the backend rendered studio view now that the authoring MFE directly supports PDF blocks.
Supporting information
Link to other information about the change, such as Jira issues, GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.
Testing instructions
OPENEDX_EXTRA_PIP_REQUIREMENTSwith atutor dev launchafterwardpdfto the advanced modules list for a coursenpm run setupand thennpm run test. Verify the output shows the PDF block tests (they're likely last)Other information
Closes #170
Merge checklist:
Check off if complete or not applicable: