summaryrefslogtreecommitdiffstats
path: root/apps/files/tests
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-02-19 23:47:19 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-03-01 20:33:14 +0100
commitbb85084c3de5e7563ad0131c5206a9c61f57a3ee (patch)
tree3e177e916d2a96b5721f6d7666780499b0b49378 /apps/files/tests
parent1da92fd5dad88889478c156e6cd73b9c8f09a6cd (diff)
downloadnextcloud-server-bb85084c3de5e7563ad0131c5206a9c61f57a3ee.tar.gz
nextcloud-server-bb85084c3de5e7563ad0131c5206a9c61f57a3ee.zip
Take padding and margin of the creatable actions div into account
There are some differences in width handling between the browsers used to run the tests, most likely due to their support (or lack of) of certain CSS features: PhantomJS requires "width" to be set (probably because it does not handle flex displays and treats it like a block, so "min-width" does not matter in this case), while Firefox requires "min-width" to be set (otherwise the children of "#controls" could be compressed due to its use of flex display and the elements would end with a different width than the one needed for the tests). Due to all that the width of the breadcrumb siblings must be specified in the tests using both "width" and "min-width". Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/files/tests')
-rw-r--r--apps/files/tests/js/breadcrumbSpec.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/apps/files/tests/js/breadcrumbSpec.js b/apps/files/tests/js/breadcrumbSpec.js
index 9898c556cfd..dcb9391f6ed 100644
--- a/apps/files/tests/js/breadcrumbSpec.js
+++ b/apps/files/tests/js/breadcrumbSpec.js
@@ -303,6 +303,88 @@ describe('OCA.Files.BreadCrumb tests', function() {
expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
});
+ it('Hides breadcrumbs to fit available width left by siblings', function() {
+ var $crumbs;
+
+ $('#controls').width(700);
+ bc._resize();
+
+ $crumbs = bc.$el.find('.crumb');
+
+ // Third and fourth crumb are hidden and everything else is visible
+ expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
+ expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
+
+ expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
+ expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
+ expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
+ expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
+ expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
+ expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
+
+ var $creatableActions = $('<div class="actions creatable"></div>');
+ // Set both the width and the min-width to even differences in width
+ // handling in the browsers used to run the tests.
+ $creatableActions.css('width', '200px');
+ $creatableActions.css('min-width', '200px');
+ $('#controls').append($creatableActions);
+
+ bc._resize();
+
+ // Second, third, fourth and fifth crumb are hidden and everything
+ // else is visible
+ expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
+ expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
+
+ expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
+ expect($crumbs.eq(3).hasClass('hidden')).toEqual(true);
+ expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
+ expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
+ expect($crumbs.eq(6).hasClass('hidden')).toEqual(true);
+ expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
+ });
+ it('Hides breadcrumbs to fit available width left by siblings with paddings and margins', function() {
+ var $crumbs;
+
+ $('#controls').width(700);
+ bc._resize();
+
+ $crumbs = bc.$el.find('.crumb');
+
+ // Third and fourth crumb are hidden and everything else is visible
+ expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
+ expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
+
+ expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
+ expect($crumbs.eq(3).hasClass('hidden')).toEqual(false);
+ expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
+ expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
+ expect($crumbs.eq(6).hasClass('hidden')).toEqual(false);
+ expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
+
+ var $creatableActions = $('<div class="actions creatable"></div>');
+ // Set both the width and the min-width to even differences in width
+ // handling in the browsers used to run the tests.
+ $creatableActions.css('width', '20px');
+ $creatableActions.css('min-width', '20px');
+ $creatableActions.css('margin-left', '90px');
+ $creatableActions.css('padding-right', '90px');
+ $('#controls').append($creatableActions);
+
+ bc._resize();
+
+ // Second, third, fourth and fifth crumb are hidden and everything
+ // else is visible
+ expect($crumbs.eq(0).hasClass('hidden')).toEqual(false);
+ expect($crumbs.eq(1).hasClass('hidden')).toEqual(false);
+
+ expect($crumbs.eq(2).hasClass('hidden')).toEqual(false);
+ expect($crumbs.eq(3).hasClass('hidden')).toEqual(true);
+ expect($crumbs.eq(4).hasClass('hidden')).toEqual(true);
+ expect($crumbs.eq(5).hasClass('hidden')).toEqual(true);
+ expect($crumbs.eq(6).hasClass('hidden')).toEqual(true);
+ expect($crumbs.eq(7).hasClass('hidden')).toEqual(false);
+ });
it('Updates the breadcrumbs when reducing available width', function() {
var $crumbs;