Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cypress test #148

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/bin/initialize.sh
Original file line number Diff line number Diff line change
@@ -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 [email protected] --user_pass=password --role=editor

5 changes: 0 additions & 5 deletions tests/cypress/e2e/admin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
26 changes: 26 additions & 0 deletions tests/cypress/e2e/article-status.test.js
Original file line number Diff line number Diff line change
@@ -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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to add a verification step here to confirm that the article status was created successfully.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamdharmesh probably best if you help get things updated for this PR and merge in

});

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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, Add a verification step to confirm status edited successfully. Could you please help to add verification steps for all the tests?

});

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();
});

});
26 changes: 26 additions & 0 deletions tests/cypress/e2e/issue-status.test.js
Original file line number Diff line number Diff line change
@@ -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();
});

});
42 changes: 41 additions & 1 deletion tests/cypress/e2e/print.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
});
});
26 changes: 26 additions & 0 deletions tests/cypress/e2e/publications.test.js
Original file line number Diff line number Diff line change
@@ -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();
});

});
16 changes: 16 additions & 0 deletions tests/cypress/e2e/user-custom-role.test.js
Original file line number Diff line number Diff line change
@@ -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();

});
});
Loading