diff options
Diffstat (limited to 'spec')
6 files changed, 179 insertions, 12 deletions
diff --git a/spec/features/projects/pages/user_edits_lets_encrypt_settings_spec.rb b/spec/features/projects/pages/user_edits_lets_encrypt_settings_spec.rb index a7da59200e9..16e64ade665 100644 --- a/spec/features/projects/pages/user_edits_lets_encrypt_settings_spec.rb +++ b/spec/features/projects/pages/user_edits_lets_encrypt_settings_spec.rb @@ -48,13 +48,13 @@ RSpec.describe "Pages with Let's Encrypt", :https_pages_enabled, feature_categor expect(domain.auto_ssl_enabled).to eq false expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'false' - expect(page).to have_selector '.card-header', text: 'Certificate' + expect(page).to have_selector '.gl-card-header', text: 'Certificate' expect(page).to have_text domain.subject find('.js-auto-ssl-toggle-container .js-project-feature-toggle button').click expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'true' - expect(page).not_to have_selector '.card-header', text: 'Certificate' + expect(page).not_to have_selector '.gl-card-header', text: 'Certificate' expect(page).not_to have_text domain.subject click_on 'Save Changes' @@ -108,7 +108,7 @@ RSpec.describe "Pages with Let's Encrypt", :https_pages_enabled, feature_categor it 'user do not see private key' do visit project_pages_domain_path(project, domain) - expect(page).not_to have_selector '.card-header', text: 'Certificate' + expect(page).not_to have_selector '.gl-card-header', text: 'Certificate' expect(page).not_to have_text domain.subject end end @@ -131,16 +131,16 @@ RSpec.describe "Pages with Let's Encrypt", :https_pages_enabled, feature_categor it 'user sees certificate subject' do visit project_pages_domain_path(project, domain) - expect(page).to have_selector '.card-header', text: 'Certificate' + expect(page).to have_selector '.gl-card-header', text: 'Certificate' expect(page).to have_text domain.subject end it 'user can delete the certificate', :js do visit project_pages_domain_path(project, domain) - expect(page).to have_selector '.card-header', text: 'Certificate' + expect(page).to have_selector '.gl-card-header', text: 'Certificate' expect(page).to have_text domain.subject - within('.card') { click_on 'Remove' } + within('.gl-card') { click_on 'Remove' } accept_gl_confirm(button_text: 'Remove certificate') expect(page).to have_field 'Certificate (PEM)', with: '' expect(page).to have_field 'Key (PEM)', with: '' diff --git a/spec/frontend/boards/mock_data.js b/spec/frontend/boards/mock_data.js index 1d011eacf1c..0f58d7cf9fa 100644 --- a/spec/frontend/boards/mock_data.js +++ b/spec/frontend/boards/mock_data.js @@ -477,6 +477,9 @@ export const mockList = { loading: false, issuesCount: 1, maxIssueCount: 0, + metadata: { + epicsCount: 1, + }, __typename: 'BoardList', }; diff --git a/spec/frontend/super_sidebar/components/super_sidebar_spec.js b/spec/frontend/super_sidebar/components/super_sidebar_spec.js index 57c84bc87a6..32921da23aa 100644 --- a/spec/frontend/super_sidebar/components/super_sidebar_spec.js +++ b/spec/frontend/super_sidebar/components/super_sidebar_spec.js @@ -3,11 +3,17 @@ import SuperSidebar from '~/super_sidebar/components/super_sidebar.vue'; import HelpCenter from '~/super_sidebar/components/help_center.vue'; import UserBar from '~/super_sidebar/components/user_bar.vue'; import SidebarPortalTarget from '~/super_sidebar/components/sidebar_portal_target.vue'; +import { isCollapsed } from '~/super_sidebar/super_sidebar_collapsed_state_manager'; import { sidebarData } from '../mock_data'; +jest.mock('~/super_sidebar/super_sidebar_collapsed_state_manager', () => ({ + isCollapsed: jest.fn(), +})); + describe('SuperSidebar component', () => { let wrapper; + const findSidebar = () => wrapper.find('.super-sidebar'); const findUserBar = () => wrapper.findComponent(UserBar); const findHelpCenter = () => wrapper.findComponent(HelpCenter); const findSidebarPortalTarget = () => wrapper.findComponent(SidebarPortalTarget); @@ -22,19 +28,32 @@ describe('SuperSidebar component', () => { }; describe('default', () => { - beforeEach(() => { + it('add aria-hidden and inert attributes when collapsed', () => { + isCollapsed.mockReturnValue(true); + createWrapper(); + expect(findSidebar().attributes('aria-hidden')).toBe('true'); + expect(findSidebar().attributes('inert')).toBe('inert'); + }); + + it('does not add aria-hidden and inert attributes when expanded', () => { + isCollapsed.mockReturnValue(false); createWrapper(); + expect(findSidebar().attributes('aria-hidden')).toBe('false'); + expect(findSidebar().attributes('inert')).toBe(undefined); }); it('renders UserBar with sidebarData', () => { + createWrapper(); expect(findUserBar().props('sidebarData')).toBe(sidebarData); }); it('renders HelpCenter with sidebarData', () => { + createWrapper(); expect(findHelpCenter().props('sidebarData')).toBe(sidebarData); }); it('renders SidebarPortalTarget', () => { + createWrapper(); expect(findSidebarPortalTarget().exists()).toBe(true); }); }); diff --git a/spec/frontend/super_sidebar/super_sidebar_collapsed_state_manager_spec.js b/spec/frontend/super_sidebar/super_sidebar_collapsed_state_manager_spec.js new file mode 100644 index 00000000000..27fa451cf7b --- /dev/null +++ b/spec/frontend/super_sidebar/super_sidebar_collapsed_state_manager_spec.js @@ -0,0 +1,132 @@ +import { GlBreakpointInstance as bp, breakpoints } from '@gitlab/ui/dist/utils'; +import { getCookie, setCookie } from '~/lib/utils/common_utils'; +import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; +import { + SIDEBAR_COLLAPSED_CLASS, + SIDEBAR_COLLAPSED_COOKIE, + SIDEBAR_COLLAPSED_COOKIE_EXPIRATION, + toggleSuperSidebarCollapsed, + initSuperSidebarCollapsedState, + bindSuperSidebarCollapsedEvents, + findPage, + findSidebar, + findToggles, +} from '~/super_sidebar/super_sidebar_collapsed_state_manager'; + +const { xl, sm } = breakpoints; + +jest.mock('~/lib/utils/common_utils', () => ({ + getCookie: jest.fn(), + setCookie: jest.fn(), +})); + +const pageHasCollapsedClass = (hasClass) => { + if (hasClass) { + expect(findPage().classList).toContain(SIDEBAR_COLLAPSED_CLASS); + } else { + expect(findPage().classList).not.toContain(SIDEBAR_COLLAPSED_CLASS); + } +}; + +describe('Super Sidebar Collapsed State Manager', () => { + beforeEach(() => { + setHTMLFixture(` + <button class="js-super-sidebar-toggle"></button> + <div class="page-with-super-sidebar"></div> + <aside class="super-sidebar"></aside> + `); + }); + + afterEach(() => { + resetHTMLFixture(); + }); + + describe('toggleSuperSidebarCollapsed', () => { + it.each` + collapsed | saveCookie | windowWidth | hasClass + ${true} | ${true} | ${xl} | ${true} + ${true} | ${false} | ${xl} | ${true} + ${true} | ${true} | ${sm} | ${true} + ${true} | ${false} | ${sm} | ${true} + ${false} | ${true} | ${xl} | ${false} + ${false} | ${false} | ${xl} | ${false} + ${false} | ${true} | ${sm} | ${false} + ${false} | ${false} | ${sm} | ${false} + `( + 'when collapsed is $collapsed, saveCookie is $saveCookie, and windowWidth is $windowWidth then page class contains `page-with-super-sidebar-collapsed` is $hasClass', + ({ collapsed, saveCookie, windowWidth, hasClass }) => { + jest.spyOn(bp, 'windowWidth').mockReturnValue(windowWidth); + + toggleSuperSidebarCollapsed(collapsed, saveCookie); + + pageHasCollapsedClass(hasClass); + expect(findSidebar().ariaHidden).toBe(collapsed); + expect(findSidebar().inert).toBe(collapsed); + + if (saveCookie && windowWidth >= xl) { + expect(setCookie).toHaveBeenCalledWith(SIDEBAR_COLLAPSED_COOKIE, collapsed, { + expires: SIDEBAR_COLLAPSED_COOKIE_EXPIRATION, + }); + } else { + expect(setCookie).not.toHaveBeenCalled(); + } + }, + ); + }); + + describe('initSuperSidebarCollapsedState', () => { + it.each` + windowWidth | cookie | hasClass + ${xl} | ${undefined} | ${false} + ${sm} | ${undefined} | ${true} + ${xl} | ${'true'} | ${true} + ${sm} | ${'true'} | ${true} + `( + 'sets page class to `page-with-super-sidebar-collapsed` when windowWidth is $windowWidth and cookie value is $cookie', + ({ windowWidth, cookie, hasClass }) => { + jest.spyOn(bp, 'windowWidth').mockReturnValue(windowWidth); + getCookie.mockReturnValue(cookie); + + initSuperSidebarCollapsedState(); + + pageHasCollapsedClass(hasClass); + expect(setCookie).not.toHaveBeenCalled(); + }, + ); + }); + + describe('bindSuperSidebarCollapsedEvents', () => { + it.each` + windowWidth | cookie | hasClass + ${xl} | ${undefined} | ${true} + ${sm} | ${undefined} | ${true} + ${xl} | ${'true'} | ${false} + ${sm} | ${'true'} | ${false} + `( + 'toggle click sets page class to `page-with-super-sidebar-collapsed` when windowWidth is $windowWidth and cookie value is $cookie', + ({ windowWidth, cookie, hasClass }) => { + setHTMLFixture(` + <button class="js-super-sidebar-toggle"></button> + <div class="page-with-super-sidebar ${cookie ? SIDEBAR_COLLAPSED_CLASS : ''}"></div> + <aside class="super-sidebar"></aside> + `); + jest.spyOn(bp, 'windowWidth').mockReturnValue(windowWidth); + getCookie.mockReturnValue(cookie); + + bindSuperSidebarCollapsedEvents(); + + findToggles()[0].click(); + + pageHasCollapsedClass(hasClass); + + if (windowWidth >= xl) { + expect(setCookie).toHaveBeenCalledWith(SIDEBAR_COLLAPSED_COOKIE, !cookie, { + expires: SIDEBAR_COLLAPSED_COOKIE_EXPIRATION, + }); + } else { + expect(setCookie).not.toHaveBeenCalled(); + } + }, + ); + }); +}); diff --git a/spec/services/jira_connect_installations/proxy_lifecycle_event_service_spec.rb b/spec/services/jira_connect_installations/proxy_lifecycle_event_service_spec.rb index c621388a734..3c144de2208 100644 --- a/spec/services/jira_connect_installations/proxy_lifecycle_event_service_spec.rb +++ b/spec/services/jira_connect_installations/proxy_lifecycle_event_service_spec.rb @@ -94,9 +94,9 @@ RSpec.describe JiraConnectInstallations::ProxyLifecycleEventService, feature_cat expect(Gitlab::IntegrationsLogger).to receive(:info).with( integration: 'JiraConnect', message: 'Proxy lifecycle event received error response', - event_type: evnet_type, - status_code: 422, - body: 'Error message' + jira_event_type: evnet_type, + jira_status_code: 422, + jira_body: 'Error message' ) execute_service diff --git a/spec/views/devise/confirmations/almost_there.html.haml_spec.rb b/spec/views/devise/confirmations/almost_there.html.haml_spec.rb index c091efe9295..8e12fb5a17e 100644 --- a/spec/views/devise/confirmations/almost_there.html.haml_spec.rb +++ b/spec/views/devise/confirmations/almost_there.html.haml_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' RSpec.describe 'devise/confirmations/almost_there' do - describe 'confirmations text' do - subject { render(template: 'devise/confirmations/almost_there') } + subject { render(template: 'devise/confirmations/almost_there') } + describe 'confirmations text' do before do allow(view).to receive(:params).and_return(email: email) end @@ -34,4 +34,17 @@ RSpec.describe 'devise/confirmations/almost_there' do end end end + + describe 'register again prompt' do + specify do + subject + + expect(rendered).to have_content( + 'If the email address is incorrect, you can register again with a different email' + ) + expect(rendered).to have_link( + 'register again with a different email', href: new_user_registration_path + ) + end + end end |