Commit 581ac8c8 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch 'gitlab-ui-integration-344423-give-toggle-labels-unique-id' into 'master'

GitLab UI integration branch for 344423-give-toggle-labels-unique-id

See merge request gitlab-org/gitlab!73482
parents 7c0d178a a2cf6719
...@@ -103,6 +103,7 @@ export default { ...@@ -103,6 +103,7 @@ export default {
:disabled="isLoading" :disabled="isLoading"
:label="$options.i18n.label" :label="$options.i18n.label"
data-qa-selector="dependency_proxy_setting_toggle" data-qa-selector="dependency_proxy_setting_toggle"
data-testid="dependency-proxy-setting-toggle"
/> />
</div> </div>
</template> </template>
......
...@@ -204,7 +204,7 @@ RSpec.describe 'Epic boards sidebar', :js do ...@@ -204,7 +204,7 @@ RSpec.describe 'Epic boards sidebar', :js do
click_card(card) click_card(card)
page.within('.subscriptions') do page.within('.subscriptions') do
expect(page).to have_button('Notifications') expect(page).to have_selector('[data-testid="subscription-toggle"]')
expect(page).not_to have_content('Disabled by group owner') expect(page).not_to have_content('Disabled by group owner')
end end
end end
...@@ -214,17 +214,19 @@ RSpec.describe 'Epic boards sidebar', :js do ...@@ -214,17 +214,19 @@ RSpec.describe 'Epic boards sidebar', :js do
wait_for_requests wait_for_requests
click_button 'Notifications' subscription_button = find('[data-testid="subscription-toggle"]')
subscription_button.click
wait_for_requests wait_for_requests
expect(page).to have_button('Notifications', class: 'is-checked') expect(subscription_button).to have_css("button.is-checked")
click_button 'Notifications' subscription_button.click
wait_for_requests wait_for_requests
expect(page).not_to have_button('Notifications', class: 'is-checked') expect(subscription_button).to have_css("button:not(.is-checked)")
end end
context 'when notifications have been disabled' do context 'when notifications have been disabled' do
...@@ -236,7 +238,7 @@ RSpec.describe 'Epic boards sidebar', :js do ...@@ -236,7 +238,7 @@ RSpec.describe 'Epic boards sidebar', :js do
it 'displays a message that notifications have been disabled' do it 'displays a message that notifications have been disabled' do
page.within('.subscriptions') do page.within('.subscriptions') do
expect(page).to have_button('Notifications', class: 'is-disabled') expect(page).to have_selector('[data-testid="subscription-toggle"]', class: 'is-disabled')
expect(page).to have_content('Disabled by group owner') expect(page).to have_content('Disabled by group owner')
end end
end end
......
...@@ -56,9 +56,14 @@ RSpec.describe 'Group Dependency Proxy' do ...@@ -56,9 +56,14 @@ RSpec.describe 'Group Dependency Proxy' do
visit settings_path visit settings_path
wait_for_requests wait_for_requests
click_button 'Enable Proxy' proxy_toggle = find('[data-testid="dependency-proxy-setting-toggle"]')
proxy_toggle_button = proxy_toggle.find('button')
expect(page).to have_button 'Enable Proxy', class: '!is-checked' expect(proxy_toggle).to have_css("button.is-checked")
proxy_toggle_button.click
expect(proxy_toggle).not_to have_css("button.is-checked")
visit path visit path
......
...@@ -45,7 +45,7 @@ RSpec.describe "User toggles subscription", :js do ...@@ -45,7 +45,7 @@ RSpec.describe "User toggles subscription", :js do
it 'is disabled' do it 'is disabled' do
expect(page).to have_content('Disabled by project owner') expect(page).to have_content('Disabled by project owner')
expect(page).to have_button('Notifications', class: 'is-disabled') expect(page).to have_selector('[data-testid="subscription-toggle"]', class: 'is-disabled')
end end
end end
end end
......
...@@ -19,7 +19,7 @@ RSpec.describe 'Projects > Settings > Packages', :js do ...@@ -19,7 +19,7 @@ RSpec.describe 'Projects > Settings > Packages', :js do
let(:packages_enabled) { true } let(:packages_enabled) { true }
it 'displays the packages toggle button' do it 'displays the packages toggle button' do
expect(page).to have_button('Packages', class: 'gl-toggle') expect(page).to have_selector('[data-testid="toggle-label"]', text: 'Packages')
expect(page).to have_selector('input[name="project[packages_enabled]"] + button', visible: true) expect(page).to have_selector('input[name="project[packages_enabled]"] + button', visible: true)
end end
end end
...@@ -28,7 +28,7 @@ RSpec.describe 'Projects > Settings > Packages', :js do ...@@ -28,7 +28,7 @@ RSpec.describe 'Projects > Settings > Packages', :js do
let(:packages_enabled) { false } let(:packages_enabled) { false }
it 'does not show up in UI' do it 'does not show up in UI' do
expect(page).not_to have_button('Packages', class: 'gl-toggle') expect(page).not_to have_selector('[data-testid="toggle-label"]', text: 'Packages')
end end
end end
end end
...@@ -58,7 +58,6 @@ describe('AlertsSettingsForm', () => { ...@@ -58,7 +58,6 @@ describe('AlertsSettingsForm', () => {
afterEach(() => { afterEach(() => {
if (wrapper) { if (wrapper) {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
} }
}); });
...@@ -69,7 +68,7 @@ describe('AlertsSettingsForm', () => { ...@@ -69,7 +68,7 @@ describe('AlertsSettingsForm', () => {
const enableIntegration = (index, value) => { const enableIntegration = (index, value) => {
findFormFields().at(index).setValue(value); findFormFields().at(index).setValue(value);
findFormToggle().trigger('click'); findFormToggle().vm.$emit('change', true);
}; };
describe('with default values', () => { describe('with default values', () => {
......
...@@ -14,8 +14,8 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () = ...@@ -14,8 +14,8 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () =
let store; let store;
const findNotificationHeader = () => wrapper.find("[data-testid='notification-header-text']"); const findNotificationHeader = () => wrapper.find("[data-testid='notification-header-text']");
const findToggle = () => wrapper.find(GlToggle); const findToggle = () => wrapper.findComponent(GlToggle);
const findGlLoadingIcon = () => wrapper.find(GlLoadingIcon); const findGlLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const createComponent = (activeBoardItem = { ...mockActiveIssue }) => { const createComponent = (activeBoardItem = { ...mockActiveIssue }) => {
store = createStore(); store = createStore();
...@@ -32,7 +32,6 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () = ...@@ -32,7 +32,6 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () =
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
store = null; store = null;
jest.clearAllMocks(); jest.clearAllMocks();
}); });
...@@ -104,7 +103,7 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () = ...@@ -104,7 +103,7 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () =
expect(findGlLoadingIcon().exists()).toBe(false); expect(findGlLoadingIcon().exists()).toBe(false);
findToggle().trigger('click'); findToggle().vm.$emit('change');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
...@@ -129,7 +128,7 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () = ...@@ -129,7 +128,7 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () =
expect(findGlLoadingIcon().exists()).toBe(false); expect(findGlLoadingIcon().exists()).toBe(false);
findToggle().trigger('click'); findToggle().vm.$emit('change');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
...@@ -152,7 +151,7 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () = ...@@ -152,7 +151,7 @@ describe('~/boards/components/sidebar/board_sidebar_subscription_spec.vue', () =
}); });
jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {}); jest.spyOn(wrapper.vm, 'setError').mockImplementation(() => {});
findToggle().trigger('click'); findToggle().vm.$emit('change');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(wrapper.vm.setError).toHaveBeenCalled(); expect(wrapper.vm.setError).toHaveBeenCalled();
......
...@@ -327,7 +327,7 @@ describe('Pipeline graph wrapper', () => { ...@@ -327,7 +327,7 @@ describe('Pipeline graph wrapper', () => {
expect(getLinksLayer().exists()).toBe(true); expect(getLinksLayer().exists()).toBe(true);
expect(getLinksLayer().props('showLinks')).toBe(false); expect(getLinksLayer().props('showLinks')).toBe(false);
expect(getViewSelector().props('type')).toBe(LAYER_VIEW); expect(getViewSelector().props('type')).toBe(LAYER_VIEW);
await getDependenciesToggle().trigger('click'); await getDependenciesToggle().vm.$emit('change', true);
jest.runOnlyPendingTimers(); jest.runOnlyPendingTimers();
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(wrapper.findComponent(LinksLayer).props('showLinks')).toBe(true); expect(wrapper.findComponent(LinksLayer).props('showLinks')).toBe(true);
......
...@@ -111,7 +111,7 @@ describe('the graph view selector component', () => { ...@@ -111,7 +111,7 @@ describe('the graph view selector component', () => {
expect(wrapper.emitted().updateShowLinksState).toBeUndefined(); expect(wrapper.emitted().updateShowLinksState).toBeUndefined();
expect(findToggleLoader().exists()).toBe(false); expect(findToggleLoader().exists()).toBe(false);
await findDependenciesToggle().trigger('click'); await findDependenciesToggle().vm.$emit('change', true);
/* /*
Loading happens before the event is emitted or timers are run. Loading happens before the event is emitted or timers are run.
Then we run the timer because the event is emitted in setInterval Then we run the timer because the event is emitted in setInterval
......
...@@ -52,16 +52,17 @@ RSpec.shared_examples 'issue boards sidebar' do ...@@ -52,16 +52,17 @@ RSpec.shared_examples 'issue boards sidebar' do
it 'shows toggle as on then as off as user toggles to subscribe and unsubscribe', :aggregate_failures do it 'shows toggle as on then as off as user toggles to subscribe and unsubscribe', :aggregate_failures do
wait_for_requests wait_for_requests
subscription_button = find('[data-testid="subscription-toggle"]')
click_button 'Notifications' subscription_button.click
expect(page).to have_button('Notifications', class: 'is-checked') expect(subscription_button).to have_css("button.is-checked")
click_button 'Notifications' subscription_button.click
wait_for_requests wait_for_requests
expect(page).not_to have_button('Notifications', class: 'is-checked') expect(subscription_button).to have_css("button:not(.is-checked)")
end end
context 'when notifications have been disabled' do context 'when notifications have been disabled' do
...@@ -73,7 +74,7 @@ RSpec.shared_examples 'issue boards sidebar' do ...@@ -73,7 +74,7 @@ RSpec.shared_examples 'issue boards sidebar' do
it 'displays a message that notifications have been disabled' do it 'displays a message that notifications have been disabled' do
page.within('[data-testid="sidebar-notifications"]') do page.within('[data-testid="sidebar-notifications"]') do
expect(page).to have_button('Notifications', class: 'is-disabled') expect(page).to have_selector('[data-testid="subscription-toggle"]', class: 'is-disabled')
expect(page).to have_content('Disabled by project owner') expect(page).to have_content('Disabled by project owner')
end end
end end
......
...@@ -914,10 +914,10 @@ ...@@ -914,10 +914,10 @@
resolved "https://registry.yarnpkg.com/@gitlab/tributejs/-/tributejs-1.0.0.tgz#672befa222aeffc83e7d799b0500a7a4418e59b8" resolved "https://registry.yarnpkg.com/@gitlab/tributejs/-/tributejs-1.0.0.tgz#672befa222aeffc83e7d799b0500a7a4418e59b8"
integrity sha512-nmKw1+hB6MHvlmPz63yPwVs1qQkycHwsKgxpEbzmky16Y6mL4EJMk3w1b8QlOAF/AIAzjCERPhe/R4MJiohbZw== integrity sha512-nmKw1+hB6MHvlmPz63yPwVs1qQkycHwsKgxpEbzmky16Y6mL4EJMk3w1b8QlOAF/AIAzjCERPhe/R4MJiohbZw==
"@gitlab/ui@32.28.0": "@gitlab/ui@32.31.0":
version "32.28.0" version "32.31.0"
resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-32.28.0.tgz#afa0e1dee66ec438126b2706e0860e2c622fc867" resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-32.31.0.tgz#e379f79f0797c98d67e121739add8dec8281a5d4"
integrity sha512-DudY+jPIxjGymyB2KgdexmxV+sbjCy3or7LzviiI0jb5jCIiqNoZ4F4G+P0T+Z1FbLBgEXjgUaEZw09edka/lg== integrity sha512-a/03Jgh3TJx0W1lJjsYZiAKbRQHGvomrGhzDvBpxKve2FXrYdo4G6gbwlIKJGiooB5YmZ5OIWhgnhQ8FSy15Aw==
dependencies: dependencies:
"@babel/standalone" "^7.0.0" "@babel/standalone" "^7.0.0"
bootstrap-vue "2.20.1" bootstrap-vue "2.20.1"
......
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