Skip to content

Commit

Permalink
Merge pull request #1386 from klembot/develop
Browse files Browse the repository at this point in the history
2.6.2
  • Loading branch information
klembot authored Feb 26, 2023
2 parents 4116ffe + 9839c7a commit de3ac43
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 68 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Twine",
"version": "2.6.1",
"version": "2.6.2",
"description": "a GUI for creating nonlinear stories",
"author": "Chris Klimas <chris@twinery.org>",
"license": "GPL-3.0",
Expand Down
1 change: 0 additions & 1 deletion public/story-formats/chapbook-1.2.1/format.js

This file was deleted.

1 change: 0 additions & 1 deletion public/story-formats/chapbook-1.2.2/format.js

This file was deleted.

1 change: 0 additions & 1 deletion public/story-formats/chapbook-1.2.2/logo.svg

This file was deleted.

1 change: 1 addition & 0 deletions public/story-formats/chapbook-1.2.3/format.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions public/story-formats/harlowe-3.3.4/format.js

This file was deleted.

4 changes: 4 additions & 0 deletions public/story-formats/harlowe-3.3.5/format.js

Large diffs are not rendered by default.

File renamed without changes
48 changes: 7 additions & 41 deletions src/dialogs/passage-edit/__tests__/passage-toolbar.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
act,
cleanup,
fireEvent,
render,
screen,
within
} from '@testing-library/react';
import {act, fireEvent, render, screen, within} from '@testing-library/react';
import {axe} from 'jest-axe';
import * as React from 'react';
import {useStoriesContext} from '../../../store/stories';
Expand Down Expand Up @@ -69,40 +62,13 @@ describe('<PassageToolbar>', () => {
).toBe('mock-new-passage-name');
});

it('displays a checkbox button showing whether the passage is the start passage', async () => {
const story = fakeStory(2);

await renderComponent({stories: [story]});

let startCheckbox = screen.getByRole('checkbox', {
name: 'dialogs.passageEdit.setAsStart'
});

expect(startCheckbox).toBeChecked();
// See https://github.com/testing-library/jest-dom/issues/144
expect(startCheckbox).toHaveAttribute('aria-disabled', 'true');
cleanup();
story.startPassage = story.passages[1].id;
await renderComponent({stories: [story]});
startCheckbox = screen.getByRole('checkbox', {
name: 'dialogs.passageEdit.setAsStart'
});
expect(startCheckbox).not.toBeChecked();
expect(startCheckbox).not.toHaveAttribute('aria-disabled', 'true');
});

it('sets the passage as the start one if the user uses the checkbox button', async () => {
const story = fakeStory(2);

story.startPassage = story.passages[1].id;
await renderComponent({stories: [story]});
expect(
screen.getByTestId('story-inspector-default').dataset.startPassage
).toBe(story.passages[1].id);
fireEvent.click(screen.getByText('dialogs.passageEdit.setAsStart'));
it('displays a button to test the story from this passage', () => {
renderComponent();
expect(
screen.getByTestId('story-inspector-default').dataset.startPassage
).toBe(story.passages[0].id);
screen.getByRole('button', {
name: 'routes.storyEdit.toolbar.testFromHere'
})
).toBeVisible();
});

// Need a higher-fidelity mock of <MenuButton> that includes checked state.
Expand Down
17 changes: 3 additions & 14 deletions src/dialogs/passage-edit/passage-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ import * as React from 'react';
import {useTranslation} from 'react-i18next';
import {UndoRedoButtons} from '../../components/codemirror';
import {ButtonBar} from '../../components/container/button-bar';
import {CheckboxButton} from '../../components/control/checkbox-button';
import {MenuButton} from '../../components/control/menu-button';
import {RenamePassageButton} from '../../components/passage/rename-passage-button';
import {AddTagButton} from '../../components/tag';
import { TestPassageButton } from '../../routes/story-edit/toolbar/passage/test-passage-button';
import {
addPassageTag,
Passage,
setTagColor,
Story,
storyPassageTags,
updatePassage,
updateStory
} from '../../store/stories';
import {useUndoableStoriesContext} from '../../store/undoable-stories';
import {Color} from '../../util/color';
Expand All @@ -29,9 +28,8 @@ export interface PassageToolbarProps {

export const PassageToolbar: React.FC<PassageToolbarProps> = props => {
const {disabled, editor, passage, story} = props;
const {dispatch, stories} = useUndoableStoriesContext();
const {dispatch} = useUndoableStoriesContext();
const {t} = useTranslation();
const isStart = story.startPassage === passage.id;

function handleAddTag(name: string, color?: Color) {
// Kind of tricky. We make adding the tag to the passage undoable, but not
Expand Down Expand Up @@ -59,10 +57,6 @@ export const PassageToolbar: React.FC<PassageToolbarProps> = props => {
dispatch(updatePassage(story, passage, {name}, {dontUpdateOthers: true}));
}

function handleSetAsStart() {
dispatch(updateStory(stories, story, {startPassage: passage.id}));
}

function handleSetSize({height, width}: {height: number; width: number}) {
dispatch(updatePassage(story, passage, {height, width}));
}
Expand Down Expand Up @@ -117,12 +111,7 @@ export const PassageToolbar: React.FC<PassageToolbarProps> = props => {
passage={passage}
story={story}
/>
<CheckboxButton
disabled={disabled || isStart}
label={t('dialogs.passageEdit.setAsStart')}
onChange={handleSetAsStart}
value={isStart}
/>
<TestPassageButton passage={passage} story={story} />
</ButtonBar>
);
};
2 changes: 1 addition & 1 deletion src/store/prefs/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const defaults = (): PrefsState => ({
},
storyFormat: {
name: 'Harlowe',
version: '3.3.4'
version: '3.3.5'
},
storyFormatListFilter: 'current',
storyListSort: 'name',
Expand Down
8 changes: 4 additions & 4 deletions src/store/story-formats/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const builtins = () => [
{
name: 'Chapbook',
url: 'story-formats/chapbook-1.2.2/format.js',
version: '1.2.2'
url: 'story-formats/chapbook-1.2.3/format.js',
version: '1.2.3'
},
{
name: 'Harlowe',
Expand All @@ -16,8 +16,8 @@ export const builtins = () => [
},
{
name: 'Harlowe',
url: 'story-formats/harlowe-3.3.4/format.js',
version: '3.3.4'
url: 'story-formats/harlowe-3.3.5/format.js',
version: '3.3.5'
},
{
name: 'Paperthin',
Expand Down

0 comments on commit de3ac43

Please sign in to comment.