Skip to content

Commit

Permalink
Build: (330d8f2) Merge pull request #17 from 10up/command/set-permali…
Browse files Browse the repository at this point in the history
…nk-structure

Set Permalink Structure command
  • Loading branch information
cadic committed Mar 23, 2022
1 parent 2ad45f6 commit 15f2a64
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/commands/set-permalink-structure.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Set Permalink Structure
*
* @param type - Permalink structure, should contain structure tags or be an empty string (which means "Plain" structure)
*
* @example
* ```
* cy.setPermalinkStructure('/%year%/%postname%/')
* ```
*/
export declare const setPermalinkStructure: (type: string) => void;
22 changes: 22 additions & 0 deletions lib/commands/set-permalink-structure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setPermalinkStructure = void 0;
/**
* Set Permalink Structure
*
* @param type - Permalink structure, should contain structure tags or be an empty string (which means "Plain" structure)
*
* @example
* ```
* cy.setPermalinkStructure('/%year%/%postname%/')
* ```
*/
const setPermalinkStructure = (type) => {
cy.visit('/wp-admin/options-permalink.php');
cy.get('#permalink_structure').click().clear();
if ('' !== type) {
cy.get('#permalink_structure').click().type(type);
}
cy.get('#submit').click();
};
exports.setPermalinkStructure = setPermalinkStructure;
2 changes: 2 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { setPermalinkStructure } from './commands/set-permalink-structure';
import { openDocumentSettingsPanel } from './commands/open-document-settings-panel';
import { openDocumentSettingsSidebar } from './commands/open-document-settings-sidebar';
import { deleteAllTerms } from './commands/delete-all-terms';
Expand All @@ -7,6 +8,7 @@ import { login } from './commands/login';
declare global {
namespace Cypress {
interface Chainable<Subject> {
setPermalinkStructure: typeof setPermalinkStructure;
openDocumentSettingsPanel: typeof openDocumentSettingsPanel;
openDocumentSettingsSidebar: typeof openDocumentSettingsSidebar;
deleteAllTerms: typeof deleteAllTerms;
Expand Down
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
/// <reference types="cypress" />
Object.defineProperty(exports, "__esModule", { value: true });
// Import commands.
const set_permalink_structure_1 = require("./commands/set-permalink-structure");
const open_document_settings_panel_1 = require("./commands/open-document-settings-panel");
const open_document_settings_sidebar_1 = require("./commands/open-document-settings-sidebar");
const delete_all_terms_1 = require("./commands/delete-all-terms");
const create_term_1 = require("./commands/create-term");
const logout_1 = require("./commands/logout");
const login_1 = require("./commands/login");
// Register commands
Cypress.Commands.add('setPermalinkStructure', set_permalink_structure_1.setPermalinkStructure);
Cypress.Commands.add('openDocumentSettingsPanel', open_document_settings_panel_1.openDocumentSettingsPanel);
Cypress.Commands.add('openDocumentSettingsSidebar', open_document_settings_sidebar_1.openDocumentSettingsSidebar);
Cypress.Commands.add('deleteAllTerms', delete_all_terms_1.deleteAllTerms);
Expand Down

0 comments on commit 15f2a64

Please sign in to comment.