Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(230)

Unified Diff: test/test_browser_app.js

Issue 13245045: Bundle Topology
Patch Set: Bundle Topology Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/test_app.js ('k') | test/test_browser_editorial.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/test_browser_app.js
=== modified file 'test/test_browser_app.js'
--- test/test_browser_app.js 2013-08-19 17:15:16 +0000
+++ test/test_browser_app.js 2013-08-28 00:28:12 +0000
@@ -181,6 +181,54 @@
})();
(function() {
+ describe('browser minimzed view', function() {
+ var Y, browser, container, view, views, Minimized;
+
+ before(function(done) {
+ Y = YUI(GlobalConfig).use(
+ 'juju-browser',
+ 'juju-models',
+ 'juju-views',
+ 'juju-tests-utils',
+ 'subapp-browser-minimized',
+ function(Y) {
+ browser = Y.namespace('juju.browser');
+ views = Y.namespace('juju.browser.views');
+ Minimized = views.MinimizedView;
+ done();
+ });
+ });
+
+ beforeEach(function() {
+ container = Y.namespace('juju-tests.utils').makeContainer('container');
+ addBrowserContainer(Y, container);
+ // Mock out a dummy location for the Store used in view instances.
+ window.juju_config = {
+ charmworldURL: 'http://localhost'
+ };
+ });
+
+ afterEach(function() {
+ view.destroy();
+ Y.one('#subapp-browser').remove(true);
+ delete window.juju_config;
+ container.remove(true);
+ });
+
+ it('toggles to sidebar', function(done) {
+ var container = Y.one('#subapp-browser');
+ view = new Minimized();
+ view.on('viewNavigate', function(ev) {
+ assert(ev.change.viewmode === 'sidebar');
+ done();
+ });
+ view.render(container);
+ view.controls._toggleViewable({halt: function() {}});
+ });
+ });
+ })();
+
+ (function() {
describe('browser sidebar view', function() {
var Y, browser, container, view, views, Sidebar;
@@ -332,13 +380,14 @@
(function() {
describe('browser app', function() {
- var Y, app, browser, Charmworld2, next;
+ var Y, app, browser, Charmworld2, container, next;
before(function(done) {
Y = YUI(GlobalConfig).use(
'app-subapp-extension',
'juju-browser',
'juju-charm-store',
+ 'juju-tests-utils',
'juju-views',
'subapp-browser', function(Y) {
browser = Y.namespace('juju.subapps');
@@ -353,12 +402,16 @@
window.juju_config = {
charmworldURL: 'http://localhost'
};
+ container = Y.namespace('juju-tests.utils').makeContainer('container');
+ addBrowserContainer(Y, container);
+
});
afterEach(function() {
if (app) {
app.destroy();
}
+ container.remove(true);
window.juju_config = undefined;
});
@@ -383,6 +436,28 @@
assert.isTrue(called);
});
+ it('resets using initState', function() {
+ app = new browser.Browser();
+ var mockView = {
+ destroy: function() {}
+ };
+ app._sidebar = mockView;
+ app._minimized = mockView;
+ app._fullscreen = mockView;
+
+ // Setup some previous state to check for clearing.
+ app._oldState.viewmode = 'fullscreen';
+ app._viewState.viewmode = 'sidebar';
+
+ app.initState();
+
+ assert.equal(app._sidebar, undefined, 'sidebar is removed');
+ assert.equal(app._fullscreen, undefined, 'fullscreen is removed');
+ assert.equal(app._minimized, undefined, 'minimized is removed');
+ assert.equal(app._oldState.viewmode, null, 'old state is reset');
+ assert.equal(app._viewState.viewmode, null, 'view state is reset');
+ });
+
it('correctly strips viewmode from the charmID', function() {
app = new browser.Browser();
var paths = [
@@ -609,6 +684,7 @@
'app-subapp-extension',
'juju-views',
'juju-browser',
+ 'juju-tests-utils',
'subapp-browser', function(Y) {
browser = Y.namespace('juju.subapps');
@@ -723,6 +799,8 @@
it('resets filters when navigating away from search', function() {
browser._viewState.search = true;
browser._filter.set('text', 'foo');
+ // Set the state before changing up.
+ browser._saveState();
browser._getStateUrl({search: false});
assert.equal('', browser._filter.get('text'));
});
@@ -1143,6 +1221,18 @@
it('when hidden the browser avoids routing', function() {
browser.hidden = true;
+ // XXX bug:1217383
+ // We also want to verify that the old views are cleared to avoid
+ // having hidden views doing UX work for us.
+ var hitCount = 0;
+ var mockView = {
+ destroy: function() {
+ hitCount = hitCount + 1;
+ }
+ };
+ browser._sidebar = mockView;
+ browser._minimized = mockView;
+ browser._fullscreen = mockView;
var req = {
path: '/minimized',
@@ -1161,6 +1251,13 @@
minNode.getComputedStyle('display').should.eql('none');
browserNode.getComputedStyle('display').should.eql('none');
+
+ assert.equal(hitCount, 3);
+
+ // The view state needs to also be sync'd and updated even though
+ // we're hidden so that we can detect changes in the app state across
+ // requests while hidden.
+ assert.equal(browser._oldState.viewmode, 'minimized');
});
it('knows when the search cache should be updated', function() {
@@ -1169,16 +1266,19 @@
'querystring': 'text=apache'
});
assert.isTrue(browser._searchChanged());
+ browser._saveState();
browser._getStateUrl({
'search': true,
'querystring': 'text=apache'
});
assert.isFalse(browser._searchChanged());
+ browser._saveState();
browser._getStateUrl({
'search': true,
'querystring': 'text=ceph'
});
assert.isTrue(browser._searchChanged());
+ browser._saveState();
});
it('permits a filter clear command', function() {
« no previous file with comments | « test/test_app.js ('k') | test/test_browser_editorial.js » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b