Skip to content

Commit

Permalink
Merge pull request #129 from public-accountability/develop2
Browse files Browse the repository at this point in the history
setting to start in editor mode
  • Loading branch information
aepyornis authored Dec 14, 2022
2 parents 56d4a4b + 4975e5a commit d234fe3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
2 changes: 2 additions & 0 deletions app/util/defaultState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export interface SettingsState {
logActions: boolean
bugReportUrl: string | null
helpUrl: string | null
startInEditMode: boolean
}

export interface StateWithoutHistory {
Expand Down Expand Up @@ -253,6 +254,7 @@ const defaultState: State = {
logActions: false,
bugReportUrl: "https://littlesis.org/bug_report",
helpUrl: "https://littlesis.org/help/oligrapher",
startInEditMode: false,
},

// for Undo/Redo
Expand Down
2 changes: 1 addition & 1 deletion app/util/stateInitializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default function stateInitializer(legacyState: any): State {

state.graph = convertGraph(state.graph)

state.display.modes.editor = userCanEditSelector(state)
state.display.modes.editor = state.settings.startInEditMode && userCanEditSelector(state)
state.display.viewBox = calculateViewBoxFromGraph(state.graph)
state.display.modes.story = calculateStoryMode(state)

Expand Down
2 changes: 1 addition & 1 deletion html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<script>
const oli = new Oligrapher({
settings: { logActions: true },
settings: { logActions: true, startInEditMode: true },
attributes: {
title: "Blank Map",
date: "January 12, 2018",
Expand Down
28 changes: 16 additions & 12 deletions test/components/Header.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
import { screen } from '@testing-library/react'
import Header from '../../app/components/Header'
import { wrapInThemeProvider } from '../helpers'
import { screen } from "@testing-library/react"
import Header from "../../app/components/Header"
import { wrapInThemeProvider } from "../helpers"

const attributes = {
const attributes = {
title: "Example Title",
subtitle: "Example Subtitle",
user: { id: "1", "name": "Bob", "url": "https://example.com/bob" },
owner: { id: "1", "name": "Bob", "url": "https://example.com/bob" }
user: { id: "1", name: "Bob", url: "https://example.com/bob" },
owner: { id: "1", name: "Bob", url: "https://example.com/bob" },
}


test('Shows title in Header', async () => {
const result = renderWithStore(wrapInThemeProvider(createElement(Header)), null, { attributes, settings: { noEditing: true} })
test("Shows title in Header", async () => {
const result = renderWithStore(wrapInThemeProvider(createElement(Header)), null, {
attributes,
settings: { noEditing: true },
})
expect(result.container.querySelector("#oligrapher-header")).toBeTruthy()
expect(result.container.querySelector("h1#oligrapher-title").textContent).toEqual("Example Title")
expect(screen.queryByTestId("oligrapher-header-toggler")).not.toBeInTheDocument()
expect(screen.queryByTestId("oligrapher-title-input")).not.toBeInTheDocument()
})


test('Shows toggler and input when editor', async () => {
const result = renderWithStore(wrapInThemeProvider(createElement(Header)), null, { attributes })
test("Shows toggler and input when editor", async () => {
const result = renderWithStore(wrapInThemeProvider(createElement(Header)), null, {
attributes,
settings: { startInEditMode: true },
})
expect(result.container.querySelector("#oligrapher-header")).toBeTruthy()
expect(screen.queryByTestId("oligrapher-header-toggler")).toBeInTheDocument()
expect(screen.queryByTestId("oligrapher-title-input")).toBeInTheDocument()
Expand Down

0 comments on commit d234fe3

Please sign in to comment.