File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+ require 'support/editor'
3+ require 'support/playground_actions'
4+
5+ RSpec . feature "Highlighting MIR output" , type : :feature , js : true do
6+ include PlaygroundActions
7+
8+ before do
9+ visit '/'
10+ editor . set ( code )
11+ in_build_menu { click_on ( "MIR" ) }
12+ end
13+
14+ scenario "error locations are links" do
15+ within ( '.output-mir' ) do
16+ click_link ( 'src/main.rs:4:14: 4:19' , match : :first )
17+ end
18+ expect ( editor ) . to have_highlighted_text ( 'a + b' )
19+ end
20+
21+ def editor
22+ Editor . new ( page )
23+ end
24+
25+ def code
26+ <<~EOF
27+ fn main() {
28+ let a = 1;
29+ let b = 2;
30+ let _c = a + b;
31+ }
32+ EOF
33+ end
34+ end
Original file line number Diff line number Diff line change @@ -15,4 +15,17 @@ def set(text)
1515 def has_line? ( text )
1616 page . has_css? '.ace_line' , text : text
1717 end
18+
19+ def has_highlighted_text? ( text )
20+ page . within ( '.editor .ace_text-input' , visible : :any ) do
21+ selected = page . evaluate_script <<~JS
22+ (() => {
23+ const editor = document.querySelector('.ace_editor').env.editor;
24+ return editor.getSelectedText();
25+ })()
26+ JS
27+
28+ selected == text
29+ end
30+ end
1831end
You can’t perform that action at this time.
0 commit comments