diff --git a/tests/bin/initialize.sh b/tests/bin/initialize.sh index e9cb0f0..98b6735 100755 --- a/tests/bin/initialize.sh +++ b/tests/bin/initialize.sh @@ -1,3 +1,6 @@ #!/bin/bash wp-env run tests-wordpress chmod -c ugo+w /var/www/html wp-env run tests-cli wp rewrite structure '/%postname%/' --hard + +wp-env run tests-cli wp user create editor editor@eightdayweek.com --user_pass=password --role=editor + diff --git a/tests/cypress/e2e/admin.test.js b/tests/cypress/e2e/admin.test.js index 2ace546..6664d49 100644 --- a/tests/cypress/e2e/admin.test.js +++ b/tests/cypress/e2e/admin.test.js @@ -7,11 +7,6 @@ describe("Admin can login and open dashboard", () => { cy.visit(`/wp-admin`); cy.get("h1").should("contain", "Dashboard"); }); - - it("Activate Hello Dolly and deactivate it back", () => { - cy.activatePlugin("hello-dolly"); - cy.deactivatePlugin("hello-dolly"); - }); }); describe('Admin can login and make sure plugin is activated', () => { diff --git a/tests/cypress/e2e/article-status.test.js b/tests/cypress/e2e/article-status.test.js new file mode 100644 index 0000000..f7c5c41 --- /dev/null +++ b/tests/cypress/e2e/article-status.test.js @@ -0,0 +1,26 @@ +describe('Article Status', () => { + before(() => { + cy.login(); + }); + + it("Create Article Status", () => { + cy.visit(`wp-admin/edit-tags.php?taxonomy=pi-article-status&post_type=print-issue`); + cy.get('#tag-name').type('Active-01'); + cy.get('#submit').click(); + }); + + it("Edit Article Status", () => { + cy.visit(`wp-admin/edit-tags.php?taxonomy=pi-article-status&post_type=print-issue`); + cy.get('[aria-label="“Active-01” (Edit)"]').click(); + cy.get('#name').clear(); + cy.get('#name').type('Active-02') + cy.get('.button').click(); + }); + + it("Delete Article Status", () => { + cy.visit(`wp-admin/edit-tags.php?taxonomy=pi-article-status&post_type=print-issue`); + cy.get('[aria-label="“Active-02” (Edit)"]').click(); + cy.get('.delete').click(); + }); + + }); \ No newline at end of file diff --git a/tests/cypress/e2e/issue-status.test.js b/tests/cypress/e2e/issue-status.test.js new file mode 100644 index 0000000..507c4d3 --- /dev/null +++ b/tests/cypress/e2e/issue-status.test.js @@ -0,0 +1,26 @@ +describe('Issue Status', () => { + before(() => { + cy.login(); + }); + + it("Create Issue Status", () => { + cy.visit(`wp-admin/edit-tags.php?taxonomy=print_issue_status&post_type=print-issue`); + cy.get('#tag-name').type('Active-01'); + cy.get('#submit').click(); + }); + + it("Edit Issue Status", () => { + cy.visit(`wp-admin/edit-tags.php?taxonomy=print_issue_status&post_type=print-issue`); + cy.get('[aria-label="“Active-01” (Edit)"]').click(); + cy.get('#name').clear(); + cy.get('#name').type('Active-02') + cy.get('.button').click(); + }); + + it("Delete Issue Status", () => { + cy.visit(`wp-admin/edit-tags.php?taxonomy=print_issue_status&post_type=print-issue`); + cy.get('[aria-label="“Active-02” (Edit)"]').click(); + cy.get('.delete').click(); + }); + + }); \ No newline at end of file diff --git a/tests/cypress/e2e/print.test.js b/tests/cypress/e2e/print.test.js index f5f30e8..6a7e64b 100644 --- a/tests/cypress/e2e/print.test.js +++ b/tests/cypress/e2e/print.test.js @@ -5,7 +5,7 @@ describe('Publish a new print issue', () => { it("Open new print issue page", () => { cy.visit(`/wp-admin/post-new.php?post_type=print-issue`); - cy.get("#title").type("Print Title 1"); + cy.get("#title").type("Print Title 01"); cy.get("#pi-section-add").click(); cy.get("#pi-section-name").type("Section title 1"); cy.get("#pi-section-add-confirm").click(); @@ -22,4 +22,44 @@ describe('Publish a new print issue', () => { }); cy.get("#normal-sortables .button-primary:visible").click(); }); + + it("Add multiple section and Edit issue", () => { + cy.visit(`wp-admin/edit.php?post_type=print-issue`); + cy.get('[aria-label="“Print Title 01” (Edit)"]').click(); + cy.get("#title").clear(); + cy.get("#title").type("Print Title 02"); + cy.get("#pi-section-add").click(); + cy.get("#pi-section-name").type("Section title 2"); + cy.get("#pi-section-add-confirm").click(); + cy.get(".pi-article-add:visible").eq(1).should('exist').click(); + cy.get(".pi-article-title:visible").eq(1).type("Hello"); + cy.intercept('GET', '/wp-admin/admin-ajax.php*').as('ajaxRequest'); + cy.wait('@ajaxRequest').its('response.statusCode').should('eq', 200); + cy.get("body").then($body => { + if ($body.find(".ui-menu-item").length > 0) { + cy.get(".ui-menu-item").click(); + } else { + cy.get(".ui-menu-item-wrapper").click(); + } + }); + cy.get("#normal-sortables .button-primary:visible").eq(1).click(); + }); + + it("Export Issues", () => { + cy.visit(`wp-admin/edit.php?post_type=print-issue`); + cy.get('[aria-label="“Print Title 02” (Edit)"]').click(); + cy.window().document().then(function (doc) { + doc.addEventListener('click', () => { + setTimeout(function () { doc.location.reload() }, 5000) + }) + cy.get('#article-export-all').click() + }) + + }); + + it("Delete issue", () => { + cy.visit(`wp-admin/edit.php?post_type=print-issue`); + cy.get('[aria-label="“Print Title 02” (Edit)"]').click(); + cy.get('.submitdelete').click(); + }); }); \ No newline at end of file diff --git a/tests/cypress/e2e/publications.test.js b/tests/cypress/e2e/publications.test.js new file mode 100644 index 0000000..4d73c41 --- /dev/null +++ b/tests/cypress/e2e/publications.test.js @@ -0,0 +1,26 @@ +describe('Publications', () => { + before(() => { + cy.login(); + }); + + it("Create Publications", () => { + cy.visit(`wp-admin/edit-tags.php?taxonomy=print_issue_publication&post_type=print-issue`); + cy.get('#tag-name').type('Weekly Articles'); + cy.get('#submit').click(); + }); + + it("Edit Publications", () => { + cy.visit(`wp-admin/edit-tags.php?taxonomy=print_issue_publication&post_type=print-issue`); + cy.get('[aria-label="“Weekly Articles” (Edit)"]').click(); + cy.get('#name').clear(); + cy.get('#name').type('Monthly Articles') + cy.get('.button').click(); + }); + + it("Delete Publications", () => { + cy.visit(`wp-admin/edit-tags.php?taxonomy=print_issue_publication&post_type=print-issue`); + cy.get('[aria-label="“Monthly Articles” (Edit)"]').click(); + cy.get('.delete').click(); + }); + + }); \ No newline at end of file diff --git a/tests/cypress/e2e/user-custom-role.test.js b/tests/cypress/e2e/user-custom-role.test.js new file mode 100644 index 0000000..b0bde54 --- /dev/null +++ b/tests/cypress/e2e/user-custom-role.test.js @@ -0,0 +1,16 @@ +describe('Check Custom Role', () => { + before(() => { + cy.login(); + }); + + it("Change user role Role to Print Editor and remove Print Editor role", () => { + cy.visit(`wp-admin/users.php`); + cy.get('#user_2').click(); + cy.get('[type="checkbox"]').check('2'); + cy.get('#pp-print-role').select(2); + cy.get('#changeit').click(); + cy.get('#pp-print-role').select(1); + cy.get('#changeit').click(); + + }); + }); \ No newline at end of file