Skip to content

Commit

Permalink
Beta Release (#2981)
Browse files Browse the repository at this point in the history
Created by Github action

---------

Co-authored-by: Nar -- <28705606+finnar-bin@users.noreply.github.com>
Co-authored-by: Andres Galindo <agalin920@gmail.com>
Co-authored-by: Stuart Runyan <shrunyan@gmail.com>
Co-authored-by: Allen Pigar <50983144+allenpigar@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Gian Espinosa <espinosagian1995@gmail.com>
Co-authored-by: Gian Espinosa <44116036+glespinosa@users.noreply.github.com>
  • Loading branch information
7 people authored Oct 22, 2024
1 parent 1ec2f36 commit 7b5c242
Show file tree
Hide file tree
Showing 22 changed files with 1,597 additions and 394 deletions.
63 changes: 63 additions & 0 deletions cypress/e2e/content/actions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ describe("Actions in content editor", () => {
});

cy.get("input[name=title]", { timeout: 5000 }).click().type(timestamp);

cy.getBySelector("ManualMetaFlow").click();

cy.getBySelector("metaDescription")
.find("textarea")
.first()
Expand Down Expand Up @@ -271,4 +274,64 @@ describe("Actions in content editor", () => {
// }).should("exist");
// // cy.contains("The item has been purged from the CDN cache", { timeout: 5000 }).should("exist");
// });

it("Creates a new content item using AI-generated data", () => {
cy.waitOn("/v1/content/models*", () => {
cy.waitOn("/v1/content/models/*/fields?showDeleted=true", () => {
cy.visit("/content/6-a1a600-k0b6f0/new");
});
});

cy.intercept("/ai").as("ai");
cy.wait(5000);

// Generate AI content for single line text
cy.get("#12-0c3934-8dz720").find("[data-cy='AIOpen']").click();
cy.getBySelector("AITopicField").type("biking");
cy.getBySelector("AIAudienceField").type("young adults");
cy.getBySelector("AIGenerate").click();

cy.wait("@ai");

cy.getBySelector("AIApprove").click();

// Generate AI content for wysiwyg
cy.get("#12-717920-6z46t7").find("[data-cy='AIOpen']").click();
cy.getBySelector("AITopicField").type("biking");
cy.getBySelector("AIAudienceField").type("young adults");
cy.getBySelector("AIGenerate").click();

cy.wait("@ai");

cy.getBySelector("AIApprove").click();

// Select AI-assisted metadata generation flow
cy.getBySelector("ManualMetaFlow").click();

// Generate AI content for meta title
cy.getBySelector("metaTitle").find("input").clear();
cy.getBySelector("metaTitle").find("[data-cy='AIOpen']").click();
cy.getBySelector("AIGenerate").click();

cy.wait("@ai");

cy.getBySelector("AISuggestion1").click();
cy.getBySelector("AIApprove").click();

// Generate AI content for meta description
cy.getBySelector("metaDescription")
.find("textarea[name='metaDescription']")
.clear({ force: true });
cy.getBySelector("metaDescription").find("[data-cy='AIOpen']").click();
cy.getBySelector("AIGenerate").click();

cy.wait("@ai");

cy.getBySelector("AISuggestion1").click();
cy.getBySelector("AIApprove").click();

cy.getBySelector("CreateItemSaveButton").click();

cy.contains("Created Item", { timeout: 5000 }).should("exist");
});
});
4 changes: 3 additions & 1 deletion cypress/e2e/content/item-list-table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ describe("Content item list table", () => {

cy.getBySelector("SingleRelationshipCell", { timeout: 10000 })
.first()
.contains("All Field Types");
.contains(
"5 Tricks to Teach Your Pitbull: Fun & Easy Tips for You & Your Dog!"
);
});
});
47 changes: 42 additions & 5 deletions cypress/e2e/content/meta.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const today = Date.now();

