Skip to content

Commit c79741c

Browse files
committed
Update tests for new UI changes.
1 parent 91693e3 commit c79741c

File tree

3 files changed

+42
-34
lines changed

3 files changed

+42
-34
lines changed

tests/qunit/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var helpers = {
66
fixture.append( '<div class="spinner">Loading...</div>' );
77
fixture.append( '<textarea id="testResults"></textarea>' );
88
fixture.append( '<div id="footer" style="display: none;"></div>' );
9-
fixture.append( '<div id="standardMode"></div>' );
9+
fixture.append( '<div id="wpe-pcc-standardMode"></div>' );
1010
fixture.append( '<input type="radio" name="phptest_version" value="' + version + '" checked="checked">' );
1111
},
1212
rgb2hex: function(rgb) {

tests/qunit/index.html

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,38 @@
2020
<script src="test-run.js"></script>
2121

2222
<script id="result-template" type="text/x-handlebars-template">
23-
<div style="border-left-color: {{#if skipped}}#999999{{else if passed}}#038103{{else}}#e74c3c{{/if}};" class="wpe-results-card">
24-
<div class="inner-left">
25-
{{#if skipped}}<img src="<?php echo esc_url( plugins_url( '/src/images/question.png', __FILE__ ) ); ?>">{{else if passed}}<img src="<?php echo esc_url( plugins_url( '/src/images/check.png', __FILE__ ) ); ?>">{{else}}<img src="<?php echo esc_url( plugins_url( '/src/images/x.png', __FILE__ ) ); ?>">{{/if}}
26-
</div>
27-
<div class="inner-right">
28-
<h3 style="margin: 0px;">{{plugin_name}}</h3>
29-
{{#if skipped}}Unknown{{else if passed}}PHP {{test_version}} compatible.{{else}}<b>Not</b> PHP {{test_version}} compatible.{{/if}}<br>
30-
{{update}}<br>
31-
<textarea style="display: none; white-space: pre;">{{logs}}</textarea><a class="view-details">view details</a>
32-
</div>
33-
<?php $update_url = site_url( 'wp-admin/update-core.php' , 'admin' ); ?>
34-
<div style="float:right;">{{#if updateAvailable}}<div class="badge wpe-update"><a href="<?php echo esc_url( $update_url ); ?>">Update Available</a></div>{{/if}}<div class="badge warnings">{{warnings}} Warnings</div><div class="badge errors">{{errors}} Errors</div></div>
35-
</div>
23+
<div class="wpe-pcc-alert wpe-pcc-alert-{{#if skipped}}skipped{{else if passed}}passed{{else}}error{{/if}}">
24+
<p>
25+
<?php /* Appropriate icon, based on status */ ?>
26+
<span class="dashicons-before dashicons-{{#if errors}}no{{else if skipped}}editor-help{{else}}yes{{/if}}"></span>
27+
<?php /* Name of plugin/theme being tested */ ?>
28+
<strong>{{plugin_name}} </strong> -
29+
<?php /* Results status */ ?>
30+
<span class="wpe-pcc-alert-status">
31+
{{#if skipped}}
32+
<span class="wpe-pcc-badge wpe-pcc-badge-skipped"><?php _e( 'Unknown', 'php-compatibility-checker' ); ?></span>
33+
{{else}}
34+
{{#if passed}}
35+
<span class="wpe-pcc-badge wpe-pcc-badge-passed"><?php _e( 'Compatible', 'php-compatibility-checker' ); ?></span>
36+
{{/if}}
37+
{{#if warnings}}
38+
<span class="wpe-pcc-badge wpe-pcc-badge-warnings"><?php _e( 'Warnings:', 'php-compatibility-checker' ); ?> <strong>{{warnings}}</strong></span>
39+
{{/if}}
40+
{{#if errors}}
41+
<span class="wpe-pcc-badge wpe-pcc-badge-errors"><?php _e( 'Errors:', 'php-compatibility-checker' ); ?> <strong>{{errors}}</strong></span>
42+
{{/if}}
43+
{{/if}}
44+
</span>
45+
<?php /* Check if plugin/theme has an update available */ ?>
46+
<?php $update_url = site_url( 'wp-admin/update-core.php' , 'admin' ); ?>
47+
{{#if updateAvailable}}
48+
(<a href="<?php echo esc_url( $update_url ); ?>"><?php _e( 'Update Available', 'php-compatibility-checker' ); ?></a>)
49+
{{/if}}
50+
<?php /* View details link */ ?>
51+
<a class="wpe-pcc-alert-details" href="#"><?php _e( 'toggle details', 'php-compatibility-checker' ); ?></a>
52+
<textarea class="wpe-pcc-alert-logs hide">{{logs}}</textarea>
53+
</p>
54+
</div> <!-- /wpe-pcc-alert -->
3655
</script>
3756
</body>
38-
</html>
57+
</html>

tests/qunit/test-run.js

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ QUnit.test( 'reset elements', function( assert ) {
2929
fixture.append( '<div id="wpe-pcc-standardMode">Hello this is text.</div>' );
3030
fixture.append( '<textarea id="testResults">This is some more text!</textarea>' );
3131
fixture.append( '<div id="wpe-progress-count"></div>' );
32-
fixture.append( '<div id="progressbar"></div>' );
3332

3433
// Set the progress bar to a known state.
3534
jQuery( '#progressbar' ).progressbar({ value: 5 });
@@ -39,7 +38,6 @@ QUnit.test( 'reset elements', function( assert ) {
3938
assert.ok( '' === $( '#testResults' ).text(), 'testResults is empty' );
4039
assert.ok( '' === $( '#wpe-pcc-standardMode' ).html(), 'wpe-pcc-standardMode is empty' );
4140
assert.ok( '' === $( '#wpe-progress-count' ).text(), 'wpe-progress-count is empty' );
42-
assert.ok( 0 === $( '#progressbar' ).progressbar( 'value' ), 'progressbar is set to 0' );
4341
});
4442

4543
QUnit.module( 'displayReport' );
@@ -54,12 +52,9 @@ QUnit.test( 'Render test pass', function( assert ) {
5452
displayReport(helpers.passResults);
5553

5654
var displayedResults = $('#testResults').text();
57-
5855
assert.ok( helpers.passResults === displayedResults, 'Text results are correct' );
59-
// assert.ok( $('#footer').is(':visible'), 'Footer is visible' );
60-
assert.ok( $('.wpe-pcc-alert').length == 2, 'There are 2 results.' );
61-
assert.ok( $('#wpe-pcc-standardMode').text().indexOf( 'Your WordPress install is PHP 5.5 compatible.' ) !== -1, 'Test did pass.' );
62-
assert.ok( '#038103' === helpers.rgb2hex( $( ".wpe-pcc-alert" ).eq( 0 ).css( 'border-left-color' ) ), 'First plugin marked as passed.' );
56+
assert.ok( $( '.wpe-pcc-alert' ).length == 2, 'There are 2 results.' );
57+
assert.ok( $( '.wpe-pcc-alert' ).eq(0).hasClass( 'wpe-pcc-alert-passed' ), 'First plugin marked as passed.' );
6358
assert.ok( $( '#wpe-pcc-standardMode' ).text().indexOf( '0 out of 2' ) === -1, 'No scan stats are shown.' );
6459
});
6560

@@ -75,9 +70,7 @@ QUnit.test( 'Render test fail', function( assert ) {
7570
var displayedResults = $('#testResults').text();
7671

7772
assert.ok( helpers.failResults === displayedResults, 'Text results are correct' );
78-
// assert.ok( $('#footer').is(':visible'), 'Footer is visible' );
7973
assert.ok( $('.wpe-pcc-alert').length == 7, 'There are 7 results.' );
80-
assert.ok( $('#wpe-pcc-standardMode').text().indexOf( 'Your WordPress install is not PHP 5.5 compatible.' ) !== -1, 'Test did not pass.' );
8174
assert.ok( $( '#wpe-pcc-standardMode' ).text().indexOf( '1 out of 7' ) !== -1, 'Scan stats are correct' );
8275
});
8376

@@ -92,8 +85,8 @@ QUnit.test( 'Render test skip', function( assert ) {
9285

9386
var displayedResults = $( '#testResults' ).text();
9487

95-
assert.ok( '#038103' === helpers.rgb2hex( $( ".wpe-pcc-alert" ).eq( 0 ).css( 'border-left-color' ) ), 'First plugin marked as passed.' );
96-
assert.ok( '#999999' === helpers.rgb2hex( $( ".wpe-pcc-alert" ).eq( 1 ).css( 'border-left-color' ) ), 'Second plugin marked as skipped.' );
88+
assert.ok( $( '.wpe-pcc-alert' ).eq(0).hasClass( 'wpe-pcc-alert-passed' ), 'First plugin marked as passed.' );
89+
assert.ok( $( '.wpe-pcc-alert' ).eq(1).hasClass( 'wpe-pcc-alert-skipped' ), 'Second plugin marked as skipped.' );
9790
});
9891

9992
QUnit.module( 'checkStatus' );
@@ -102,7 +95,7 @@ QUnit.test( 'Test checkStatus progress', function( assert ) {
10295
// This will be an async test since it involves callbacks.
10396
var done = assert.async();
10497
var fixture = $( '#qunit-fixture' );
105-
fixture.append( '<div id="wpe-progress-count"></div>' );
98+
fixture.append( '<div id="wpe-pcc-progress-count"></div>' );
10699
fixture.append( '<div id="progressbar"></div>' );
107100

108101
// Define our mock URL.
@@ -118,9 +111,7 @@ QUnit.test( 'Test checkStatus progress', function( assert ) {
118111
return true;
119112
},
120113
onAfterComplete: function() { // Check the results of checkStatus();
121-
assert.ok( $( '#wpe-progress-count' ).text() === '17/17', 'Progress count is correct.' );
122-
assert.ok( $( '#progressbar' ).progressbar( 'value' ) === 94.1176470588 , 'Progress bar is correct.' );
123-
114+
assert.ok( $( '#wpe-pcc-progress-count' ).text() === '(17 of 17)', 'Progress count is correct.' );
124115
// Clear the next queued checkStatus call.
125116
clearTimeout( timer );
126117
// End the test.
@@ -135,7 +126,7 @@ QUnit.test( 'Test checkStatus progress', function( assert ) {
135126
QUnit.test( 'Test checkStatus done', function( assert ) {
136127
var done = assert.async();
137128
var fixture = $( '#qunit-fixture' );
138-
fixture.append( '<div id="wpe-progress"><div id="wpe-progress-count"></div></div>' );
129+
fixture.append( '<div id="wpe-progress"><div id="wpe-pcc-progress-count"></div></div>' );
139130

140131
ajaxurl = '/checkStatus/done/';
141132

@@ -148,7 +139,7 @@ QUnit.test( 'Test checkStatus done', function( assert ) {
148139
return true;
149140
},
150141
onAfterComplete: function() {
151-
assert.ok( ! $('#wpe-progress').is(':visible'), 'Progress div is hidden.' );
142+
assert.ok( ! $('#wpe-pcc-progress-count').is(':visible'), 'Progress div is hidden.' );
152143
clearTimeout( timer );
153144
done();
154145
}
@@ -160,7 +151,6 @@ QUnit.test( 'Test checkStatus done', function( assert ) {
160151
QUnit.test( 'Test checkStatus fail JSON.parse', function( assert ) {
161152
var done = assert.async();
162153
var fixture = $( '#qunit-fixture' );
163-
fixture.append( '<div id="wpe-progress"><div id="wpe-progress-count"></div></div>' );
164154

165155
ajaxurl = '/checkStatus/fail/json/';
166156
var callCount = 0;
@@ -177,7 +167,6 @@ QUnit.test( 'Test checkStatus fail JSON.parse', function( assert ) {
177167
return true;
178168
},
179169
onAfterComplete: function() {
180-
assert.ok( $('#wpe-progress').is(':visible'), 'Progress div is visible.' );
181170
// Ensure that an alert was popped with the JSON SyntaxError.
182171
assert.ok( -1 !== alertText.toString().search( 'SyntaxError' ), 'Got JSON parse error in alert.' );
183172
assert.ok( 1 === callCount, 'Alert was called.' );

0 commit comments

Comments
 (0)