Skip to content

Commit

Permalink
Merge pull request #2866 from Codeinwp/cypress/palette-switch-test
Browse files Browse the repository at this point in the history
test: adds test for palette switch
  • Loading branch information
gutoslv authored Jun 8, 2021
2 parents ce48996 + afeb2c4 commit e927646
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"neve_ran_builder_migration": true,
"neve_migrated_builders": true,
"neve_migrated_hfg_colors": true,
"nav_menu_locations": {
"primary": 176
},
"header_palette_switch_icon_size": "{\"mobile\":16,\"tablet\":16,\"desktop\":44}",
"hfg_header_layout": "{\"desktop\":{\"top\":[{\"x\":7,\"y\":1,\"width\":1,\"height\":1,\"id\":\"header_palette_switch\"}],\"main\":[{\"x\":0,\"y\":1,\"width\":4,\"height\":1,\"id\":\"logo\"},{\"x\":4,\"y\":1,\"width\":8,\"height\":1,\"id\":\"primary-menu\"}],\"bottom\":[]},\"mobile\":{\"top\":[],\"main\":[{\"x\":0,\"y\":1,\"width\":8,\"height\":1,\"id\":\"logo\"},{\"x\":8,\"y\":1,\"width\":4,\"height\":1,\"id\":\"nav-icon\"}],\"bottom\":[],\"sidebar\":[{\"x\":0,\"y\":1,\"width\":8,\"height\":1,\"id\":\"primary-menu\"}]}}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
describe('Palette Switch component', function () {
before('Setup by adding a new palette', function () {
cy.fixture('customizer/hfg/hfg-palette-switch-component').then((setup) => {
cy.setCustomizeSettings(setup);
});
});

it('Changes the color palette by clicking', function () {
cy.visit('/');
cy.get('h2').should('have.css', 'color', 'rgb(57, 57, 57)');
cy.get('.icon > svg > path').click();
cy.get('h2').should('have.css', 'color', 'rgb(255, 255, 255)');
});

it('Removes color palette from website', function () {
cy.setCustomizeSettings({});
cy.visit('/');
cy.get('.icon > svg > path').should('not.exist');
});
});

describe('Palette Swich auto', function () {
before('Setup', function () {
cy.fixture('customizer/hfg/hfg-palette-switch-component').then((setup) => {
setup.header_palette_switch_auto_adjust_color = 1;
cy.setCustomizeSettings(setup);
});
});

it('Automatically changes the color palette when dark is default', function () {
cy.setLocalStorage('neve_user_theme', 'dark');
cy.visit('/');
cy.get('h2').should('have.css', 'color', 'rgb(255, 255, 255)');
});

it('Automatically changes the color palette when light is default', function () {
cy.setLocalStorage('neve_user_theme', 'light');
cy.visit('/');
cy.get('h2').should('have.css', 'color', 'rgb(57, 57, 57)');
});
});

0 comments on commit e927646

Please sign in to comment.