Commit 337f2c44 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'tz-fix-snippet-display-js-error' into 'master'

Fixes a JS error on Private snippets as there is no share or embed button

See merge request gitlab-org/gitlab!18380
parents 549252cc 402bc003
import { __ } from '~/locale';
export default () => {
const { protocol, host, pathname } = window.location;
const shareBtn = document.querySelector('.js-share-btn');
if (shareBtn) {
const { protocol, host, pathname } = window.location;
const embedBtn = document.querySelector('.js-embed-btn');
const snippetUrlArea = document.querySelector('.js-snippet-url-area');
const embedAction = document.querySelector('.js-embed-action');
const url = `${protocol}//${host + pathname}`;
......@@ -22,4 +26,5 @@ export default () => {
snippetUrlArea.value = scriptTag;
embedAction.innerText = __('Embed');
});
}
};
# frozen_string_literal: true
require 'spec_helper'
describe 'Private Snippets', :js do
let(:user) { create(:user) }
before do
sign_in(user)
end
it 'Private Snippet renders for creator' do
private_snippet = create(:personal_snippet, :private, author: user)
visit snippet_path(private_snippet)
wait_for_requests
expect(page).to have_content(private_snippet.content)
expect(page).not_to have_css('.js-embed-btn')
expect(page).not_to have_css('.js-share-btn')
end
end
......@@ -10,6 +10,8 @@ describe 'Public Snippets', :js do
wait_for_requests
expect(page).to have_content(public_snippet.content)
expect(page).to have_css('.js-embed-btn', visible: false)
expect(page).to have_css('.js-share-btn', visible: false)
end
it 'Unauthenticated user should see raw public snippets' do
......
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