-
Notifications
You must be signed in to change notification settings - Fork 27
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 Refactor #145
Comments
A potential benefit for moving the JSON to its own file - we could create a schema for the JSON structure and add that to our automated test suite for the project. |
In the telecon today we discussed also removing author information, and rely on GitHub/git for attribution. |
I'll take a look at this for the next call. Goal: estimate how long it will take me to finish this. |
So with separate JSON files, the HTML files would be essentially identical. An idea is to have a single HTML file to run test, and use a hash in the URL to load the right JSON file. We could generate an index with links to all the "tests". Something like
|
Do we have any security concerns around including executable JS in the JSON as described in the example? It would probably be best to avoid |
I think the JSON files can be trusted as much as the script file itself, but there should be validation on the |
It seems possible to avoid executable code in the JSON as well, e.g. by defining functions for all special cases needed and have the JSON data say which functions it needs. |
That's the route that I was thinking. Its easier to read and just seems cleaner. The hard part will be generating a callable list of functions, which are defined separately for each test plan. Not quite sure how to approach that in a maintainable way; but I'll explore it. |
I've merged the PR. The "single HTML file" idea wasn't implemented, and I started to look into doing that myself today. I think it might require changes to the prototype test runner as well? It might be more work than I thought at first. I suggest we drop the idea for now. |
In consuming the tests, I've realized we need to do a refactor of the test format of the test
.html
files. The purpose of the refactor is to more easily consume metadata from the tests. The refactor is ultimately pretty small, but it will effect three things in this repository. The changes that will have to be made:VerifyATBehavior
call, the script will look for a<script id ="test-data" type="application/json"></script>
and initiate the test from there.setupTestPage
code will have to be escaped to to include it in the JSON. Since these test files will most likely never be written by hand, I think that is reasonable. We will then have to inject it into the popup window with the APG example in a different way, maybe appending the popup html with ascript
tag with the stringified javascript inside of it.And example of the new format I am imaging for the test files is provided at the end of this issue. For comparison, see the original format for this test in: read-checked-checkbox.html.
The change moves all the test specific information from a javascript script tag (where all the test specific information is passed to the harness through an API call) to a json script tag. When designing these test, it seemed like we might want to support a lot more logic in the test file, but it turns out the only javascript you need is pretty minimal. Moving all the declarative parts of the test to the JSON script tag I think simplifies the test file and makes it very straightforward to consume in the runner.
The text was updated successfully, but these errors were encountered: