Commit bd042d31 authored by Tom Quirk's avatar Tom Quirk Committed by Phil Hughes

Fix wiki specs

Adds :js to support toasts in tests
parent 43290d0d
...@@ -41,7 +41,11 @@ export default { ...@@ -41,7 +41,11 @@ export default {
primaryProps() { primaryProps() {
return { return {
text: this.$options.i18n.deletePageText, text: this.$options.i18n.deletePageText,
attributes: { variant: 'danger', 'data-qa-selector': 'confirm_deletion_button' }, attributes: {
variant: 'danger',
'data-qa-selector': 'confirm_deletion_button',
'data-testid': 'confirm_deletion_button',
},
}; };
}, },
cancelProps() { cancelProps() {
......
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import showToast from '~/vue_shared/plugins/global_toast';
const MARKDOWN_LINK_TEXT = { const MARKDOWN_LINK_TEXT = {
markdown: '[Link Title](page-slug)', markdown: '[Link Title](page-slug)',
...@@ -63,6 +64,7 @@ export default class Wikis { ...@@ -63,6 +64,7 @@ export default class Wikis {
} }
Wikis.trackPageView(); Wikis.trackPageView();
Wikis.showToasts();
} }
handleWikiTitleChange(e) { handleWikiTitleChange(e) {
...@@ -116,4 +118,9 @@ export default class Wikis { ...@@ -116,4 +118,9 @@ export default class Wikis {
}, },
}); });
} }
static showToasts() {
const toasts = document.querySelectorAll('.js-toast-message');
toasts.forEach(toast => showToast(toast.dataset.message));
}
} }
...@@ -103,9 +103,10 @@ module WikiActions ...@@ -103,9 +103,10 @@ module WikiActions
@page = response.payload[:page] @page = response.payload[:page]
if response.success? if response.success?
flash[:toast] = _('Wiki page was successfully updated.')
redirect_to( redirect_to(
wiki_page_path(wiki, page), wiki_page_path(wiki, page)
notice: _('Wiki was successfully updated.')
) )
else else
render 'shared/wikis/edit' render 'shared/wikis/edit'
...@@ -122,9 +123,10 @@ module WikiActions ...@@ -122,9 +123,10 @@ module WikiActions
@page = response.payload[:page] @page = response.payload[:page]
if response.success? if response.success?
flash[:toast] = _('Wiki page was successfully created.')
redirect_to( redirect_to(
wiki_page_path(wiki, page), wiki_page_path(wiki, page)
notice: _('Wiki was successfully updated.')
) )
else else
render 'shared/wikis/edit' render 'shared/wikis/edit'
...@@ -169,9 +171,10 @@ module WikiActions ...@@ -169,9 +171,10 @@ module WikiActions
response = WikiPages::DestroyService.new(container: container, current_user: current_user).execute(page) response = WikiPages::DestroyService.new(container: container, current_user: current_user).execute(page)
if response.success? if response.success?
flash[:toast] = _("Wiki page was successfully deleted.")
redirect_to wiki_path(wiki), redirect_to wiki_path(wiki),
status: :found, status: :found
notice: _("Page was successfully deleted")
else else
@error = response @error = response
render 'shared/wikis/edit' render 'shared/wikis/edit'
......
---
title: Use toasts for wiki notifications
merge_request: 46201
author:
type: changed
...@@ -19281,9 +19281,6 @@ msgstr "" ...@@ -19281,9 +19281,6 @@ msgstr ""
msgid "Page settings" msgid "Page settings"
msgstr "" msgstr ""
msgid "Page was successfully deleted"
msgstr ""
msgid "PagerDutySettings|Active" msgid "PagerDutySettings|Active"
msgstr "" msgstr ""
...@@ -30182,7 +30179,13 @@ msgstr "" ...@@ -30182,7 +30179,13 @@ msgstr ""
msgid "Wiki" msgid "Wiki"
msgstr "" msgstr ""
msgid "Wiki was successfully updated." msgid "Wiki page was successfully created."
msgstr ""
msgid "Wiki page was successfully deleted."
msgstr ""
msgid "Wiki page was successfully updated."
msgstr "" msgstr ""
msgid "WikiClone|Clone your wiki" msgid "WikiClone|Clone your wiki"
......
...@@ -17,8 +17,8 @@ RSpec.shared_examples 'User deletes wiki page' do ...@@ -17,8 +17,8 @@ RSpec.shared_examples 'User deletes wiki page' do
it 'deletes a page', :js do it 'deletes a page', :js do
click_on('Edit') click_on('Edit')
click_on('Delete') click_on('Delete')
find('.modal-footer .btn-danger').click find('[data-testid="confirm_deletion_button"]').click
expect(page).to have_content('Page was successfully deleted') expect(page).to have_content('Wiki page was successfully deleted.')
end end
end end
...@@ -213,11 +213,11 @@ RSpec.shared_examples 'User updates wiki page' do ...@@ -213,11 +213,11 @@ RSpec.shared_examples 'User updates wiki page' do
visit wiki_page_path(wiki_page.wiki, wiki_page, action: :edit) visit wiki_page_path(wiki_page.wiki, wiki_page, action: :edit)
end end
it 'allows changing the title if the content does not change' do it 'allows changing the title if the content does not change', :js do
fill_in 'Title', with: 'new title' fill_in 'Title', with: 'new title'
click_on 'Save changes' click_on 'Save changes'
expect(page).to have_content('Wiki was successfully updated.') expect(page).to have_content('Wiki page was successfully updated.')
end end
it 'shows a validation error when trying to change the content' do it 'shows a validation error when trying to change the content' do
......
...@@ -33,7 +33,7 @@ RSpec.shared_examples 'User views a wiki page' do ...@@ -33,7 +33,7 @@ RSpec.shared_examples 'User views a wiki page' do
click_on('Create page') click_on('Create page')
end end
expect(page).to have_content('Wiki was successfully updated.') expect(page).to have_content('Wiki page was successfully created.')
end end
it 'shows the history of a page that has a path' do it 'shows the history of a page that has a path' do
...@@ -49,7 +49,7 @@ RSpec.shared_examples 'User views a wiki page' do ...@@ -49,7 +49,7 @@ RSpec.shared_examples 'User views a wiki page' do
end end
end end
it 'shows an old version of a page' do it 'shows an old version of a page', :js do
expect(current_path).to include('one/two/three-test') expect(current_path).to include('one/two/three-test')
expect(find('.wiki-pages')).to have_content('three') expect(find('.wiki-pages')).to have_content('three')
...@@ -65,7 +65,7 @@ RSpec.shared_examples 'User views a wiki page' do ...@@ -65,7 +65,7 @@ RSpec.shared_examples 'User views a wiki page' do
fill_in('Content', with: 'Updated Wiki Content') fill_in('Content', with: 'Updated Wiki Content')
click_on('Save changes') click_on('Save changes')
expect(page).to have_content('Wiki was successfully updated.') expect(page).to have_content('Wiki page was successfully updated.')
click_on('Page history') click_on('Page history')
......
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