Skip to content

Commit 2ce5258

Browse files
committed
implement integration tests for settings page
1 parent eafdde5 commit 2ce5258

6 files changed

Lines changed: 48 additions & 1 deletion

File tree

cypress/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
declare namespace Cypress {
44
interface Chainable<Subject> {
55

6+
getByCy(cyKey: string): Chainable<Element>;
67
postContentMatchesSnapshot(): Chainable<void>
78
insertRowBlock(): Chainable<void>
89
selectRowBlock( index?: number ): Chainable<void>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/// <reference types="Cypress" />
2+
3+
describe( 'Settings page', () => {
4+
beforeEach( () => {
5+
cy.loginUser();
6+
} );
7+
8+
it( 'Default values should be selected', () => {
9+
cy.visitAdminPage(
10+
'options-general.php?page=wp-bootstrap-blocks_settings'
11+
);
12+
13+
cy.get(
14+
'#wp-bootstrap-blocks_bootstrap_version option:selected'
15+
).should( 'have.value', '4' );
16+
17+
cy.get( '#wp-bootstrap-blocks_enable_css_grid' )
18+
.should( 'not.be.checked' )
19+
.and( 'be.disabled' );
20+
} );
21+
22+
it( 'Should respect constants', () => {
23+
cy.activatePlugin( 'wp-bootstrap-blocks-test-css-grid' );
24+
cy.visitAdminPage(
25+
'options-general.php?page=wp-bootstrap-blocks_settings'
26+
);
27+
28+
cy.get( '#wp-bootstrap-blocks_bootstrap_version' ).should(
29+
'be.disabled'
30+
);
31+
cy.get(
32+
'#wp-bootstrap-blocks_bootstrap_version option:selected'
33+
).should( 'have.value', '5' );
34+
35+
cy.get( '#wp-bootstrap-blocks_enable_css_grid' )
36+
.should( 'be.checked' )
37+
.and( 'be.disabled' );
38+
39+
cy.deactivatePlugin( 'wp-bootstrap-blocks-test-css-grid' );
40+
} );
41+
} );
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Cypress.Commands.add( 'getByCy', ( cyKey ) =>
2+
cy.get( `[data-cy="${ cyKey }"]` )
3+
);

cypress/support/commands/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './get-by-cy';
12
import './insert-row-block';
23
import './select-row-block';
34
import './row-template-is-selected';

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Please create a new GitHub issue and let us know: [https://github.com/liip/boots
148148
* [FEATURE] Reflect noGutters and horizontalGutters options visually in editor (WordPress >= 5.4).
149149
* [FIX] Add missing "Medium" size to vertical gutter options.
150150
* [FIX] Fix label of default css grid gutter option ("Medium" instead of "None").
151+
* [FIX] Allow enabling CSS grid option only if Bootstrap version is >= 5.
151152

152153
= 4.1.0 =
153154

src/settings/class-settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public static function settings_page() {
266266
<div class="wrap" id="<?php echo esc_attr( self::MENU_SLUG ); ?>">
267267
<h1><?php esc_html_e( 'Bootstrap Blocks Settings', 'wp-bootstrap-blocks' ); ?></h1>
268268

269-
<form method="post" action="options.php" enctype="multipart/form-data" data-cy="wp-bootstrap-blocks-settings-form">
269+
<form method="post" action="options.php" enctype="multipart/form-data">
270270
<?php
271271
// Get settings fields
272272
settings_fields( self::MENU_SLUG );

0 commit comments

Comments
 (0)