Skip to content

Commit

Permalink
refactor: blog post to pitch
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas-C committed Oct 17, 2024
1 parent 8b7c48e commit eb2b58b
Show file tree
Hide file tree
Showing 29 changed files with 233 additions and 265 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions e2e/specs/blockpicker_frontpage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test("adds and removes grid", async ({ page }) => {
await page.getByTestId("slate-block-picker").click();
await expect(page.getByTestId("create-keyFigure")).toBeVisible();
await expect(page.getByTestId("create-image")).toBeVisible();
await expect(page.getByTestId("create-blogPost")).toBeVisible();
await expect(page.getByTestId("create-pitch")).toBeVisible();
await expect(page.getByTestId("slate-block-picker-menu").getByRole("button")).toHaveCount(6);
await expect(page.getByTestId("remove-grid")).toBeVisible();
await page.getByTestId("remove-grid").click();
Expand All @@ -47,20 +47,24 @@ test("adds and removes keyfigure", async ({ page }) => {
await expect(page.getByTestId("slate-key-figure")).toHaveCount(0);
});

test("adds and removes blogpost", async ({ page }) => {
await page.getByTestId("create-blogPost").click();
test("adds and removes pitch", async ({ page }) => {
await page.getByTestId("create-grid").click();
await expect(page.getByTestId("slate-grid-cell")).toHaveCount(2);
await page.getByTestId("slate-grid-cell").first().click();
await page.getByTestId("slate-block-picker").click();
await page.getByTestId("create-pitch").click();
await expect(page.getByRole("button", { name: "Lagre", exact: true })).toBeDisabled();
const modal = page.locator('div[role="dialog"]');
await modal.locator("div[name='title']").fill("test");
await page.locator("input[name='author']").fill("test");
await page.locator("div[name='description']").fill("test");
await page.locator("input[name='link']").fill("https://test.test");
await page.getByTestId("select-image-from-list").first().click();
await page.getByTestId("use-image").click();
await expect(page.getByRole("button", { name: "Lagre", exact: true })).toBeEnabled();
await page.getByRole("button", { name: "Lagre", exact: true }).click();
await expect(page.getByTestId("slate-blog-post")).toBeVisible();
await page.getByTestId("remove-blogpost").click();
await expect(page.getByTestId("slate-blog-post")).toHaveCount(0);
await expect(page.getByTestId("slate-pitch")).toBeVisible();
await page.getByTestId("remove-pitch").click();
await expect(page.getByTestId("slate-pitch")).toHaveCount(0);
});

test("adds and removes contactblock", async ({ page }) => {
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"@emotion/babel-plugin": "11.11.0",
"@emotion/eslint-plugin": "11.11.0",
"@emotion/jest": "11.11.0",
"@ndla/preset-panda": "^0.0.40",
"@ndla/preset-panda": "^0.0.41",
"@ndla/scripts": "^2.1.2",
"@ndla/types-backend": "^0.2.92",
"@ndla/types-embed": "^5.0.3-alpha.0",
"@ndla/types-embed": "^5.0.4-alpha.0",
"@ndla/types-taxonomy": "^1.0.30",
"@pandacss/dev": "^0.46.1",
"@playwright/test": "^1.42.0",
Expand Down Expand Up @@ -84,24 +84,24 @@
"@fontsource/source-code-pro": "^4.5.9",
"@fontsource/source-sans-pro": "^4.5.9",
"@fontsource/source-serif-pro": "^4.5.7",
"@ndla/article-converter": "^10.0.55-alpha.0",
"@ndla/audio-search": "^7.0.47-alpha.0",
"@ndla/button": "^15.0.32-alpha.0",
"@ndla/article-converter": "^10.0.56-alpha.0",
"@ndla/audio-search": "^7.0.48-alpha.0",
"@ndla/button": "^15.0.33-alpha.0",
"@ndla/error-reporter": "^2.0.4",
"@ndla/forms": "^10.0.46-alpha.0",
"@ndla/icons": "^8.0.31-alpha.0",
"@ndla/image-search": "^11.0.49-alpha.0",
"@ndla/forms": "^10.0.47-alpha.0",
"@ndla/icons": "^8.0.32-alpha.0",
"@ndla/image-search": "^11.0.50-alpha.0",
"@ndla/licenses": "^8.0.3-alpha.0",
"@ndla/modal": "^8.0.31-alpha.0",
"@ndla/primitives": "^1.0.46-alpha.0",
"@ndla/safelink": "^7.0.46-alpha.0",
"@ndla/select": "^6.0.31-alpha.0",
"@ndla/modal": "^8.0.32-alpha.0",
"@ndla/primitives": "^1.0.47-alpha.0",
"@ndla/safelink": "^7.0.47-alpha.0",
"@ndla/select": "^6.0.32-alpha.0",
"@ndla/styled-system": "^0.0.24",
"@ndla/tracker": "^5.0.9",
"@ndla/typography": "^0.4.25",
"@ndla/ui": "^56.0.52-alpha.0",
"@ndla/ui": "^56.0.53-alpha.0",
"@ndla/util": "^5.0.0-alpha.0",
"@ndla/video-search": "^8.0.46-alpha.0",
"@ndla/video-search": "^8.0.47-alpha.0",
"@radix-ui/react-popover": "^1.0.3",
"@radix-ui/react-portal": "^1.0.3",
"@radix-ui/react-toolbar": "^1.0.4",
Expand Down
10 changes: 5 additions & 5 deletions src/components/HowTo/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type StoryType =
| "CodeBlock"
| "Concept"
| "ConceptList"
| "BlogPost"
| "Pitch"
| "status"
| "ContactBlock"
| "Grid"
Expand Down Expand Up @@ -324,13 +324,13 @@ export const stories: Record<StoryType, Story> = {
},
],
},
BlogPost: {
title: "Blogginnlegg",
lead: "Legg til et blogginnlegg",
Pitch: {
title: "Pitch",
lead: "Legg til en pitch",
body: [
{
type: "text",
content: "Lim inn lenke til artikkel og legg til tittel for å generere en bloggpost.",
content: "Lim inn lenke til artikkel og legg til tittel for å generere en pitch.",
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/SlateEditor/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/
import { TYPE_ASIDE } from "./plugins/aside/types";
import { TYPE_AUDIO } from "./plugins/audio/types";
import { TYPE_BLOGPOST } from "./plugins/blogPost/types";
import { TYPE_CAMPAIGN_BLOCK } from "./plugins/campaignBlock/types";
import { TYPE_CODEBLOCK } from "./plugins/codeBlock/types";
import { TYPE_COMMENT_INLINE } from "./plugins/comment/inline/types";
Expand All @@ -24,6 +23,7 @@ import { TYPE_IMAGE } from "./plugins/image/types";
import { TYPE_KEY_FIGURE } from "./plugins/keyFigure/types";
import { TYPE_LINK, TYPE_CONTENT_LINK } from "./plugins/link/types";
import { TYPE_MATHML } from "./plugins/mathml/types";
import { TYPE_PITCH } from "./plugins/pitch/types";
import { TYPE_RELATED } from "./plugins/related/types";
import { TYPE_SPAN } from "./plugins/span/types";
import { TYPE_TABLE } from "./plugins/table/types";
Expand Down Expand Up @@ -53,7 +53,7 @@ export const blocks = [
TYPE_FILE,
TYPE_RELATED,
TYPE_TABLE,
TYPE_BLOGPOST,
TYPE_PITCH,
TYPE_GRID,
TYPE_KEY_FIGURE,
TYPE_CAMPAIGN_BLOCK,
Expand Down
4 changes: 2 additions & 2 deletions src/components/SlateEditor/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { ReactEditor, RenderElementProps, RenderLeafProps } from "slate-react";
import { AsideElement } from "./plugins/aside";
import { AudioElement } from "./plugins/audio/types";
import { BlockQuoteElement } from "./plugins/blockquote";
import { BlogPostElement } from "./plugins/blogPost/types";
import { BreakElement } from "./plugins/break";
import { CampaignBlockElement } from "./plugins/campaignBlock";
import { CodeblockElement } from "./plugins/codeBlock";
Expand Down Expand Up @@ -40,6 +39,7 @@ import { CustomTextWithMarks } from "./plugins/mark";
import { MathmlElement } from "./plugins/mathml";
import { NoopElement } from "./plugins/noop";
import { ParagraphElement } from "./plugins/paragraph";
import { PitchElement } from "./plugins/pitch/types";
import { RelatedElement } from "./plugins/related";
import { SectionElement } from "./plugins/section";
import { SpanElement } from "./plugins/span";
Expand Down Expand Up @@ -114,7 +114,7 @@ declare module "slate" {
| DefinitionListElement
| DefinitionDescriptionElement
| DefinitionTermElement
| BlogPostElement
| PitchElement
| GridElement
| GridCellElement
| KeyFigureElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import getCurrentBlock from "../../utils/getCurrentBlock";
import { TYPE_ASIDE } from "../aside/types";
import { defaultAsideBlock } from "../aside/utils";
import { TYPE_AUDIO } from "../audio/types";
import { TYPE_BLOGPOST } from "../blogPost/types";
import { defaultBlogPostBlock } from "../blogPost/utils";
import { TYPE_CAMPAIGN_BLOCK } from "../campaignBlock/types";
import { defaultCampaignBlock } from "../campaignBlock/utils";
import { TYPE_CODEBLOCK } from "../codeBlock/types";
Expand Down Expand Up @@ -56,6 +54,8 @@ import { defaultLinkBlockList } from "../linkBlockList";
import { TYPE_LINK_BLOCK_LIST } from "../linkBlockList/types";
import { TYPE_LIST_ITEM } from "../list/types";
import { TYPE_PARAGRAPH } from "../paragraph/types";
import { TYPE_PITCH } from "../pitch/types";
import { defaultPitchBlock } from "../pitch/utils";
import { defaultRelatedBlock } from "../related";
import { TYPE_RELATED } from "../related/types";
import { defaultTableBlock } from "../table/defaultBlocks";
Expand Down Expand Up @@ -335,8 +335,8 @@ const SlateBlockPicker = ({
onInsertBlock(defaultCodeblockBlock());
break;
}
case TYPE_BLOGPOST: {
onInsertBlock(defaultBlogPostBlock());
case TYPE_PITCH: {
onInsertBlock(defaultPitchBlock());
break;
}
case TYPE_CONCEPT_BLOCK: {
Expand Down
6 changes: 3 additions & 3 deletions src/components/SlateEditor/plugins/blockPicker/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import HowToHelper from "../../../HowTo/HowToHelper";
import { StoryType } from "../../../HowTo/stories";
import { TYPE_ASIDE } from "../aside/types";
import { TYPE_AUDIO } from "../audio/types";
import { TYPE_BLOGPOST } from "../blogPost/types";
import { TYPE_CAMPAIGN_BLOCK } from "../campaignBlock/types";
import { TYPE_CODEBLOCK } from "../codeBlock/types";
import { TYPE_COMMENT_BLOCK } from "../comment/block/types";
Expand All @@ -53,6 +52,7 @@ import { TYPE_H5P } from "../h5p/types";
import { TYPE_IMAGE } from "../image/types";
import { TYPE_KEY_FIGURE } from "../keyFigure/types";
import { TYPE_LINK_BLOCK_LIST } from "../linkBlockList/types";
import { TYPE_PITCH } from "../pitch/types";
import { TYPE_RELATED } from "../related/types";
import { TYPE_TABLE } from "../table/types";
import { TYPE_DISCLAIMER } from "../uuDisclaimer/types";
Expand Down Expand Up @@ -168,9 +168,9 @@ export const frontpageActions = commonActions.concat(
helpIcon: renderArticleInModal("Grid"),
},
{
data: { type: TYPE_BLOGPOST, object: "blogPost" },
data: { type: TYPE_PITCH, object: "pitch" },
icon: <BlogPost />,
helpIcon: renderArticleInModal("BlogPost"),
helpIcon: renderArticleInModal("Pitch"),
},
{
data: { type: TYPE_KEY_FIGURE, object: "keyFigure" },
Expand Down
4 changes: 2 additions & 2 deletions src/components/SlateEditor/plugins/grid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import { reduceElementDataAttributesV2 } from "../../../../util/embedTagHelpers"
import { SlateSerializer } from "../../interfaces";
import { defaultBlockNormalizer, NormalizerConfig } from "../../utils/defaultNormalizer";
import { afterOrBeforeTextBlockElement } from "../../utils/normalizationHelpers";
import { TYPE_BLOGPOST } from "../blogPost/types";
import { TYPE_HEADING } from "../heading/types";
import { TYPE_IMAGE } from "../image/types";
import { TYPE_KEY_FIGURE } from "../keyFigure/types";
import { TYPE_LIST } from "../list/types";
import { TYPE_PARAGRAPH } from "../paragraph/types";
import { TYPE_PITCH } from "../pitch/types";

export interface GridElement {
type: "grid";
Expand Down Expand Up @@ -53,7 +53,7 @@ const normalizerConfig: NormalizerConfig = {

const normalizerConfigGridCell: NormalizerConfig = {
nodes: {
allowed: [TYPE_KEY_FIGURE, TYPE_BLOGPOST, TYPE_PARAGRAPH, TYPE_IMAGE, TYPE_HEADING, TYPE_LIST],
allowed: [TYPE_KEY_FIGURE, TYPE_PITCH, TYPE_PARAGRAPH, TYPE_IMAGE, TYPE_HEADING, TYPE_LIST],
defaultType: TYPE_PARAGRAPH,
},
};
Expand Down
Loading

0 comments on commit eb2b58b

Please sign in to comment.