Open JJ-8 opened 3 weeks ago
I think a good way to handle this problem is to get rid of the isValid
function completely.
Each parser should return an array of challenges and the number of challenge parsed should be visible in the select menu.
something like:
- ctfd 20 challs
- raw parser 1 chall
- ...
- ECSC invalid
We can also set the parser with the largest amount of challs by default on paste.
This way the user could select the most appropriate parser if the JSON input is valid for multiple formats.
When you paste some JSON in the importer, the
isValid
function is evaluated on the input to see if we can detect the parser for the pasted data. The amount of parsers is slowly growing and it is annoying to have collisions in detection of the parser. Furthermore, manual testing becomes quite tedious since we do not have all the test inputs somewhere documented.I think it is best to create a few unit tests to have an easy and documented way of testing the parsers and their
isValid
method. Here we can make sure that there won't be any collision in inferring the parser and that all parsers work correctly.Probably we can add Jest to the frontend and introduce some unit tests in there? Quasar also has support for Jest: https://testing.quasar.dev/packages/unit-jest/ Through a Github Action we can test these parsers by default on every PR.