Commit f1710bd1 authored by Annabel Dunstone Gray's avatar Annabel Dunstone Gray

Delete sidebar specs and fixtures; update shortcuts_spec to check page title

parent 8c1b41f1
...@@ -10,21 +10,20 @@ feature 'Dashboard shortcuts', feature: true, js: true do ...@@ -10,21 +10,20 @@ feature 'Dashboard shortcuts', feature: true, js: true do
find('body').native.send_key('g') find('body').native.send_key('g')
find('body').native.send_key('p') find('body').native.send_key('p')
ensure_active_main_tab('Projects') check_page_title('Projects')
find('body').native.send_key('g') find('body').native.send_key('g')
find('body').native.send_key('i') find('body').native.send_key('i')
ensure_active_main_tab('Issues') check_page_title('Issues')
find('body').native.send_key('g') find('body').native.send_key('g')
find('body').native.send_key('m') find('body').native.send_key('m')
ensure_active_main_tab('Merge Requests') check_page_title('Merge Requests')
end end
def ensure_active_main_tab(content) def check_page_title(title)
find('.global-dropdown-toggle').trigger('click') expect(find('.header-content .title')).to have_content(title)
expect(find('.global-dropdown-menu li.active')).to have_content(content)
end end
end end
/* eslint-disable no-new */
require('~/sidebar');
require('~/lib/utils/text_utility');
((global) => {
describe('Dashboard', () => {
const fixtureTemplate = 'static/dashboard.html.raw';
function todosCountText() {
return $('.js-todos-count').text();
}
function triggerToggle(newCount) {
$(document).trigger('todo:toggle', newCount);
}
preloadFixtures(fixtureTemplate);
beforeEach(() => {
loadFixtures(fixtureTemplate);
new global.Sidebar();
});
it('should update todos-count after receiving the todo:toggle event', () => {
triggerToggle(5);
expect(todosCountText()).toEqual('5');
});
it('should display todos-count with delimiter', () => {
triggerToggle(1000);
expect(todosCountText()).toEqual('1,000');
triggerToggle(1000000);
expect(todosCountText()).toEqual('1,000,000');
});
});
})(window.gl);
%ul.nav.nav-sidebar
%li.home.active
%a.dashboard-shortcuts-projects
%span
Projects
%li
%a
%span
Todos
%span.count.js-todos-count
1
%li
%a.dashboard-shortcuts-activity
%span
Activity
%li
%a
%span
Groups
%li
%a
%span
Milestones
%li
%a.dashboard-shortcuts-issues
%span
Issues
%span
1
%li
%a.dashboard-shortcuts-merge_requests
%span
Merge Requests
%li
%a
%span
Snippets
%li
%a
%span
Help
%li
%a
%span
Profile Settings
require('~/sidebar');
(() => {
describe('Project dashboard page', () => {
let $pageWithSidebar = null;
let $sidebarToggle = null;
let sidebar = null;
const fixtureTemplate = 'projects/dashboard.html.raw';
const assertSidebarStateExpanded = (shouldBeExpanded) => {
expect(sidebar.isExpanded).toBe(shouldBeExpanded);
expect($pageWithSidebar.hasClass('page-sidebar-expanded')).toBe(shouldBeExpanded);
};
preloadFixtures(fixtureTemplate);
beforeEach(() => {
loadFixtures(fixtureTemplate);
$pageWithSidebar = $('.page-with-sidebar');
$sidebarToggle = $('.toggle-nav-collapse');
// otherwise instantiating the Sidebar for the second time
// won't do anything, as the Sidebar is a singleton class
gl.Sidebar.singleton = null;
sidebar = new gl.Sidebar();
});
it('can show the sidebar when the toggler is clicked', () => {
assertSidebarStateExpanded(false);
$sidebarToggle.click();
assertSidebarStateExpanded(true);
});
it('should dismiss the sidebar when clone button clicked', () => {
$sidebarToggle.click();
assertSidebarStateExpanded(true);
const cloneButton = $('.project-clone-holder a.clone-dropdown-btn');
cloneButton.click();
assertSidebarStateExpanded(false);
});
it('should dismiss the sidebar when download button clicked', () => {
$sidebarToggle.click();
assertSidebarStateExpanded(true);
const downloadButton = $('.project-action-button .btn:has(i.fa-download)');
downloadButton.click();
assertSidebarStateExpanded(false);
});
it('should dismiss the sidebar when add button clicked', () => {
$sidebarToggle.click();
assertSidebarStateExpanded(true);
const addButton = $('.project-action-button .btn:has(i.fa-plus)');
addButton.click();
assertSidebarStateExpanded(false);
});
it('should dismiss the sidebar when notification button clicked', () => {
$sidebarToggle.click();
assertSidebarStateExpanded(true);
const notifButton = $('.js-notification-toggle-btns .notifications-btn');
notifButton.click();
assertSidebarStateExpanded(false);
});
it('should dismiss the sidebar when clicking on the body', () => {
$sidebarToggle.click();
assertSidebarStateExpanded(true);
$('body').click();
assertSidebarStateExpanded(false);
});
it('should dismiss the sidebar when clicking on the project description header', () => {
$sidebarToggle.click();
assertSidebarStateExpanded(true);
$('.project-home-panel').click();
assertSidebarStateExpanded(false);
});
});
})();
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