diff options
author | Stan Hu <stanhu@gmail.com> | 2018-06-21 00:18:45 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-06-21 00:18:45 +0300 |
commit | 8af62a64c4e7cae9d62e13e1c026948f02675bfa (patch) | |
tree | d667876df67db9a276e33a45fdd01c54a48a555f /spec/javascripts/signin_tabs_memoizer_spec.js | |
parent | a88a9e22c5f27b458593d08ee9dce5a834c51f2a (diff) |
Fall back to the first sign-in tab if the local storage value is bad
If `current_signin_tab` is `#crowd`, then no tab will be active. Fix
this by using the first available tab.
Relates to https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20049#note_82996324
Diffstat (limited to 'spec/javascripts/signin_tabs_memoizer_spec.js')
-rw-r--r-- | spec/javascripts/signin_tabs_memoizer_spec.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/javascripts/signin_tabs_memoizer_spec.js b/spec/javascripts/signin_tabs_memoizer_spec.js index 423432c9e5d..9d3905fa1d8 100644 --- a/spec/javascripts/signin_tabs_memoizer_spec.js +++ b/spec/javascripts/signin_tabs_memoizer_spec.js @@ -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(); |