Skip to content

Commit 162e2d8

Browse files
committed
Show pass/fail state for corpus tests.
1 parent 483a5a7 commit 162e2d8

File tree

6 files changed

+105
-4
lines changed

6 files changed

+105
-4
lines changed

‎app/assets/javascripts/app.js‎

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎app/assets/javascripts/dest/src.js‎

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎app/assets/javascripts/src/views/refiddle.coffee‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class App.Views.Refiddle extends Backbone.View
7979
@highlightMatches( @matches )
8080

8181
highlightMatches: (matches) =>
82+
@updateMatchResults( matches )
83+
8284
_.each @corpusEditor.getAllMarks(), (m) ->
8385
m.clear()
8486

@@ -90,6 +92,18 @@ class App.Views.Refiddle extends Backbone.View
9092
@corpusEditor.markText( from, to, className: pair[2] || "match" )
9193
undefined
9294

95+
updateMatchResults: (matches) ->
96+
summary = matches.matchSummary
97+
98+
$("html").toggleClass( "with-tests", summary.tests )
99+
$("html").toggleClass( "tests-passing", summary.failed == 0 )
100+
$("html").toggleClass( "tests-failing", summary.failed > 0 )
101+
102+
$(".match-results .total .count").text( summary.total )
103+
$(".match-results .pass .count").text( summary.passed )
104+
$(".match-results .fail .count").text( summary.failed )
105+
106+
93107

94108
resizeTextGroup: =>
95109
@resizeTextGroupDebounced ||= _.debounce @_resizeTextGroup, 50, true

‎app/assets/stylesheets/codemirror.less‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
font-family: @font-family-monospace;
66
font-size: @font-size-small;
7-
line-height: 1.3;
7+
line-height: 1.6;
88
}
99

1010
.CodeMirror pre

‎app/assets/stylesheets/pages/refiddle.less‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,60 @@
108108
font-size: @font-size-small;
109109
padding: @padding-base-vertical * 2 @padding-base-horizontal;
110110
}
111+
112+
.match-results
113+
{
114+
.label
115+
{
116+
margin-left: 4px;
117+
}
118+
}
119+
120+
121+
}
122+
123+
.match-results
124+
{
125+
.pass, .fail
126+
{
127+
display: none;
128+
}
129+
}
130+
131+
.with-tests
132+
{
133+
.match-results
134+
{
135+
.pass, .fail
136+
{
137+
display: inline;
138+
}
139+
.total
140+
{
141+
display: none;
142+
}
143+
}
144+
145+
&.tests-failing
146+
{
147+
#refiddle_regex, #refiddle_regex + .CodeMirror
148+
{
149+
border-color: @brand-danger;
150+
}
151+
}
152+
153+
&.tests-passing
154+
{
155+
#refiddle_regex, #refiddle_regex + .CodeMirror
156+
{
157+
border-color: @brand-success;
158+
}
159+
.match-results
160+
{
161+
.fail
162+
{
163+
display: none;
164+
}
165+
}
166+
}
111167
}

‎app/views/refiddles/_form.html.haml‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,16 @@
1717
.panel.panel-default><
1818
.panel-heading
1919
.pull-right
20-
.label.label-default 0 Matches
21-
.label.label-success 1 PASSING
22-
.label.label-danger 2 FAILING
20+
.match-results
21+
.label.label-default.total
22+
%span.count
23+
Matches
24+
.label.label-success.pass
25+
%span.count
26+
Passing
27+
.label.label-danger.fail
28+
%span.count
29+
Failing
2330
= link_to "Corpus", "#corpus", data: { toggle: "collapse", parent: "#text" }
2431

2532
#corpus.panel-collapse.collapse.in

0 commit comments

Comments
 (0)