Testing

Privly’s Safari Extension supports both unit testing and integration testing. The tests can be run either locally or on SauceLabs.

Unit Testing

The extension’s unit testing is supported with the help of Jasmine tests run by the Karma Test Runner.

To run the unit tests, we need to first install the packages. To do this, navigate to the privly.safariextension/privly-applications/test directory and run the command npm install -g karma-cli && npm install. Finally navigate to the test directory to run the tests.

To run the unit tests locally, run the command ./run_each.sh ../privly.safariextension/privly-applications/test/karma.conf.js

To run the unit tests on SauceLabs, run the command ./run_each.sh ../privly.safariextension/privly-applications/test/karma.conf-ci.js

Integration Testing

The extension presently does not support integration testing with the help of Selenium. So, to make sure that the extension is functioning as expected, we need to manually follow the steps given below to ensure the same.

To test injected link functionality:

  • Navigate to http://test.privly.org/test_pages/url_parameters.html on the browser.
  • The No Parameters link will get replaced with an injected iframe.
  • This injected iframe contains the privly message.
  • Click on the privly popover and select Stop Injecting.
  • The injected iframe will now get replaced with the original text.
  • Repeat the test by navigating to https://www.facebook.com/mohammed.smith.7 on the browser.

To test injected link functionality with host page CSP:

  • Navigate to https://twitter.com/PrivlyTest on the browser.
  • The Privly links should not get replaced by iframes as the host page CSP does not allow iframes of different origin.

To test context menu functionality:

  • Navigate to http://test.privly.org/test_pages/embedposting_iframes.html on the browser.
  • Enter some text inside the first textarea.
  • Right click on the text and choose Privly: New Message from the context menu.
  • A new tab will open for creating the new message link.
  • If you are doing this for the first time, it will prompt you to login.
  • You will see your entered text in this page. Save the message.
  • The new message tab will close automatically and the text entered in the textarea will be replaced by a privly link.

To test privly button functionality:

  • Click on the privly extension popover and select Options.
  • In the Options page, uncheck the box that disables privly button and close the page.
  • Navigate to http://test.privly.org/test_pages/embedposting_iframes.html on the browser.
  • Click on the first textarea. We will see privly button that appears on the top-right of the textarea.
  • Click the privly button. A new page will open for new message link.
  • Enter some text in the page and click Save. The page will close.
  • The textarea contents will get replaced by the newly generated privly link.