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

Add a test for the front end #219

Merged
merged 13 commits into from
Oct 13, 2023
Merged
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
9 changes: 7 additions & 2 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"plugins": ["."],
"plugins": [
"."
],
"themes": [
"https://downloads.wordpress.org/theme/twentytwentyone.zip"
],
"env": {
"tests": {
"mappings": {
"wp-cli.yml": "./tests/bin/wp-cli.yml"
}
}
}
}
}
1 change: 1 addition & 0 deletions tests/cypress/config.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
chromeWebSecurity: false,
fixturesFolder: __dirname+'/fixtures',
screenshotsFolder: __dirname+'/screenshots',
videosFolder: __dirname+'/videos',
Expand Down
69 changes: 69 additions & 0 deletions tests/cypress/integration/check-avatar-fe.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
describe("Check avatar on a post", () => {
beforeEach(() => {
cy.login();
});

it("Can admin upload, crop and select local avatar?", () => {
// Check and upload at least one media file.
cy.atleastOneMedia();

// Visit profile page and set uploaded file as an avatar.
cy.visit("/wp-admin/profile.php");
cy.get("#simple-local-avatar-media").click();

cy.get(".media-menu-item:nth-child(2)").click();
cy.get("li.attachment:first-child").click();
cy.get(".media-button-select").click();

cy.get("body").then(($body) => {
if (0 !== $body.find(".media-button-insert").length) {
cy.get(".media-button-insert").click();
}
});

cy.get("#simple-local-avatar-remove").should("be.visible");
});

it("Can admin set the avatar rating?", () => {
cy.visit("/wp-admin/profile.php");

cy.get('input[name="simple_local_avatar_rating"][value="PG"]').check();
cy.get("#description").clear().type("Admin bio");
cy.get("#submit").click();

cy.reload();

cy.get('input[name="simple_local_avatar_rating"][value="PG"]').should(
"be.checked"
);
cy.get('input[name="simple_local_avatar_rating"][value="G"]').check();
cy.get("#submit").click();
});

it("Does the avatar appear on a created post?", () => {
// Set the theme
cy.visit("/wp-admin/themes.php");
cy.get(".theme-browser.rendered").then(($body) => {
if (
0 !==
$body.find('.theme[data-slug="twentytwentyone"] .button.activate')
.length
) {
cy.get('.theme[data-slug="twentytwentyone"] .button.activate').click({
force: true,
});
}
});

cy.createPost({
title: "Test Simple Avatars Post",
}).then((post) => {
// Check the FE
cy.visit(`/?p=${post.id}`);
cy.get(".author-bio .avatar").should("be.visible");
cy.get(".author-bio .avatar")
.invoke("attr", "src")
.should("include", "icon-256x256");
});
});
});
Loading