diff --git a/README.md b/README.md index 1b83b3ba2..01595d98e 100644 --- a/README.md +++ b/README.md @@ -294,7 +294,6 @@ function BlogPost({ data }) { const image = getImage(data.file) return (
-

{data.blogPost.title}

) diff --git a/lib/cypress/component/index.spec.jsx b/lib/cypress/component/index.spec.jsx deleted file mode 100644 index ecbc5ae21..000000000 --- a/lib/cypress/component/index.spec.jsx +++ /dev/null @@ -1,144 +0,0 @@ -import React from "react"; -import Test from "../../testing-components/Test"; -import TestUseStoryblok from "../../testing-components/TestUseStoryblok"; -import { mount } from "@cypress/react"; -import Teaser from "gatsby-source-storyblok-playground/components/teaser"; -import Grid from "gatsby-source-storyblok-playground/components/grid"; -import Feature from "gatsby-source-storyblok-playground/components/feature"; -import Page from "gatsby-source-storyblok-playground/components/page"; - -describe("gatsby-source-storyblok", () => { - beforeEach(() => { - cy.spy(window.console, "log").as("log"); - cy.spy(window.console, "error").as("error"); - delete window.storyblokRegisterEvent; - document.getElementById("storyblok-javascript-bridge")?.remove(); - }); - - describe("JS Bridge", () => { - it("loads by default", () => { - mount(); - cy.get("#storyblok-javascript-bridge").should("exist"); - }); - - it("doesn't load if the bridge is disabled", () => { - mount(); - cy.get("#storyblok-javascript-bridge").should("not.exist"); - cy.get("@error").should( - "be.calledWithMatch", - "Storyblok Bridge is disabled" - ); - }); - }); - - describe("getStoryblokApi", () => { - it("should return an instance of the API if we use the API Plugin", () => { - mount(); - cy.get('[data-test="api"]').should("have.text", "true"); - }); - - it("shouldn't return an instance of the API if no access token is provided", () => { - mount(); - cy.get('[data-test="api"]').should("have.text", "false"); - }); - - it("should return an error message when no access token is provided", () => { - mount(); - cy.get("@error").should( - "be.calledWithMatch", - "You can't use getStoryblokApi" - ); - }); - }); - - describe("StoryblokComponent", () => { - it("Should render the StoryblokComponent if the blok is passed", () => { - const blok = { - component: "teaser", - headline: "Hello React", - _editable: ``, - }; - - const components = { - teaser: Teaser, - }; - - mount( - - ); - - cy.get('[data-test="teaser"]').should("exist"); - cy.get("[data-test=teaser]") - .should("have.attr", "data-blok-c") - .and("equals", '{"id":12345,"uid":"fc34-uad1"}'); - - cy.get("[data-test=teaser]") - .should("have.attr", "data-blok-uid") - .and("equals", "12345-fc34-uad1"); - }); - - it("Should log an error if the blok is not loaded", () => { - const components = { - teaser: Teaser, - }; - - mount( - - ); - - cy.get('[data-test="teaser"]').should("not.exist"); - cy.get("@error").should("be.calledWithMatch", "Please provide a 'blok'"); - }); - - it("Should log an error if the component is not loaded", () => { - const blok = { - component: "teaser", - headline: "Hello React", - _editable: ``, - }; - - mount(); - - cy.get('[data-test="teaser"]').should("not.exist"); - cy.get("@error").should( - "be.calledWithMatch", - "Component teaser doesn't exist." - ); - }); - }); - - describe("useStoryblok", () => { - it("Should render the StoryblokComponent", () => { - const components = { - teaser: Teaser, - grid: Grid, - feature: Feature, - page: Page, - }; - - mount( - - ); - - cy.get('[data-test="page"]').should("exist"); - cy.get('[data-test="grid"]').should("exist"); - cy.get('[data-test="feature"]').should("have.length", 3); - }); - - it("Should log an error if no using the apiPlugin", () => { - mount(); - - cy.get("@error").should( - "be.calledWithMatch", - "You can't use useStoryblok" - ); - }); - }); -}); diff --git a/lib/package.json b/lib/package.json index 6e1733235..ac22df652 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,10 +1,5 @@ { "name": "gatsby-source-storyblok", - "contributors": [ - { - "name": "Alexander Feiglstorfer " - } - ], "version": "4.0.0", "description": "SDK to integrate Storyblok into your project using Gatsby.", "main": "./dist/gatsby-source-storyblok.js", diff --git a/lib/testing-components/TestUseStoryblok.jsx b/lib/testing-components/TestUseStoryblok.jsx deleted file mode 100644 index 49407a6bb..000000000 --- a/lib/testing-components/TestUseStoryblok.jsx +++ /dev/null @@ -1,24 +0,0 @@ -import { - storyblokInit, - apiPlugin, - useStoryblok, - StoryblokComponent, -} from "gatsby-source-storyblok"; - -const TestUseStoryblok = ({ accessToken, components }) => { - storyblokInit({ - accessToken, - use: accessToken ? [apiPlugin] : [], - components, - }); - - const story = useStoryblok("react", { version: "draft" }); - - if (!story) { - return
Loading...
; - } - - return ; -}; - -export default TestUseStoryblok; diff --git a/playground-test/components/feature.jsx b/playground-test/components/feature.jsx deleted file mode 100644 index 698fd05b7..000000000 --- a/playground-test/components/feature.jsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from "react"; -import { storyblokEditable } from "gatsby-source-storyblok"; - -const Feature = ({ blok }) => { - return ( -
-
-
{blok.name}
-

{blok.description}

-
-
- ); -}; - -export default Feature; diff --git a/playground-test/components/grid.jsx b/playground-test/components/grid.jsx deleted file mode 100644 index 266e90034..000000000 --- a/playground-test/components/grid.jsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from "react"; -import { StoryblokComponent, storyblokEditable } from "gatsby-source-storyblok"; - -const Grid = ({ blok }) => ( -
    - {blok.columns.map((nestedBlok) => ( -
  • - -
  • - ))} -
-); - -export default Grid; diff --git a/playground-test/components/page.jsx b/playground-test/components/page.jsx deleted file mode 100644 index ccc1f69c8..000000000 --- a/playground-test/components/page.jsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from "react"; -import { StoryblokComponent, storyblokEditable } from "gatsby-source-storyblok"; - -const Page = ({ blok }) => ( -
- {blok.body - ? blok.body.map((nestedBlok) => ( -
- -
- )) - : null} -
-); - -export default Page; diff --git a/playground-test/components/teaser.jsx b/playground-test/components/teaser.jsx deleted file mode 100644 index cbd2108c9..000000000 --- a/playground-test/components/teaser.jsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from "react"; -import { storyblokEditable } from "gatsby-source-storyblok"; - -const Teaser = ({ blok }) => { - return ( -
-
-

{blok.headline}

-
-
- ); -}; - -export default Teaser; diff --git a/playground/components/feature.jsx b/playground/components/feature.jsx deleted file mode 100644 index 698fd05b7..000000000 --- a/playground/components/feature.jsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from "react"; -import { storyblokEditable } from "gatsby-source-storyblok"; - -const Feature = ({ blok }) => { - return ( -
-
-
{blok.name}
-

{blok.description}

-
-
- ); -}; - -export default Feature; diff --git a/playground/components/grid.jsx b/playground/components/grid.jsx deleted file mode 100644 index 266e90034..000000000 --- a/playground/components/grid.jsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from "react"; -import { StoryblokComponent, storyblokEditable } from "gatsby-source-storyblok"; - -const Grid = ({ blok }) => ( -
    - {blok.columns.map((nestedBlok) => ( -
  • - -
  • - ))} -
-); - -export default Grid; diff --git a/playground/components/page.jsx b/playground/components/page.jsx deleted file mode 100644 index ccc1f69c8..000000000 --- a/playground/components/page.jsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from "react"; -import { StoryblokComponent, storyblokEditable } from "gatsby-source-storyblok"; - -const Page = ({ blok }) => ( -
- {blok.body - ? blok.body.map((nestedBlok) => ( -
- -
- )) - : null} -
-); - -export default Page; diff --git a/playground/components/teaser.jsx b/playground/components/teaser.jsx deleted file mode 100644 index cbd2108c9..000000000 --- a/playground/components/teaser.jsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from "react"; -import { storyblokEditable } from "gatsby-source-storyblok"; - -const Teaser = ({ blok }) => { - return ( -
-
-

{blok.headline}

-
-
- ); -}; - -export default Teaser;