From ec17874568fd4f9f772ef54ccc687bbd73f6b0e7 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 22 Jun 2021 07:35:38 -0700 Subject: [PATCH] Remove test harness --- app/components/RevisionDiffExample.js | 32 ------------------- app/routes/index.js | 7 ---- package.json | 2 +- server/api/revisions.js | 24 -------------- .../__snapshots__/markdownDiff.test.js.snap | 16 +++------- server/utils/markdownDiff.test.js | 12 +++++-- 6 files changed, 15 insertions(+), 78 deletions(-) delete mode 100644 app/components/RevisionDiffExample.js diff --git a/app/components/RevisionDiffExample.js b/app/components/RevisionDiffExample.js deleted file mode 100644 index ef2eae1b59..0000000000 --- a/app/components/RevisionDiffExample.js +++ /dev/null @@ -1,32 +0,0 @@ -// @flow -import * as React from "react"; -import styled from "styled-components"; -import { client } from "utils/ApiClient"; - -export default function RevisionDiffExample() { - const [diff, setDiff] = React.useState(""); - - React.useEffect(() => { - const fetchData = async () => { - const res = await client.post("/revisions.diff_example", {}); - console.log({ res }); - setDiff(res.data.diff); - }; - - fetchData(); - }, []); - - return ; -} - -const Container = styled.div` - ins { - color: green; - text-decoration: none; - } - - del { - color: red; - text-decoration: strikethrough; - } -`; diff --git a/app/routes/index.js b/app/routes/index.js index 7d052902b5..f3d93a352e 100644 --- a/app/routes/index.js +++ b/app/routes/index.js @@ -4,7 +4,6 @@ import { Switch } from "react-router-dom"; import DelayedMount from "components/DelayedMount"; import FullscreenLoading from "components/FullscreenLoading"; import Route from "components/ProfiledRoute"; -import RevisionDiffExample from "components/RevisionDiffExample"; import { matchDocumentSlug as slug } from "utils/routeHelpers"; const Authenticated = React.lazy(() => @@ -39,12 +38,6 @@ export default function Routes() { - {/* TODO this is just a development harness -- delete later */} - { }; }); -// TODO: dev harness for revision diffs -if (process.env.NODE_ENV !== "production") { - router.post("revisions.diff_example", auth(), pagination(), async (ctx) => { - let before = await fs.promises.readFile( - path.resolve(__dirname, "..", "test", "fixtures", "complex.md"), - "utf8" - ); - - let after = await fs.promises.readFile( - path.resolve(__dirname, "..", "test", "fixtures", "complexModified.md"), - "utf8" - ); - - const diff = markdownDiff(before, after); - - ctx.body = { - data: { diff }, - }; - }); -} - export default router; diff --git a/server/utils/__snapshots__/markdownDiff.test.js.snap b/server/utils/__snapshots__/markdownDiff.test.js.snap index 5c7aaa1de6..c79df6ac74 100644 --- a/server/utils/__snapshots__/markdownDiff.test.js.snap +++ b/server/utils/__snapshots__/markdownDiff.test.js.snap @@ -1,13 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`should diff a complex document 1`] = ` -"

Heading 1

-

Heading 2

-

This is a test paragraph

-

This is a second test paragraph. This is a second sentence.

-

This is a another test paragraph. This is a another sentence.

-
    -
  • list item 1
  • +"
  • list item 1
  • list item 2
this is a codeblock
 

This is a new paragraph.

@@ -17,14 +11,14 @@ exports[`should diff a complex document 1`] = `

This is a placeholder

this is a highlight

    -
  • [ ]x]checklist item 1
  • [x]checklist item 2
  • -
  • [ ]checklist item 23
  • [ ]checklist item 4
  • -
  • [x]checklist item 35
  • " +
  • [ ]x]checklist item 1
  • [x]checklist item 2
  • +
  • [ ]checklist item 23
  • [ ]checklist item 4
  • +
  • [x]checklist item 35
  • " `; exports[`should mark changed nodes 1`] = `""`; exports[`should return everything inserted when previously empty 1`] = ` "

    Heading 1

    Heading 2

    This is a test paragraph

    This is a second test paragraph. This is a second sentence.

    This is a another test paragraph. This is a another sentence.

    • list item 1
    • list item 2
    this is a codeblock
    -

    This is an info block

    This is a placeholder

    this is a highlight

    • [ ]checklist item 1
    • [ ]checklist item 2
    • [x]checklist item 3

    same on both sides

    same on both sides

    same on both sides

    " +

    This is an info block

    This is a placeholder

    this is a highlight

    • [ ]checklist item 1
    • [ ]checklist item 2
    • [x]checklist item 3

    same on both sides

    same on both sides

    same on both sides

    " `; diff --git a/server/utils/markdownDiff.test.js b/server/utils/markdownDiff.test.js index 0718db28d1..5f2f1338a9 100644 --- a/server/utils/markdownDiff.test.js +++ b/server/utils/markdownDiff.test.js @@ -5,12 +5,18 @@ import markdownDiff from "./markdownDiff"; it("should diff a complex document", async () => { const before = await fs.promises.readFile( - path.resolve(__dirname, "..", "test", "fixtures", "complex.md"), + path.resolve(process.cwd(), "server", "test", "fixtures", "complex.md"), "utf8" ); const after = await fs.promises.readFile( - path.resolve(__dirname, "..", "test", "fixtures", "complexModified.md"), + path.resolve( + process.cwd(), + "server", + "test", + "fixtures", + "complexModified.md" + ), "utf8" ); @@ -25,7 +31,7 @@ it("should return empty string when both sides are empty", () => { it("should return everything inserted when previously empty", async () => { const content = await fs.promises.readFile( - path.resolve(__dirname, "..", "test", "fixtures", "complex.md"), + path.resolve(process.cwd(), "server", "test", "fixtures", "complex.md"), "utf8" );