-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notifies user before discarding unsaved resource. Disables Save butto…
…n when no changes. closes #313
- Loading branch information
1 parent
642fe84
commit 972030b
Showing
17 changed files
with
248 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2019 Stanford University see LICENSE for license | ||
|
||
import React from 'react' | ||
import { shallow } from 'enzyme' | ||
import SaveAndPublishButton from 'components/editor/SaveAndPublishButton' | ||
import Button from 'react-bootstrap/lib/Button' | ||
|
||
describe('<SaveAndPublishButton />', () => { | ||
const mockSave = jest.fn() | ||
describe('when disabled', () => { | ||
const wrapper = shallow(<SaveAndPublishButton.WrappedComponent isDisabled={true} save={mockSave}/>) | ||
it('the button is disabled', () => { | ||
expect(wrapper.find(Button).prop('disabled')).toEqual(true) | ||
}) | ||
}) | ||
describe('when not disabled', () => { | ||
const wrapper = shallow(<SaveAndPublishButton.WrappedComponent isDisabled={false} save={mockSave}/>) | ||
it('the button is not disabled', () => { | ||
expect(wrapper.find(Button).prop('disabled')).toEqual(false) | ||
}) | ||
}) | ||
describe('clicking the button', () => { | ||
const wrapper = shallow(<SaveAndPublishButton.WrappedComponent isDisabled={false} save={mockSave} isSaved={false} currentUser="Wilford Brimley" />) | ||
it('calls save', () => { | ||
wrapper.find(Button).simulate('click') | ||
expect(mockSave).toHaveBeenCalledWith(false, 'Wilford Brimley') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2019 Stanford University see LICENSE for license | ||
|
||
import pupExpect from 'expect-puppeteer' | ||
import { testUserLogin } from './loginHelper' | ||
|
||
describe('Leaving the editor', () => { | ||
beforeAll(async () => { | ||
await testUserLogin() | ||
}) | ||
|
||
it('prompts the user before leaving', async () => { | ||
expect.assertions(8) | ||
|
||
// Load up a Bibframe Instance | ||
await pupExpect(page).toClick('a', { text: 'BIBFRAME Instance' }) | ||
await pupExpect(page).toMatchElement('a', { text: 'Editor' }) | ||
|
||
const dialog1 = await expect(page).toDisplayDialog(async () => { | ||
await pupExpect(page).toClick('a', { text: 'Load RDF' }) | ||
}) | ||
await dialog1.dismiss() | ||
await pupExpect(page).not.toMatch('Resource RDF N3') | ||
|
||
const dialog2 = await expect(page).toDisplayDialog(async () => { | ||
await pupExpect(page).toClick('a', { text: 'Load RDF' }) | ||
}) | ||
await dialog2.accept() | ||
await pupExpect(page).toMatch('Resource RDF N3') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.