Commit e40aa397 authored by Clement Ho's avatar Clement Ho

Merge branch 'sh-fallback-to-first-tab-signin' into 'master'

Fall back to the first sign-in tab if the local storage value is bad

See merge request gitlab-org/gitlab-ce!20050
parents d67590bc 8af62a64
......@@ -37,6 +37,11 @@ export default class SigninTabsMemoizer {
const tab = document.querySelector(`${this.tabSelector} a[href="${anchorName}"]`);
if (tab) {
tab.click();
} else {
const firstTab = document.querySelector(`${this.tabSelector} a`);
if (firstTab) {
firstTab.click();
}
}
}
}
......
......@@ -45,6 +45,21 @@ import SigninTabsMemoizer from '~/pages/sessions/new/signin_tabs_memoizer';
expect(fakeTab.click).toHaveBeenCalled();
});
it('clicks the first tab if value in local storage is bad', () => {
createMemoizer().saveData('#bogus');
const fakeTab = {
click: () => {},
};
spyOn(document, 'querySelector').and.callFake(selector => (selector === `${tabSelector} a[href="#bogus"]` ? null : fakeTab));
spyOn(fakeTab, 'click');
memo.bootstrap();
// verify that triggers click on stored selector and fallback
expect(document.querySelector.calls.allArgs()).toEqual([['ul.new-session-tabs a[href="#bogus"]'], ['ul.new-session-tabs a']]);
expect(fakeTab.click).toHaveBeenCalled();
});
it('saves last selected tab on change', () => {
createMemoizer();
......
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