describe("Content Meta", () => {
before(() => {
cy.waitOn("/v1/content/models*", () => {
cy.visit("/content/6-556370-8sh47g/7-b939a4-457q19/meta");
});
});
// before(() => {
// cy.waitOn("/v1/content/models*", () => {
// cy.visit("/content/6-556370-8sh47g/7-b939a4-457q19/meta");
// });
// });

// skipping failing test in preparation for CI.
it.skip("Modifies and saves Meta fields", () => {
Expand Down Expand Up @@ -63,4 +65,39 @@ describe("Content Meta", () => {
cy.get("#SaveItemButton").click();
cy.contains("Saved a new ").should("exist");
});

it("Does not validate meta description for dataset items", () => {
cy.waitOn("/v1/content/models*", () => {
cy.waitOn("/v1/env/nav", () => {
cy.waitOn("/v1/search/items*", () => {
cy.visit("/content/6-675028-84dq4s/new");
});
});
});

cy.get("#12-7893a0-w4j9gk", { timeout: 5000 }).find("input").type(today);
cy.getBySelector("CreateItemSaveButton").click();
cy.get("[data-cy=toast]").contains("Created Item");
});

it("Does validate meta description for non-dataset items", () => {
cy.waitOn("/v1/content/models*", () => {
cy.waitOn("/v1/env/nav", () => {
cy.waitOn("/v1/search/items*", () => {
cy.visit("/content/6-556370-8sh47g/7-b939a4-457q19/meta");
});
});
});

cy.getBySelector("metaDescription", { timeout: 10000 })
.find("textarea")
.first()
.type("test");
cy.getBySelector("metaDescription")
.find("textarea")
.first()
.type("{selectall}{del}");
cy.get("#SaveItemButton").click();
cy.getBySelector("FieldErrorsList").should("exist");
});
});
2 changes: 1 addition & 1 deletion cypress/e2e/schema/field.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ describe("Schema: Fields", () => {
cy.getBySelector(SELECTORS.ADD_FIELD_MODAL_DEACTIVATE_REACTIVATE)
.should("exist")
.click();
cy.getBySelector(SELECTORS.ADD_FIELD_MODAL_CLOSE).should("exist").click();
cy.getBySelector(SELECTORS.SAVE_FIELD_BUTTON).should("exist").click();

cy.wait("@updateField");
cy.wait("@getFields");
Expand Down
13 changes: 13 additions & 0 deletions public/images/openai-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 12 additions & 8 deletions src/apps/content-editor/src/app/components/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import cx from "classnames";
import { AppLink } from "@zesty-io/core/AppLink";
import { ThemeProvider } from "@mui/material";
import { theme } from "@zesty-io/material";
import { unescape } from "lodash";
import { Breadcrumbs } from "shell/components/global-tabs/components/Breadcrumbs";
import { Field } from "./Field";
import { FieldError } from "./FieldError";
Expand Down Expand Up @@ -276,14 +277,17 @@ export default memo(function Editor({

if (firstContentField && firstContentField.name === name) {
// Remove tags and replace MS smart quotes with regular quotes
const cleanedValue = value
?.replace(/<[^>]*>/g, "")
?.replaceAll(/[\u2018\u2019\u201A]/gm, "'")
?.replaceAll("&rsquo;", "'")
?.replaceAll(/[\u201C\u201D\u201E]/gm, '"')
?.replaceAll("&ldquo;", '"')
?.replaceAll("&rdquo;", '"')
?.slice(0, 160);
const cleanedValue = unescape(
value
?.replace(/<[^>]*>/g, "")
?.replaceAll(/[\u2018\u2019\u201A]/gm, "'")
?.replaceAll("&rsquo;", "'")
?.replaceAll(/[\u201C\u201D\u201E]/gm, '"')
?.replaceAll("&ldquo;", '"')
?.replaceAll("&rdquo;", '"')
?.replaceAll("&nbsp;", " ")
?.slice(0, 160) || ""
);

dispatch({
type: "SET_ITEM_WEB",
Expand Down
Loading

0 comments on commit 7b5c242

Please sign in to comment.