2022-03-02 08:16:31 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'Sandboxed Mermaid rendering', :js, feature_category: :team_planning do
|
2023-01-13 00:05:48 +05:30
|
|
|
let_it_be(:project) { create(:project, :public, :repository) }
|
|
|
|
let_it_be(:description) do
|
|
|
|
<<~MERMAID
|
|
|
|
```mermaid
|
|
|
|
graph TD;
|
|
|
|
A-->B;
|
|
|
|
A-->C;
|
|
|
|
B-->D;
|
|
|
|
C-->D;
|
|
|
|
```
|
|
|
|
MERMAID
|
|
|
|
end
|
2022-03-02 08:16:31 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
let_it_be(:expected) do
|
|
|
|
%(<iframe src="/-/sandbox/mermaid" sandbox="allow-scripts allow-popups" frameborder="0" scrolling="no")
|
2022-03-02 08:16:31 +05:30
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
context 'in an issue' do
|
|
|
|
let(:issue) { create(:issue, project: project, description: description) }
|
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
it 'includes mermaid frame correctly', :with_license do
|
2023-01-13 00:05:48 +05:30
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page.html).to include(expected)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'in a merge request' do
|
|
|
|
let(:merge_request) { create(:merge_request_with_diffs, source_project: project, description: description) }
|
|
|
|
|
|
|
|
it 'renders diffs and includes mermaid frame correctly' do
|
|
|
|
visit(diffs_project_merge_request_path(project, merge_request))
|
|
|
|
|
|
|
|
wait_for_requests
|
2022-03-02 08:16:31 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
page.within('.tab-content') do
|
|
|
|
expect(page).to have_selector('.diffs')
|
|
|
|
end
|
2022-03-02 08:16:31 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
visit(project_merge_request_path(project, merge_request))
|
2022-03-02 08:16:31 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
wait_for_requests
|
2022-03-02 08:16:31 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
page.within('.merge-request') do
|
|
|
|
expect(page.html).to include(expected)
|
|
|
|
end
|
|
|
|
end
|
2022-03-02 08:16:31 +05:30
|
|
|
end
|
2023-07-09 08:55:56 +05:30
|
|
|
|
|
|
|
context 'in a project milestone' do
|
|
|
|
let(:milestone) { create(:project_milestone, project: project, description: description) }
|
|
|
|
|
|
|
|
it 'includes mermaid frame correctly', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/408560' do
|
|
|
|
visit(project_milestone_path(project, milestone))
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page.html).to include(expected)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'in a group milestone' do
|
|
|
|
let(:group_milestone) { create(:group_milestone, description: description) }
|
|
|
|
|
|
|
|
it 'includes mermaid frame correctly' do
|
|
|
|
visit(group_milestone_path(group_milestone.group, group_milestone))
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page.html).to include(expected)
|
|
|
|
end
|
|
|
|
end
|
2022-03-02 08:16:31 +05:30
|
|
|
end
|