I’d love to do some tests in AnkiDroid for the deckoption.
My issue is that, none of the fields or toggles, have id attributes. I can easily select the first field with number or the first toggle, but if the deck options page ever change, that’ll break the tests.
So I was trying to see how such tests were done in anki and could not find any.
Am I missing something?
Would it be acceptable to add id attributes to the various fields, so that it can be non-ambiguously acceded and their value changed in our integration tests?
Or is there another way to test the webpage interaction with the app that I’m missing?
If a handful of ids will make life easier for AnkiDroid, you’re welcome to add them - just please pick ids that are not likely to conflict with other usages.
Before writing component tests, think about whether you actually need to test the component, or if it’s more about the logic inside the component. If so, consider extracting out that logic to test it in isolation, without the overhead of a component
In the deck options case, the logic is in lib.ts, and we have some unit tests for that logic. I tend to prefer testing at that level - integration tests tend to be slower to write and to run, and tend to require more work when making changes to the UI. That’s not to say there’s never a place for them, but just that I think they should be used sparingly.
While I’d prefer unit test to integration test, we currently have the problem in ankidroid that the test framework does not execute javascript.
So if I want to test the actual feature I worked on, that is, whether the back button of android close the deck options if there are no changes, and otherwise request confirmation, then I think I need end to end.
Or I’d need mocking the svelte library, which honestly is an idea that I hate ,as it would not let us detect that a change in the backend breaks our app
Sorry, my comments were intended to be an explanation for why you didn’t find such tests in the Anki codebase - they weren’t intended to argue against the test you want to do for AnkiDroid.