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 {
primaryProps() {
return {
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() {
......
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import { s__, sprintf } from '~/locale';
import Tracking from '~/tracking';
import showToast from '~/vue_shared/plugins/global_toast';
const MARKDOWN_LINK_TEXT = {
markdown: '[Link Title](page-slug)',
......@@ -63,6 +64,7 @@ export default class Wikis {
}
Wikis.trackPageView();
Wikis.showToasts();
}
handleWikiTitleChange(e) {
......@@ -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
@page = response.payload[:page]
if response.success?
flash[:toast] = _('Wiki page was successfully updated.')
redirect_to(
wiki_page_path(wiki, page),
notice: _('Wiki was successfully updated.')
wiki_page_path(wiki, page)
)
else
render 'shared/wikis/edit'
......@@ -122,9 +123,10 @@ module WikiActions
@page = response.payload[:page]
if response.success?
flash[:toast] = _('Wiki page was successfully created.')
redirect_to(
wiki_page_path(wiki, page),
notice: _('Wiki was successfully updated.')
wiki_page_path(wiki, page)
)
else
render 'shared/wikis/edit'
......@@ -169,9 +171,10 @@ module WikiActions
response = WikiPages::DestroyService.new(container: container, current_user: current_user).execute(page)
if response.success?
flash[:toast] = _("Wiki page was successfully deleted.")
redirect_to wiki_path(wiki),
status: :found,
notice: _("Page was successfully deleted")
status: :found
else
@error = response
render 'shared/wikis/edit'
......
---
title: Use toasts for wiki notifications
merge_request: 46201
author:
type: changed
......@@ -19281,9 +19281,6 @@ msgstr ""
msgid "Page settings"
msgstr ""
msgid "Page was successfully deleted"
msgstr ""
msgid "PagerDutySettings|Active"
msgstr ""
......@@ -30182,7 +30179,13 @@ msgstr ""
msgid "Wiki"
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 ""
msgid "WikiClone|Clone your wiki"
......
......@@ -17,8 +17,8 @@ RSpec.shared_examples 'User deletes wiki page' do
it 'deletes a page', :js do
click_on('Edit')
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
......@@ -213,11 +213,11 @@ RSpec.shared_examples 'User updates wiki page' do
visit wiki_page_path(wiki_page.wiki, wiki_page, action: :edit)
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'
click_on 'Save changes'
expect(page).to have_content('Wiki was successfully updated.')
expect(page).to have_content('Wiki page was successfully updated.')
end
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
click_on('Create page')
end
expect(page).to have_content('Wiki was successfully updated.')
expect(page).to have_content('Wiki page was successfully created.')
end
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
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(find('.wiki-pages')).to have_content('three')
......@@ -65,7 +65,7 @@ RSpec.shared_examples 'User views a wiki page' do
fill_in('Content', with: 'Updated Wiki Content')
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')
......
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