I felt that I can bring this thread back up, as I’ve had more time to think about how HTML fits into the OpenLMIS-UI – and I thought I’d share my thoughts before I start making tickets.
Please reply to the list, or email me directly, if you disagree or have questions. I’m friendly!
tldr; I can’t find anyone that thinks unit testing HTML is a good idea. HTML should be treated as a configuration layer.
The HTML we use to define routes/pages is great because it is relatively simple to read and understand how a specific piece of HTML turns into a screen. These types of files are easy for an implementer to replace, if they can pick out atomic pieces they want to replace AND don’t have to worry about creating a syntax error (that an HTML linter can’t find).
In our HTML, we need to work to keep the cyclomatic complexity low – which is unfortunately difficult because AngularJS gives us tons of fun methods that makes putting complexity into HTML fast and simple.
© HTML segments/files should represent content, without “wrapper” divits, which will promote reuse and decrease complexity
···
Nick Reid | nick.reid@villagereach.org
Software Developer, Information Systems Group
VillageReach** *** Starting at the Last Mile
*2900 Eastlake Ave. E, Suite 230, Seattle, WA 98102, USA
CELL: +1.510.410.0020
SKYPE: nickdotreid
www.villagereach.org
From: openlmis-dev@googlegroups.com openlmis-dev@googlegroups.com on behalf of Nick Reid nick.reid@villagereach.org
Sent: Tuesday, September 26, 2017 8:23:05 AM
To: Paweł Gesek
Cc: Openlmis Dev Mailing List
Subject: Re: [openlmis-dev] Test coverage for HTML (and documentation revisions)
The more I’ve researched and talked to people about this — no one seems to seriously do this — and I agree, some of these tests really are a place where selenium testing would/could/should be done. The reason we are having this conversation seems to come out of the discussions we had this summer about regressions.
Here is the list the Pawel Gesek mentioned (for those not immersed in the thread)
HTML Unit Testing Requirements
(1) Ensure HTML views display the information described in a ticket
(2) Verify that HTML views connect to the contract exposed by their controller
(3) Dynamic AngularJS elements act as defined when scope variables change
My thoughts is response to Pawel Gasek
(1) Is generally the place where high-level business logic driven integration are written, and I think since our stories are focusing more on vertical slices of functionality — we should be accomplishing this in integration tests
(2) seems like a unit test of the controller, so its kinda redundant
(3) Checking dynamic HTML changes with selenium would be a pain, and I don’t think we want to make integration tests with super deep logic
The example of modals updating values on the page, should really be tested in the controller logic — as the internal logic of the modal should be mocked, and the controller should just be checking that calling the change function updates the correct data element. I’d argue that any piece of HTML that knows about a modal is too broadly scoped.
Nick Reid | nick.reid@villagereach.org
Software Developer, Information Systems Group
VillageReach** *** Starting at the Last Mile
*2900 Eastlake Ave. E, Suite 230, Seattle, WA 98102, USA
CELL: +1.510.410.0020
SKYPE: nickdotreid
www.villagereach.org
From: Paweł Gesek pgesek@soldevelo.com
Sent: Tuesday, September 26, 2017 3:03:58 AM
To: Nick Reid
Cc: Openlmis Dev Mailing List
Subject: Re: [openlmis-dev] Test coverage for HTML (and documentation revisions)
Never really seen any serious HTML unit testing to be honest.
I think most projects that have the time to spare for this will be doing Selenium (or other UI integration testing) anyway - and that will be the place where your requirements #1 and #3 will be checked.
Will this HTML unit testing approach also cover dynamic elements of a page like modals and how they interact with the main page? (i.e. the adjustments modal changes the adjustments total value in the grid)
Regards,
Paweł
On Thu, Sep 21, 2017 at 11:53 PM, Nick Reid
nick.reid@villagereach.org wrote:
Dear dev-
tldr;
Updating HTML coding conventions on confluence here – want feedback on requirements for unit testing.
Nikodem Graczewski and I have been discussing how to apply unit tests to our HTML templates that are used through out the OpenLMIS-UI.
HTML templates do contain logic and business requirements, so they should be included in our testing strategy. I feel that Nikodem is right in building these unit tests, but I am worried they are too strict and could cause maintenance/extension issues.
I’ve done some googling on the issue, and there really isn’t great guidance on the issue. HTML is generally viewed as a configuration layer in AngularJS, not a piece of business logic.
This issue could be resolved with an integration testing strategy, but those workflows are harder to maintain than unit tests. Toolsets like PhantomCSS don’t really feel like the right direction we should go either.
Questions:
- What tools/strategies have you used in the past that worked well (or not so well)?
- Do these requirements for unit tests on HTML in AngularJS make sense:
- Views display information described in business requirements
- View honor and expose contract from controller
- Dynamic logic works when page state changes
- How can we write these unit tests so they are not tightly coupled to testing the HTML markup – but test behavior and business requirements
Here is a
recent example of the type of HTML unit tests we are building – I’ve tried to show a short and direct example. Any feedback about these tests is welcome.
https://github.com/OpenLMIS/openlmis-cce-ui/blob/master/src/cce-add-inventory-item/add-inventory-item.html.spec.js
Please comment on
HTML Coding Conventions
https://openlmis.atlassian.net/wiki/spaces/OP/pages/115972607/UI+Documentation+Working+Draft#UIDocumentationWorkingDraft-UnitTesting
Side note: I started updated the UI Documentation, mainly by breaking up the files so its easily readable and reference able (since us UI folk would refer to our conventions, but be completely wrong about what was written). If group editing these guidelines in confluence works, we will start this with other sections.
You can see the documentation changes here:
http://docs.openlmis.org/en/latest/conventions/index.html#
Nick Reid | nick.reid@villagereach.org
Software Developer, Information Systems Group
VillageReach** *** Starting at the Last Mile
*2900 Eastlake Ave. E, Suite 230, Seattle, WA 98102, USA
CELL: +1.510.410.0020
SKYPE: nickdotreid
www.villagereach.org
–
You received this message because you are subscribed to the Google Groups “OpenLMIS Dev” group.
To unsubscribe from this group and stop receiving emails from it, send an email to openlmis-dev+unsubscribe@googlegroups.com.
To post to this group, send email to
openlmis-dev@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/openlmis-dev/CY4PR02MB21995C347DE6189CC95426B094660%40CY4PR02MB2199.namprd02.prod.outlook.com.
For more options, visit
https://groups.google.com/d/optout.
–
Paweł Gesek
Technical Project Manager
pgesek@soldevelo.com / +48 690 020 875
**
SolDevelo** Sp. z o.o. [LLC] /
www.soldevelo.com
Al. Zwycięstwa 96/98, 81-451, Gdynia, Poland
Phone: +48 58 782 45 40 / Fax: +48 58 782 45 41
–
You received this message because you are subscribed to the Google Groups “OpenLMIS Dev” group.
To unsubscribe from this group and stop receiving emails from it, send an email to openlmis-dev+unsubscribe@googlegroups.com.
To post to this group, send email to
openlmis-dev@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/openlmis-dev/CY4PR02MB2199AD6A0AE0962A33E79366947B0%40CY4PR02MB2199.namprd02.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.