Commit c498d5de authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio_ui_test: Added test for service worker

  It was added as "0" in order to run first, as the later tests calls logout and can be started as anonymous.
parent fc7dd2fc
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testSlapOSJS0ServiceWorker</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test RenderJS UI</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr>
<td rowspan="1" colspan="3">Test RenderJS UI</td>
</tr>
</thead>
<tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<tr>
<td colspan="3"><b tal:content="python: 'Clone web site'"></b></td>
</tr>
<tr>
<td>open</td>
<td
tal:content="python: '${base_url}/web_site_module/hostingjs?ignore_layout:int=1&editable_mode:int=1'">
</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>name=Base_createCloneDocument:method</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>name=Base_createCloneDocument:method</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Created Clone Web Site</td>
<td></td>
</tr>
<tr>
<td>storeValue</td>
<td>name=field_my_id</td>
<td>install_url</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<tr>
<td>open</td>
<td>${base_url}/web_site_module/${install_url}/#/?page=test_service_worker</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/wait_for_app_loaded" />
<tr>
<td>setTimeout</td>
<td>450000</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Has SW: false</td>
<td></td>
</tr>
<tr>
<td>waitForTextPresent</td>
<td>Has SW: true</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Has SW: true</td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>SlapOS Test Service Worker</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_page.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_test_service_worker.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
/*global window, rJS, RSVP, domsugar, navigator, promiseEventListener, jIO */
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
(function (window, rJS, RSVP, domsugar, navigator, promiseEventListener, jIO) {
"use strict";
rJS(window)
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareMethod('render', function () {
var gadget = this;
// Wait a bit a allow the header loader to be displayed
return new RSVP.Queue(RSVP.delay(200))
.push(function () {
return gadget.getUrlForList([
// Home page
{command: 'display'},
// Soft reload the gadget
{command: 'change'}
]);
})
.push(function (url_list) {
gadget.checkServiceWorkerStatus();
return gadget.updateHeader({
page_title: 'Test Service Worker',
front_url: url_list[0],
tab_url: url_list[1],
submit_action: true
});
});
})
.declareMethod("triggerSubmit", function () {
var gadget = this;
return new RSVP.Queue(jIO.util.ajax({
type: 'POST',
url: './Base_changeModificationDateForTest'
}))
.push(function () {
domsugar(gadget.element, {
text: "SW changed on server"
});
});
})
.declareJob("checkServiceWorkerStatus", function () {
var gadget = this,
has_service_worker = (navigator.serviceWorker.controller !== null);
domsugar(gadget.element, {
text: "Has SW: " + has_service_worker.toString()
});
return new RSVP.Queue(navigator.serviceWorker.ready)
.push(function (worker_container) {
domsugar(gadget.element, {
text: "Has SW: true"
});
return promiseEventListener(worker_container.active, 'statechange');
})
.push(function () {
// Wait a bit until the message is propagated
return RSVP.delay(2000);
})
.push(function () {
domsugar(gadget.element, {
text: "New SW ready"
});
});
});
}(window, rJS, RSVP, domsugar, navigator, promiseEventListener, jIO));
\ No newline at end of file
web_page_module/rjs_gadget_slapos_erp5_page_test_service_worker_html
web_page_module/rjs_gadget_slapos_erp5_page_test_service_worker_js
\ No newline at end of file
portal_tests/slaposjs_zuite portal_tests/slaposjs_zuite
portal_tests/slaposjs_zuite/** portal_tests/slaposjs_zuite/**
web_page_module/rjs_gadget_slapos_erp5_page_test_service_worker_html
web_page_module/rjs_gadget_slapos_erp5_page_test_service_worker_js
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment