diff options
author | Fatih Acet <acetfatih@gmail.com> | 2016-12-09 09:17:41 +0000 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-12-09 09:17:41 +0000 |
commit | 1413c94a8e0ac3abb809724f4f49919afaca2d59 (patch) | |
tree | 94c33915926de4040623564f28298d6595937f75 /spec | |
parent | ab04e6c8cd43b6c5ca8e28e3c83acd3a610baaee (diff) | |
parent | 8235f8301571a9b55a14b94b2ed687e53cbc2f4e (diff) | |
download | gitlab-ce-1413c94a8e0ac3abb809724f4f49919afaca2d59.tar.gz |
Merge branch '15081-wrong-login-tab-ldap-frontend' into 'master'
Fixed Wrong Tab Selected When Loggin Fails And Multiple Login Tabs Exists
## What does this MR do?
Fixes issue: 15081 Wrong Tab Selected When Loggin Fails And Multiple Login Tabs Exists
This is done by saving into a cookie when the active tab changes and by always selecting that tab when the page is loaded.
## Are there points in the code the reviewer needs to double check?
No
## Why was this MR needed?
In order to fix the issue: 15081
## Screenshots (if relevant)
## Does this MR meet the acceptance criteria?
- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- Tests
- [x] Added for this feature/bug
- [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
## What are the relevant issue numbers?
Closes #15081
See merge request !7314
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/fixtures/signin_tabs.html.haml | 5 | ||||
-rw-r--r-- | spec/javascripts/signin_tabs_memoizer_spec.js.es6 | 53 |
2 files changed, 58 insertions, 0 deletions
diff --git a/spec/javascripts/fixtures/signin_tabs.html.haml b/spec/javascripts/fixtures/signin_tabs.html.haml new file mode 100644 index 00000000000..12b8d423cbe --- /dev/null +++ b/spec/javascripts/fixtures/signin_tabs.html.haml @@ -0,0 +1,5 @@ +%ul.nav-tabs + %li + %a.active{ id: 'standard', href: '#standard'} Standard + %li + %a{ id: 'ldap', href: '#ldap'} Ldap diff --git a/spec/javascripts/signin_tabs_memoizer_spec.js.es6 b/spec/javascripts/signin_tabs_memoizer_spec.js.es6 new file mode 100644 index 00000000000..9a9fb22255b --- /dev/null +++ b/spec/javascripts/signin_tabs_memoizer_spec.js.es6 @@ -0,0 +1,53 @@ +/*= require signin_tabs_memoizer */ + +((global) => { + describe('SigninTabsMemoizer', () => { + const fixtureTemplate = 'signin_tabs.html'; + const tabSelector = 'ul.nav-tabs'; + const currentTabKey = 'current_signin_tab'; + let memo; + + function createMemoizer() { + memo = new global.ActiveTabMemoizer({ + currentTabKey, + tabSelector, + }); + return memo; + } + + fixture.preload(fixtureTemplate); + + beforeEach(() => { + fixture.load(fixtureTemplate); + }); + + it('does nothing if no tab was previously selected', () => { + createMemoizer(); + + expect(document.querySelector('li a.active').getAttribute('id')).toEqual('standard'); + }); + + it('shows last selected tab on boot', () => { + createMemoizer().saveData('#ldap'); + const fakeTab = { + click: () => {}, + }; + spyOn(document, 'querySelector').and.returnValue(fakeTab); + spyOn(fakeTab, 'click'); + + memo.bootstrap(); + + // verify that triggers click on the last selected tab + expect(document.querySelector).toHaveBeenCalledWith(`${tabSelector} a[href="#ldap"]`); + expect(fakeTab.click).toHaveBeenCalled(); + }); + + it('saves last selected tab on change', () => { + createMemoizer(); + + document.getElementById('standard').click(); + + expect(memo.readData()).toEqual('#standard'); + }); + }); +})(window); |