Add unit tests for "staying on the same page when switching versions" functionality
This PR is the no-op part of #7350, mostly consisting of adding tests. Once this is merged, I'll rebase #7350 on top of the merge, and it will become a much smaller PR only affecting business logic.
This is meant to simplify checking correctness of code like https://github.com/squidfunk/mkdocs-material/pull/7227 and fixing bugs like https://github.com/squidfunk/mkdocs-material/issues/7226. In fact, I'm hoping to eventually make this code general enough that it runs locally with mike serve.
See the commit descriptions for more details.
Thanks! We'll check it out once we consider adding tests. Please understand that we're currently working on other, much bigger things in the background, so please be patient until we consider this ready for merging. Thank you!
I now updated this PR to follow your suggestions from https://github.com/squidfunk/mkdocs-material/pull/7350#issuecomment-2216909385 as best I can. I added a commit that switches Mocha -> Jasmine and moves the tests to a separate dir. I also marked it as ready for review.
Once/if this PR is merged, I'll update #7350 accordingly. At that point, it will become a much smaller PR with only business logic updates.
The suggested iframe-worker template uses Karma, but I didn't use it because 1) it's a complicated tool I don't understand and 2) it says it's deprecated and isn't even accepting bugfixes in https://github.com/karma-runner/karma . Instead, I followed https://www.innoq.com/en/blog/2020/04/ts-jasmine-karma/#executingtestsonnode.js to set up Jasmine with ts-node, since that's all I need for this application. If you need something like Karma or whatever replaced it, you can always rework this later.
As you might be able to tell, I'm no expert on TS testing frameworks; I simply use whatever I can get to work and makes minimal changes to the project structure (so that it can be replaced later, if needed).
OTOH, let me know if there's more I can do to make this easier for you to review/maintain. I'm trying to make the minimal changes to the project structure possible, so that it's easy to change anything about this setup later.
I noticed that you marked this as a draft. That's fine, but just to be clear, I wasn't planning to make any further changes here, except for maybe occasionally rebasing it on top of the current master from time to time, until I hear from you.
Alright, thanks!
Feel free to take a look (it's now synced with master), but I realized I can probably make this a bit easier to review by making it use Jasmine from the beginning (so this will be 2 commits instead of 3, ultimately amounting to the same thing). So, I'll fix it up (hopefully) shortly.
But let me know if this is not necessary and you can review this as is, it'd make things a bit easier for me.
Judging by https://github.com/squidfunk/mkdocs-material/pull/7350#issuecomment-2362039638, the updates I planned wouldn't make any difference to the fate of this PR. So, I'll leave it as is.
I still think it's a good idea, so I'll leave it open, but do with it as you will. After all, it's just a contribution made with the hope that it helps.
Material for MkDocs is now in maintenance mode. Please understand that we don't consider merging this PR anymore.