debian-mirror-gitlab/spec/frontend/oauth_remember_me_spec.js

37 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2023-07-09 08:55:56 +05:30
import htmlOauthRememberMe from 'test_fixtures_static/oauth_remember_me.html';
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
2018-03-17 18:26:18 +05:30
import OAuthRememberMe from '~/pages/sessions/new/oauth_remember_me';
2017-09-10 17:25:29 +05:30
describe('OAuthRememberMe', () => {
2021-03-08 18:12:59 +05:30
const findFormAction = (selector) => {
2021-11-18 22:05:49 +05:30
return $(`#oauth-container .js-oauth-login${selector}`).parent('form').attr('action');
2020-06-23 00:09:42 +05:30
};
2017-09-10 17:25:29 +05:30
beforeEach(() => {
2023-07-09 08:55:56 +05:30
setHTMLFixture(htmlOauthRememberMe);
2017-09-10 17:25:29 +05:30
new OAuthRememberMe({ container: $('#oauth-container') }).bindEvents();
});
2022-07-16 23:28:13 +05:30
afterEach(() => {
resetHTMLFixture();
});
2023-06-20 00:43:36 +05:30
it('adds and removes the "remember_me" query parameter from all OAuth login buttons', () => {
$('#oauth-container #remember_me_omniauth').click();
2017-09-10 17:25:29 +05:30
2020-06-23 00:09:42 +05:30
expect(findFormAction('.twitter')).toBe('http://example.com/?remember_me=1');
expect(findFormAction('.github')).toBe('http://example.com/?remember_me=1');
expect(findFormAction('.facebook')).toBe(
2019-03-02 22:35:43 +05:30
'http://example.com/?redirect_fragment=L1&remember_me=1',
);
2017-09-10 17:25:29 +05:30
2023-06-20 00:43:36 +05:30
$('#oauth-container #remember_me_omniauth').click();
2017-09-10 17:25:29 +05:30
2020-06-23 00:09:42 +05:30
expect(findFormAction('.twitter')).toBe('http://example.com/');
expect(findFormAction('.github')).toBe('http://example.com/');
expect(findFormAction('.facebook')).toBe('http://example.com/?redirect_fragment=L1');
2017-09-10 17:25:29 +05:30
});
});