Testing the client-side functionality

As covered in Chapter 1Isomorphic Web Applications with Goafter the initial page load, subsequent navigations on the website are served using single page application architecture. This means that an XHR call is initiated to a Rest API endpoint that provides the necessary data to render content that will be displayed on the web page. In the case where the client-side handler displays the products listing page, for example, a Rest API endpoint is utilized to fetch the list of products to display. In some cases, a Rest API endpoint is not even necessary since the page content only requires rendering a template. One such example of this is when a user accesses the contact form by clicking on the Contact link in the navigation bar. In this situation, we simply render the contact form template and display the contents in the primary content area.

Let's take a moment and think about all the baseline functionality that we would need to test on the client-side. We need to verify that the client-side routes are functional and that the proper page is rendered for each route, similar to how we verified the server-side routes in the previous section. In addition to that, we need to confirm that the client-side form validation is working for the contact form as well as testing the scenario of a valid form submission. The functionality to add and remove items, to and from the shopping cart, is currently implemented on the client-side only. This means that we will have to write tests to verify that this functionality is working as expected. Another feature that is currently only available on the client-side, is the live chat feature. We must validate that the user can communicate with the live chat bot, that the bot replies, and that the conversation is maintained as the user navigates to different sections of the website.

Finally, we have to test our collection of cogs. We have to make sure that the time ago cog, shows a time instance in human understandable format. We have to verify that the live clock cog is functioning properly. We have to verify that the date picker cog appears when the Time Sensitivity Date field is clicked. We have to verify that the carousel cog appears on the home page. Finally, we have to verify that the notify cog is displaying notifications properly when adding and removing items to and from the shopping cart.

Therefore on the client-side, the baseline set of functionality that we'll test for, includes the following items:

  1. Verifying client-side routing and template rendering
  2. Verifying the contact form
  3. Verifying the shopping cart functionality
  4. Verifying the live chat feature
  5. Verifying the time ago cog
  6. Verifying the live clock cog
  7. Verifying the date picker cog
  8. Verifying the carousel cog
  9. Verifying the notify cog

In order to perform automated testing on the client-side, which includes user interactions, we need a tool that has a JavaScript runtime built into it. Therefore, we cannot use go test when testing the client-side functionality.

We will use CasperJS to perform automated testing on the client-side.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.37.38