launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19649
[Merge] lp:~wgrant/launchpad/webhooks-delivery-ui-tests into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/webhooks-delivery-ui-tests into lp:launchpad.
Commit message:
Refactor and test the webhook deliveries widget's retry functionality.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/webhooks-delivery-ui-tests/+merge/275007
Refactor and test the webhook deliveries widget's retry functionality.
The widget now fires an event on retry, rather than performing network communication itself. This means retries can be and are now tested.
IDs are no longer used, so multiple widgets can coexist on a single page, originally so there could be a demo widget on the test page for manual testing. But I had to split the pages after a weird test-console misbehaviour if the test module is loaded outside the test runner.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/webhooks-delivery-ui-tests into lp:launchpad.
=== modified file 'lib/lp/services/webhooks/javascript/deliveries.js'
--- lib/lp/services/webhooks/javascript/deliveries.js 2015-09-09 12:56:45 +0000
+++ lib/lp/services/webhooks/javascript/deliveries.js 2015-10-20 11:14:42 +0000
@@ -49,23 +49,12 @@
WebhookDeliveries.NAME = "webhook-deliveries";
+WebhookDeliveries.RETRY_DELIVERY = 'retryDelivery';
+
WebhookDeliveries.ATTRS = {
deliveries: {
value: [],
- setter: function(deliveries) {
- var self = this;
- // Objects in LP.cache.deliveries are not wrapped on page
- // load, but the objects we get from batch navigation are.
- // Ensure we're always dealing with wrapped ones.
- return Y.Array.map(deliveries, function(delivery) {
- if (delivery.get === undefined) {
- return self.lp_client.wrap_resource(null, delivery);
- } else {
- return delivery;
- }
- });
- }
}
};
@@ -73,7 +62,6 @@
Y.extend(WebhookDeliveries, Y.Widget, {
initializer: function(config) {
- this.lp_client = new Y.lp.client.Launchpad();
this.delivery_info = {};
var self = this;
@@ -99,15 +87,26 @@
});
},
+ delivery_retried: function(delivery_url, result) {
+ if (result) {
+ // TODO: Refresh the object and unset requesting_retry.
+ // For now this will leave "Delivering" spinner in place,
+ // which is the most likely result anyway.
+ } else {
+ this.delivery_info[delivery_url].requesting_retry = false;
+ }
+ this.syncUI();
+ },
+
bindUI: function() {
- var table = this.get("contentBox").one("#webhook-deliveries-table");
+ var table = this.get("contentBox").one(".webhook-deliveries-table");
table.delegate("click", this._toggle_detail.bind(this), "tbody > tr");
table.delegate(
"click", this._trigger_retry.bind(this), ".delivery-retry");
},
syncUI: function() {
- var table = this.get("contentBox").one("#webhook-deliveries-table");
+ var table = this.get("contentBox").one(".webhook-deliveries-table");
var new_tbody = Y.Node.create("<tbody></tbody>");
var self = this;
Y.Array.each(this.deliveries_displayed, function(delivery_url) {
@@ -263,35 +262,39 @@
// Already in progress.
return;
}
+
+ // Engage the "Delivering" spinner.
delivery.requesting_retry = true;
this.syncUI();
- // XXX wgrant 2015-09-09: This should fire an event to an
- // external model object, which forwards the retry to the server,
- // refreshes our copy, then fires an event back to update the
- // widget.
- var self = this;
- var config = {
- on: {
- success: function() {
- // TODO: Refresh the object and unset requesting_retry.
- // For now this will leave "Delivering" spinner in
- // place, which is the most likely result anyway.
- self.syncUI();
- },
- failure: function() {
- // TODO: Display error popup.
- delivery.requesting_retry = false;
- self.syncUI();
- }
- }
- };
- this.lp_client.named_post(delivery_url, 'retry', config);
+
+ // Fire an event requesting a retry. Users of the widget must
+ // listen to this, request the retry, and call
+ // delivery_retried() when the request has been sent.
+ this.fire(
+ namespace.WebhookDeliveries.RETRY_DELIVERY,
+ delivery_url)
}
});
namespace.WebhookDeliveries = WebhookDeliveries;
+namespace.retry_delivery = function(deliveries_widget, delivery_url) {
+ var config = {
+ on: {
+ success: function() {
+ deliveries_widget.delivery_retried(delivery_url, true);
+ },
+ failure: function() {
+ // TODO: Display error popup.
+ deliveries_widget.delivery_retried(delivery_url, false);
+ }
+ }
+ };
+ var lp_client = new Y.lp.client.Launchpad();
+ lp_client.named_post(delivery_url, 'retry', config);
+};
+
}, "0.1", {"requires": ["event", "node", "widget", "lp.app.date",
"lp.app.listing_navigator", "lp.client",
"lp.mustache"]});
=== added file 'lib/lp/services/webhooks/javascript/tests/demo_deliveries.html'
--- lib/lp/services/webhooks/javascript/tests/demo_deliveries.html 1970-01-01 00:00:00 +0000
+++ lib/lp/services/webhooks/javascript/tests/demo_deliveries.html 2015-10-20 11:14:42 +0000
@@ -0,0 +1,95 @@
+<!DOCTYPE html>
+<!--
+Copyright 2015 Canonical Ltd. This software is licensed under the
+GNU Affero General Public License version 3 (see the file LICENSE).
+-->
+
+<html>
+ <head>
+ <!-- Separate from test_deliveries.html because loading the test
+ module before the runner starts somehow breaks test-console. -->
+ <title>Webhook deliveries widget tests</title>
+
+ <!-- YUI and test setup -->
+ <script type="text/javascript"
+ src="../../../../../../build/js/yui/yui/yui.js">
+ </script>
+ <link rel="stylesheet"
+ href="../../../../../../lib/canonical/launchpad/icing/build/inline-sprites-1.css" />
+ <link rel="stylesheet"
+ href="../../../../../../lib/canonical/launchpad/icing/build/inline-sprites-2.css" />
+
+ <link rel="stylesheet" href="../../../../app/javascript/testing/test.css" />
+
+ <!-- Dependencies -->
+ <script type="text/javascript"
+ src="../../../../../../build/js/lp/app/testing/mockio.js"></script>
+ <script type="text/javascript"
+ src="../../../../../../build/js/lp/app/client.js"></script>
+ <script type="text/javascript"
+ src="../../../../../../build/js/lp/app/date.js"></script>
+ <script type="text/javascript"
+ src="../../../../../../build/js/lp/app/errors.js"></script>
+ <script type="text/javascript"
+ src="../../../../../../build/js/lp/app/lp.js"></script>
+ <script type="text/javascript"
+ src="../../../../../../build/js/lp/app/mustache.js"></script>
+ <script type="text/javascript"
+ src="../../../../../../build/js/lp/app/listing_navigator.js"></script>
+
+ <!-- The module under test. -->
+ <script type="text/javascript" src="../deliveries.js"></script>
+
+ <!-- The test suite -->
+ <script type="text/javascript" src="test_deliveries.js"></script>
+
+ <script id="fixture-template" type="text/x-template">
+ <div>
+ <table class="webhook-deliveries-table listing">
+ <colgroup>
+ <col style="width: 18px" />
+ </colgroup>
+ <tbody>
+ <tr class="webhook-deliveries-table-loading">
+ <td colspan="3" style="padding-left: 0.25em">
+ <img class="spinner" src="/@@/spinner" alt="Loading..." />
+ Loading...
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </script>
+
+ <!-- Set up a demo widget for manual testing. -->
+ <script type="text/javascript">
+ YUI().use('base', 'node', 'event', 'lp.services.webhooks.deliveries',
+ 'lp.services.webhooks.deliveries.test',
+ function(Y) {
+ Y.on('domready', function() {
+ var ns = Y.lp.services.webhooks.deliveries;
+ var tests = Y.lp.services.webhooks.deliveries.test;
+ var node = Y.Node.create(
+ Y.one("#fixture-template").getContent());
+ node.set("id", "demo-widget");
+ Y.one("#demo-container").replace(node);
+ var deliveries_widget = new ns.WebhookDeliveries({
+ srcNode: '#demo-widget'});
+ deliveries_widget.set('deliveries', [
+ tests.deliveries.pending,
+ tests.deliveries.successful,
+ tests.deliveries.successful_retry_now,
+ tests.deliveries.failed,
+ tests.deliveries.failed_retry_scheduled
+ ]);
+ deliveries_widget.render();
+ });
+ });
+ </script>
+ </head>
+ <body class="yui3-skin-sam">
+ <h1>Webhook deliveries widget</h1>
+ <h2>Demo</h2>
+ <div id="demo-container">Loading...</div>
+ </body>
+</html>
=== modified file 'lib/lp/services/webhooks/javascript/tests/test_deliveries.html'
--- lib/lp/services/webhooks/javascript/tests/test_deliveries.html 2015-09-09 10:27:41 +0000
+++ lib/lp/services/webhooks/javascript/tests/test_deliveries.html 2015-10-20 11:14:42 +0000
@@ -47,13 +47,13 @@
<script type="text/javascript" src="test_deliveries.js"></script>
<script id="fixture-template" type="text/x-template">
- <div id="webhook-deliveries">
- <table id="webhook-deliveries-table" class="listing">
+ <div>
+ <table class="webhook-deliveries-table listing">
<colgroup>
<col style="width: 18px" />
</colgroup>
<tbody>
- <tr id='webhook-deliveries-table-loading'>
+ <tr class="webhook-deliveries-table-loading">
<td colspan="3" style="padding-left: 0.25em">
<img class="spinner" src="/@@/spinner" alt="Loading..." />
Loading...
=== modified file 'lib/lp/services/webhooks/javascript/tests/test_deliveries.js'
--- lib/lp/services/webhooks/javascript/tests/test_deliveries.js 2015-09-09 10:57:50 +0000
+++ lib/lp/services/webhooks/javascript/tests/test_deliveries.js 2015-10-20 11:14:42 +0000
@@ -6,55 +6,61 @@
var tests = Y.namespace('lp.services.webhooks.deliveries.test');
tests.suite = new Y.Test.Suite(
'lp.services.webhooks.deliveries Tests');
-
- var DELIVERY_PENDING = {
- "event_type": "ping", "successful": null, "error_message": null,
- "date_sent": null, "self_link": "http://example.com/delivery/1",
- "date_created": "2014-09-08T01:19:16+00:00", "date_scheduled": null,
- "pending": true, "resource_type_link": "#webhook_delivery"};
-
- var DELIVERY_SUCCESSFUL = {
- "event_type": "ping", "successful": true,
- "error_message": null,
- "date_sent": "2014-09-08T01:19:16+00:00",
- "self_link": "http://example.com/delivery/2",
- "date_created": "2014-09-08T01:19:16+00:00",
- "date_scheduled": null, "pending": false,
- "resource_type_link": "#webhook_delivery"};
-
- var DELIVERY_SUCCESSFUL_RETRY_NOW = {
- "event_type": "ping", "successful": true,
- "error_message": null,
- "date_sent": "2014-09-08T01:19:16+00:00",
- "self_link": "http://example.com/delivery/2",
- "date_created": "2014-09-08T01:19:16+00:00",
- "date_scheduled": "2014-09-08T01:19:16+00:00",
- "pending": true, "resource_type_link": "#webhook_delivery"};
-
- var DELIVERY_FAILED = {
- "event_type": "ping", "successful": false,
- "error_message": "Bad HTTP response: 404",
- "date_sent": "2014-09-08T01:19:16+00:00",
- "self_link": "http://example.com/delivery/2",
- "date_created": "2014-09-08T01:19:16+00:00",
- "date_scheduled": null, "pending": false,
- "resource_type_link": "#webhook_delivery"};
-
- var DELIVERY_FAILED_RETRY_SCHEDULED = {
- "event_type": "ping", "successful": false,
- "error_message": "Bad HTTP response: 404",
- "date_sent": "2014-09-08T01:19:16+00:00",
- "self_link": "http://example.com/delivery/2",
- "date_created": "2014-09-08T01:19:16+00:00",
- "date_scheduled": "2034-09-08T01:19:16+00:00", "pending": true,
- "resource_type_link": "#webhook_delivery"};
+ var lp_client = new Y.lp.client.Launchpad();
+
+ tests.deliveries = lp_client.wrap_resource(null, {
+ "pending": {
+ "event_type": "ping", "successful": null, "error_message": null,
+ "date_sent": null, "self_link": "http://example.com/delivery/1",
+ "date_created": "2014-09-08T01:19:16+00:00",
+ "date_scheduled": null, "pending": true,
+ "resource_type_link": "#webhook_delivery"
+ },
+ "successful": {
+ "event_type": "ping", "successful": true,
+ "error_message": null,
+ "date_sent": "2014-09-08T01:19:16+00:00",
+ "self_link": "http://example.com/delivery/2",
+ "date_created": "2014-09-08T01:19:16+00:00",
+ "date_scheduled": null, "pending": false,
+ "resource_type_link": "#webhook_delivery"
+ },
+ "successful_retry_now": {
+ "event_type": "ping", "successful": true,
+ "error_message": null,
+ "date_sent": "2014-09-08T01:19:16+00:00",
+ "self_link": "http://example.com/delivery/3",
+ "date_created": "2014-09-08T01:19:16+00:00",
+ "date_scheduled": "2014-09-08T01:19:16+00:00",
+ "pending": true, "resource_type_link": "#webhook_delivery"
+ },
+ "failed": {
+ "event_type": "ping", "successful": false,
+ "error_message": "Bad HTTP response: 404",
+ "date_sent": "2014-09-08T01:19:16+00:00",
+ "self_link": "http://example.com/delivery/4",
+ "date_created": "2014-09-08T01:19:16+00:00",
+ "date_scheduled": null, "pending": false,
+ "resource_type_link": "#webhook_delivery"
+ },
+ "failed_retry_scheduled": {
+ "event_type": "ping", "successful": false,
+ "error_message": "Bad HTTP response: 404",
+ "date_sent": "2014-09-08T01:19:16+00:00",
+ "self_link": "http://example.com/delivery/5",
+ "date_created": "2014-09-08T01:19:16+00:00",
+ "date_scheduled": "2034-09-08T01:19:16+00:00", "pending": true,
+ "resource_type_link": "#webhook_delivery"
+ }
+ });
var common_test_methods = {
setUp: function() {
- Y.one("#fixture").append(
- Y.Node.create(Y.one("#fixture-template").getContent()));
- this.widget = this.createWidget();
+ this.node = Y.Node.create(Y.one("#fixture-template").getContent());
+ this.node.set("id", "test-deliveries");
+ Y.one("#fixture").append(this.node);
+ this.widget = this.createWidget("#test-deliveries");
},
tearDown: function() {
@@ -64,7 +70,7 @@
createWidget: function(cfg) {
var config = Y.merge(cfg, {
- srcNode: "#webhook-deliveries",
+ srcNode: "#test-deliveries",
});
var ns = Y.lp.services.webhooks.deliveries;
return new ns.WebhookDeliveries(config);
@@ -73,7 +79,7 @@
};
tests.suite.add(new Y.Test.Case(Y.merge(common_test_methods, {
- name: 'lp.services.webhooks.deliveries_tests',
+ name: 'lp.services.webhooks.deliveries_widget_tests',
test_library_exists: function () {
Y.Assert.isObject(Y.lp.services.webhooks.deliveries,
@@ -88,50 +94,56 @@
},
test_render: function() {
- Y.Assert.isFalse(Y.all("#webhook-deliveries tr").isEmpty());
- Y.Assert.isNotNull(Y.one("#webhook-deliveries-table-loading"));
+ Y.Assert.isFalse(this.node.all("tr").isEmpty());
+ Y.Assert.isNotNull(
+ this.node.one(".webhook-deliveries-table-loading"));
this.widget.render();
- Y.Assert.isTrue(Y.all("#webhook-deliveries tr").isEmpty());
- Y.Assert.isNull(Y.one("#webhook-deliveries-table-loading"));
+ Y.Assert.isTrue(this.node.all("tr").isEmpty());
+ Y.Assert.isNull(
+ this.node.one(".webhook-deliveries-table-loading"));
Y.ArrayAssert.itemsAreEqual(this.widget.get("deliveries"), []);
},
test_expand_detail: function() {
this.widget.render();
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 0);
- this.widget.set("deliveries", [DELIVERY_PENDING]);
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 1);
+ Y.Assert.areEqual(this.node.all("tr").size(), 0);
+ this.widget.set("deliveries", [tests.deliveries.pending]);
+ Y.Assert.areEqual(this.node.all("tr").size(), 1);
// Clicking a row adds a new one immediately below with details.
- Y.one("#webhook-deliveries tr:nth-child(1)").simulate("click");
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 2);
+ this.node.one("tr:nth-child(1)").simulate("click");
+ Y.Assert.areEqual(this.node.all("tr").size(), 2);
// Clicking on the new row does nothing.
- Y.one("#webhook-deliveries tr:nth-child(2)").simulate("click");
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 2);
+ this.node.one("tr:nth-child(2)").simulate("click");
+ Y.Assert.areEqual(this.node.all("tr").size(), 2);
// Adding and clicking another row expands it as well.
- this.widget.set("deliveries", [DELIVERY_PENDING, DELIVERY_FAILED]);
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 3);
- Y.one("#webhook-deliveries tr:nth-child(3)").simulate("click");
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 4);
+ this.widget.set(
+ "deliveries",
+ [tests.deliveries.pending, tests.deliveries.failed]);
+ Y.Assert.areEqual(this.node.all("tr").size(), 3);
+ Y.one("#test-deliveries tr:nth-child(3)").simulate("click");
+ Y.Assert.areEqual(this.node.all("tr").size(), 4);
// Clicking the main row again collapses it.
- Y.one("#webhook-deliveries tr:nth-child(1)").simulate("click");
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 3);
+ this.node.one("tr:nth-child(1)").simulate("click");
+ Y.Assert.areEqual(this.node.all("tr").size(), 3);
// The expanded state is remembered even if the deliveries
// disappear.
this.widget.set("deliveries", []);
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 0);
- this.widget.set("deliveries", [DELIVERY_PENDING, DELIVERY_FAILED]);
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 3);
+ Y.Assert.areEqual(this.node.all("tr").size(), 0);
+ this.widget.set(
+ "deliveries",
+ [tests.deliveries.pending, tests.deliveries.failed]);
+ Y.Assert.areEqual(this.node.all("tr").size(), 3);
},
dump_row_state: function(node) {
// XXX wgrant 2015-09-09: Should get the detail row in a
// nicer way.
- Y.Assert.isNull(Y.one("#webhook-deliveries tr:nth-child(2)"));
+ Y.Assert.isNull(this.node.one("tr:nth-child(2)"));
// Expand the detail section.
node.simulate("click");
- var detail_node = Y.one("#webhook-deliveries tr:nth-child(2)");
+ var detail_node = this.node.one("tr:nth-child(2)");
Y.Assert.isObject(detail_node);
var delivering_notice = detail_node.one(
".delivery-delivering-notice");
@@ -147,11 +159,18 @@
};
},
+ assert_rows_match: function(actual, expected) {
+ Y.Assert.areSame(actual.sprite, expected.sprite);
+ Y.Assert.areSame(actual.delivering, expected.delivering);
+ Y.Assert.areSame(actual.retry_notice, expected.retry_notice);
+ Y.Assert.areSame(actual.retry, expected.retry);
+ },
+
test_delivery_pending: function() {
- this.widget.set("deliveries", [DELIVERY_PENDING]);
+ this.widget.set("deliveries", [tests.deliveries.pending]);
this.widget.render();
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 1);
- var state = this.dump_row_state(Y.one("#webhook-deliveries tr"));
+ Y.Assert.areEqual(this.node.all("tr").size(), 1);
+ var state = this.dump_row_state(this.node.one("tr"));
// Of the retry widgets, only the "Delivering" spinner is shown.
Y.Assert.areEqual(state.sprite, "sprite milestone");
Y.Assert.isTrue(state.delivering);
@@ -160,10 +179,10 @@
},
test_delivery_successful: function() {
- this.widget.set("deliveries", [DELIVERY_SUCCESSFUL]);
+ this.widget.set("deliveries", [tests.deliveries.successful]);
this.widget.render();
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 1);
- var state = this.dump_row_state(Y.one("#webhook-deliveries tr"));
+ Y.Assert.areEqual(this.node.all("tr").size(), 1);
+ var state = this.dump_row_state(this.node.one("tr"));
// The only visible retry widget is the "Retry" link.
Y.Assert.areEqual(state.sprite, "sprite yes");
Y.Assert.isFalse(state.delivering);
@@ -172,10 +191,11 @@
},
test_delivery_successful_retry_now: function() {
- this.widget.set("deliveries", [DELIVERY_SUCCESSFUL_RETRY_NOW]);
+ this.widget.set(
+ "deliveries", [tests.deliveries.successful_retry_now]);
this.widget.render();
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 1);
- var state = this.dump_row_state(Y.one("#webhook-deliveries tr"));
+ Y.Assert.areEqual(this.node.all("tr").size(), 1);
+ var state = this.dump_row_state(this.node.one("tr"));
// The "Delivering" spinner is visible.
Y.Assert.areEqual(state.sprite, "sprite yes");
Y.Assert.isTrue(state.delivering);
@@ -184,10 +204,10 @@
},
test_delivery_failed: function() {
- this.widget.set("deliveries", [DELIVERY_FAILED]);
+ this.widget.set("deliveries", [tests.deliveries.failed]);
this.widget.render();
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 1);
- var state = this.dump_row_state(Y.one("#webhook-deliveries tr"));
+ Y.Assert.areEqual(this.node.all("tr").size(), 1);
+ var state = this.dump_row_state(this.node.one("tr"));
// The only visible retry widget is the "Retry" link.
Y.Assert.areEqual(state.sprite, "sprite no");
Y.Assert.isFalse(state.delivering);
@@ -196,16 +216,60 @@
},
test_delivery_failed_retry_scheduled: function() {
- this.widget.set("deliveries", [DELIVERY_FAILED_RETRY_SCHEDULED]);
+ this.widget.set(
+ "deliveries", [tests.deliveries.failed_retry_scheduled]);
this.widget.render();
- Y.Assert.areEqual(Y.all("#webhook-deliveries tr").size(), 1);
- var state = this.dump_row_state(Y.one("#webhook-deliveries tr"));
+ Y.Assert.areEqual(this.node.all("tr").size(), 1);
+ var state = this.dump_row_state(this.node.one("tr"));
// The visible retry widgets are the schedule notice and a
// "Retry now" link.
Y.Assert.areEqual(state.sprite, "sprite warning-icon");
Y.Assert.isFalse(state.delivering);
Y.Assert.areEqual(state.retry_notice, "Retrying on 2034-09-08.");
Y.Assert.areEqual(state.retry, "Retry now");
+ },
+
+ test_retry: function() {
+ this.widget.set("deliveries", [tests.deliveries.failed]);
+ this.widget.render();
+ Y.Assert.areEqual(this.node.all("tr").size(), 1);
+
+ // The delivery is initially not delivering.
+ var initial_state =
+ this.dump_row_state(this.node.one("tr"));
+ Y.Assert.areEqual(initial_state.sprite, "sprite no");
+ Y.Assert.isFalse(initial_state.delivering);
+ Y.Assert.isNull(initial_state.retry_notice);
+ Y.Assert.areEqual(initial_state.retry, "Retry");
+
+ // Hit retry and the delivery spinner is shown.
+ this.node.one("tr .delivery-retry").simulate("click");
+ this.node.one("tr").simulate("click");
+ var retry_state = this.dump_row_state(this.node.one("tr"));
+ Y.Assert.areEqual(retry_state.sprite, "sprite warning-icon");
+ Y.Assert.isTrue(retry_state.delivering);
+ Y.Assert.isNull(retry_state.retry_notice);
+ Y.Assert.isNull(retry_state.retry);
+
+ // If the retry request fails, the retry action returns.
+ this.widget.delivery_retried(
+ "http://example.com/delivery/4", false);
+ this.node.one("tr").simulate("click");
+ var retry_failed_state = this.dump_row_state(this.node.one("tr"));
+ this.assert_rows_match(retry_failed_state, initial_state);
+
+ // Retry again.
+ this.node.one("tr .delivery-retry").simulate("click");
+ this.node.one("tr").simulate("click");
+ var retry_again_state = this.dump_row_state(this.node.one("tr"));
+ this.assert_rows_match(retry_again_state, retry_state);
+
+ // Succeed this time and the "Delivering" notice sticks.
+ this.widget.delivery_retried(
+ "http://example.com/delivery/4", true);
+ this.node.one("tr").simulate("click");
+ var retried_state = this.dump_row_state(this.node.one("tr"));
+ this.assert_rows_match(retried_state, retry_state);
}
})));
=== modified file 'lib/lp/services/webhooks/templates/webhook-index.pt'
--- lib/lp/services/webhooks/templates/webhook-index.pt 2015-09-09 12:16:16 +0000
+++ lib/lp/services/webhooks/templates/webhook-index.pt 2015-10-20 11:14:42 +0000
@@ -20,7 +20,7 @@
var navigator = new ns.WebhookDeliveriesListingNavigator({
current_url: window.location,
cache: LP.cache,
- target: Y.one('#webhook-deliveries-table'),
+ target: container.one('.webhook-deliveries-table'),
container: container,
});
navigator.set('backwards_navigation',
@@ -37,8 +37,18 @@
function(e) {
deliveries_widget.set('deliveries', e.details[0]);
});
-
- deliveries_widget.set('deliveries', LP.cache.deliveries);
+ deliveries_widget.subscribe(
+ ns.WebhookDeliveries.RETRY_DELIVERY,
+ function(e) {
+ ns.retry_delivery(deliveries_widget, e.details[0]);
+ });
+ // Objects in LP.cache.deliveries are not wrapped on page
+ // load, but the objects we get from batch navigation are.
+ // Ensure we're always dealing with wrapped ones.
+ var lp_client = new Y.lp.client.Launchpad();
+ deliveries_widget.set(
+ 'deliveries',
+ lp_client.wrap_resource(null, LP.cache.deliveries));
deliveries_widget.render();
});
});
@@ -62,14 +72,14 @@
<div class="lesser"
tal:content="structure view/deliveries/@@+navigation-links-upper" />
- <table id="webhook-deliveries-table" class="listing">
+ <table class="webhook-deliveries-table listing">
<colgroup>
<col style="width: 18px" />
<col style="width: 10em" />
<col style="width: 5em" />
</colgroup>
<tbody>
- <tr id='webhook-deliveries-table-loading'>
+ <tr class="webhook-deliveries-table-loading">
<td colspan="3" style="padding-left: 0.25em">
<img class="spinner" src="/@@/spinner" alt="Loading..." />
Loading...
Follow ups