|
@@ -2,12 +2,12 @@ import { expect } from 'chai'
|
|
|
import sinon from 'sinon'
|
|
import sinon from 'sinon'
|
|
|
import React from 'react'
|
|
import React from 'react'
|
|
|
import {
|
|
import {
|
|
|
- act,
|
|
|
|
|
cleanup,
|
|
cleanup,
|
|
|
render,
|
|
render,
|
|
|
screen,
|
|
screen,
|
|
|
fireEvent,
|
|
fireEvent,
|
|
|
- waitFor
|
|
|
|
|
|
|
+ waitFor,
|
|
|
|
|
+ waitForElementToBeRemoved
|
|
|
} from '@testing-library/react'
|
|
} from '@testing-library/react'
|
|
|
import fetchMock from 'fetch-mock'
|
|
import fetchMock from 'fetch-mock'
|
|
|
import ShareProjectModal from '../../../../../frontend/js/features/share-project-modal/components/share-project-modal'
|
|
import ShareProjectModal from '../../../../../frontend/js/features/share-project-modal/components/share-project-modal'
|
|
@@ -69,12 +69,21 @@ describe('<ShareProjectModal/>', function() {
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
|
|
+ const ideWithProject = project => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ $scope: {
|
|
|
|
|
+ $watch: () => () => {},
|
|
|
|
|
+ $applyAsync: () => {},
|
|
|
|
|
+ project
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const modalProps = {
|
|
const modalProps = {
|
|
|
|
|
+ ide: ideWithProject(project),
|
|
|
show: true,
|
|
show: true,
|
|
|
isAdmin: true,
|
|
isAdmin: true,
|
|
|
- project,
|
|
|
|
|
- handleHide: sinon.stub(),
|
|
|
|
|
- updateProject: sinon.stub()
|
|
|
|
|
|
|
+ handleHide: sinon.stub()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const originalExposedSettings = window.ExposedSettings
|
|
const originalExposedSettings = window.ExposedSettings
|
|
@@ -122,7 +131,7 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{ ...project, publicAccesLevel: 'private' }}
|
|
|
|
|
|
|
+ ide={ideWithProject({ ...project, publicAccesLevel: 'private' })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -141,7 +150,7 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{ ...project, publicAccesLevel: 'tokenBased' }}
|
|
|
|
|
|
|
+ ide={ideWithProject({ ...project, publicAccesLevel: 'tokenBased' })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -158,7 +167,7 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{ ...project, publicAccesLevel: 'readAndWrite' }}
|
|
|
|
|
|
|
+ ide={ideWithProject({ ...project, publicAccesLevel: 'readAndWrite' })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -172,7 +181,7 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{ ...project, publicAccesLevel: 'readOnly' }}
|
|
|
|
|
|
|
+ ide={ideWithProject({ ...project, publicAccesLevel: 'readOnly' })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -195,7 +204,11 @@ describe('<ShareProjectModal/>', function() {
|
|
|
const { rerender } = render(
|
|
const { rerender } = render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{ ...project, invites, publicAccesLevel: 'tokenBased' }}
|
|
|
|
|
|
|
+ ide={ideWithProject({
|
|
|
|
|
+ ...project,
|
|
|
|
|
+ invites,
|
|
|
|
|
+ publicAccesLevel: 'tokenBased'
|
|
|
|
|
+ })}
|
|
|
isAdmin
|
|
isAdmin
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
@@ -207,7 +220,11 @@ describe('<ShareProjectModal/>', function() {
|
|
|
rerender(
|
|
rerender(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{ ...project, invites, publicAccesLevel: 'tokenBased' }}
|
|
|
|
|
|
|
+ ide={ideWithProject({
|
|
|
|
|
+ ...project,
|
|
|
|
|
+ invites,
|
|
|
|
|
+ publicAccesLevel: 'tokenBased'
|
|
|
|
|
+ })}
|
|
|
isAdmin={false}
|
|
isAdmin={false}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
@@ -222,17 +239,21 @@ describe('<ShareProjectModal/>', function() {
|
|
|
.null
|
|
.null
|
|
|
expect(screen.queryByRole('button', { name: 'Resend' })).to.be.null
|
|
expect(screen.queryByRole('button', { name: 'Resend' })).to.be.null
|
|
|
|
|
|
|
|
- // render as non-admin, link sharing off: actions should be missing and message should be present
|
|
|
|
|
|
|
+ // render as non-admin (non-owner), link sharing off: actions should be missing and message should be present
|
|
|
rerender(
|
|
rerender(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{ ...project, invites, publicAccesLevel: 'private' }}
|
|
|
|
|
|
|
+ ide={ideWithProject({
|
|
|
|
|
+ ...project,
|
|
|
|
|
+ invites,
|
|
|
|
|
+ publicAccesLevel: 'private'
|
|
|
|
|
+ })}
|
|
|
isAdmin={false}
|
|
isAdmin={false}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
await screen.findByText(
|
|
await screen.findByText(
|
|
|
- 'To add more collaborators or turn on link sharing, please ask the project owner'
|
|
|
|
|
|
|
+ 'To change access permissions, please ask the project owner'
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
expect(screen.queryByRole('button', { name: 'Turn off link sharing' })).to
|
|
expect(screen.queryByRole('button', { name: 'Turn off link sharing' })).to
|
|
@@ -248,7 +269,7 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{ ...project, publicAccesLevel: 'tokenBased' }}
|
|
|
|
|
|
|
+ ide={ideWithProject({ ...project, publicAccesLevel: 'tokenBased' })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -296,12 +317,12 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{
|
|
|
|
|
|
|
+ ide={ideWithProject({
|
|
|
...project,
|
|
...project,
|
|
|
members,
|
|
members,
|
|
|
invites,
|
|
invites,
|
|
|
publicAccesLevel: 'tokenBased'
|
|
publicAccesLevel: 'tokenBased'
|
|
|
- }}
|
|
|
|
|
|
|
+ })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -340,11 +361,11 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{
|
|
|
|
|
|
|
+ ide={ideWithProject({
|
|
|
...project,
|
|
...project,
|
|
|
invites,
|
|
invites,
|
|
|
publicAccesLevel: 'tokenBased'
|
|
publicAccesLevel: 'tokenBased'
|
|
|
- }}
|
|
|
|
|
|
|
+ })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -353,11 +374,9 @@ describe('<ShareProjectModal/>', function() {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const resendButton = screen.getByRole('button', { name: 'Resend' })
|
|
const resendButton = screen.getByRole('button', { name: 'Resend' })
|
|
|
|
|
+ fireEvent.click(resendButton)
|
|
|
|
|
|
|
|
- await act(async () => {
|
|
|
|
|
- await fireEvent.click(resendButton)
|
|
|
|
|
- expect(closeButton.disabled).to.be.true
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ await waitFor(() => expect(closeButton.disabled).to.be.true)
|
|
|
|
|
|
|
|
expect(fetchMock.done()).to.be.true
|
|
expect(fetchMock.done()).to.be.true
|
|
|
expect(closeButton.disabled).to.be.false
|
|
expect(closeButton.disabled).to.be.false
|
|
@@ -377,11 +396,11 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{
|
|
|
|
|
|
|
+ ide={ideWithProject({
|
|
|
...project,
|
|
...project,
|
|
|
invites,
|
|
invites,
|
|
|
publicAccesLevel: 'tokenBased'
|
|
publicAccesLevel: 'tokenBased'
|
|
|
- }}
|
|
|
|
|
|
|
+ })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -390,11 +409,8 @@ describe('<ShareProjectModal/>', function() {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const revokeButton = screen.getByRole('button', { name: 'Revoke' })
|
|
const revokeButton = screen.getByRole('button', { name: 'Revoke' })
|
|
|
-
|
|
|
|
|
- await act(async () => {
|
|
|
|
|
- await fireEvent.click(revokeButton)
|
|
|
|
|
- expect(closeButton.disabled).to.be.true
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ fireEvent.click(revokeButton)
|
|
|
|
|
+ await waitFor(() => expect(closeButton.disabled).to.be.true)
|
|
|
|
|
|
|
|
expect(fetchMock.done()).to.be.true
|
|
expect(fetchMock.done()).to.be.true
|
|
|
expect(closeButton.disabled).to.be.false
|
|
expect(closeButton.disabled).to.be.false
|
|
@@ -414,11 +430,11 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{
|
|
|
|
|
|
|
+ ide={ideWithProject({
|
|
|
...project,
|
|
...project,
|
|
|
members,
|
|
members,
|
|
|
publicAccesLevel: 'tokenBased'
|
|
publicAccesLevel: 'tokenBased'
|
|
|
- }}
|
|
|
|
|
|
|
+ })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -433,13 +449,11 @@ describe('<ShareProjectModal/>', function() {
|
|
|
|
|
|
|
|
const changeButton = screen.getByRole('button', { name: 'Change' })
|
|
const changeButton = screen.getByRole('button', { name: 'Change' })
|
|
|
|
|
|
|
|
- await act(async () => {
|
|
|
|
|
- await fireEvent.click(changeButton)
|
|
|
|
|
- expect(closeButton.disabled).to.be.true
|
|
|
|
|
|
|
+ fireEvent.click(changeButton)
|
|
|
|
|
+ await waitFor(() => expect(closeButton.disabled).to.be.true)
|
|
|
|
|
|
|
|
- const { body } = fetchMock.lastOptions()
|
|
|
|
|
- expect(JSON.parse(body)).to.deep.equal({ privilegeLevel: 'readAndWrite' })
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ const { body } = fetchMock.lastOptions()
|
|
|
|
|
+ expect(JSON.parse(body)).to.deep.equal({ privilegeLevel: 'readAndWrite' })
|
|
|
|
|
|
|
|
expect(fetchMock.done()).to.be.true
|
|
expect(fetchMock.done()).to.be.true
|
|
|
expect(closeButton.disabled).to.be.false
|
|
expect(closeButton.disabled).to.be.false
|
|
@@ -459,11 +473,11 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{
|
|
|
|
|
|
|
+ ide={ideWithProject({
|
|
|
...project,
|
|
...project,
|
|
|
members,
|
|
members,
|
|
|
publicAccesLevel: 'tokenBased'
|
|
publicAccesLevel: 'tokenBased'
|
|
|
- }}
|
|
|
|
|
|
|
+ })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -473,13 +487,16 @@ describe('<ShareProjectModal/>', function() {
|
|
|
name: 'Remove from project'
|
|
name: 'Remove from project'
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- act(() => {
|
|
|
|
|
- removeButton.click()
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ fireEvent.click(removeButton)
|
|
|
|
|
+
|
|
|
|
|
+ const url = fetchMock.lastUrl()
|
|
|
|
|
+ expect(url).to.equal('/project/test-project/users/member-viewer')
|
|
|
|
|
|
|
|
expect(fetchMock.done()).to.be.true
|
|
expect(fetchMock.done()).to.be.true
|
|
|
|
|
|
|
|
- // TODO: once the project data is updated, assert that the member has been removed
|
|
|
|
|
|
|
+ await waitForElementToBeRemoved(() =>
|
|
|
|
|
+ screen.queryByText('member-viewer@example.com')
|
|
|
|
|
+ )
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('changes member privileges to owner with confirmation', async function() {
|
|
it('changes member privileges to owner with confirmation', async function() {
|
|
@@ -496,11 +513,11 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{
|
|
|
|
|
|
|
+ ide={ideWithProject({
|
|
|
...project,
|
|
...project,
|
|
|
members,
|
|
members,
|
|
|
publicAccesLevel: 'tokenBased'
|
|
publicAccesLevel: 'tokenBased'
|
|
|
- }}
|
|
|
|
|
|
|
+ })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -519,20 +536,16 @@ describe('<ShareProjectModal/>', function() {
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- const confirmButton = screen.getByRole('button', {
|
|
|
|
|
- name: 'Change owner',
|
|
|
|
|
- hidden: true
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
const reloadStub = sinon.stub(locationModule, 'reload')
|
|
const reloadStub = sinon.stub(locationModule, 'reload')
|
|
|
|
|
|
|
|
- await act(async () => {
|
|
|
|
|
- await fireEvent.click(confirmButton)
|
|
|
|
|
- expect(confirmButton.disabled).to.be.true
|
|
|
|
|
-
|
|
|
|
|
- const { body } = fetchMock.lastOptions()
|
|
|
|
|
- expect(JSON.parse(body)).to.deep.equal({ user_id: 'member-viewer' })
|
|
|
|
|
|
|
+ const confirmButton = screen.getByRole('button', {
|
|
|
|
|
+ name: 'Change owner'
|
|
|
})
|
|
})
|
|
|
|
|
+ fireEvent.click(confirmButton)
|
|
|
|
|
+ await waitFor(() => expect(confirmButton.disabled).to.be.true)
|
|
|
|
|
+
|
|
|
|
|
+ const { body } = fetchMock.lastOptions()
|
|
|
|
|
+ expect(JSON.parse(body)).to.deep.equal({ user_id: 'member-viewer' })
|
|
|
|
|
|
|
|
expect(fetchMock.done()).to.be.true
|
|
expect(fetchMock.done()).to.be.true
|
|
|
expect(reloadStub.calledOnce).to.be.true
|
|
expect(reloadStub.calledOnce).to.be.true
|
|
@@ -540,39 +553,13 @@ describe('<ShareProjectModal/>', function() {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('sends invites to input email addresses', async function() {
|
|
it('sends invites to input email addresses', async function() {
|
|
|
- // TODO: can't use this as the value of useProjectContext doesn't get updated
|
|
|
|
|
- // let mergedProject = {
|
|
|
|
|
- // ...project,
|
|
|
|
|
- // publicAccesLevel: 'tokenBased'
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // const updateProject = value => {
|
|
|
|
|
- // mergedProject = { ...mergedProject, ...value }
|
|
|
|
|
- //
|
|
|
|
|
- // rerender(
|
|
|
|
|
- // <ShareProjectModal
|
|
|
|
|
- // {...modalProps}
|
|
|
|
|
- // project={mergedProject}
|
|
|
|
|
- // updateProject={updateProject}
|
|
|
|
|
- // />
|
|
|
|
|
- // )
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // const { rerender } = render(
|
|
|
|
|
- // <ShareProjectModal
|
|
|
|
|
- // {...modalProps}
|
|
|
|
|
- // project={mergedProject}
|
|
|
|
|
- // updateProject={updateProject}
|
|
|
|
|
- // />
|
|
|
|
|
- // )
|
|
|
|
|
-
|
|
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{
|
|
|
|
|
|
|
+ ide={ideWithProject({
|
|
|
...project,
|
|
...project,
|
|
|
publicAccesLevel: 'tokenBased'
|
|
publicAccesLevel: 'tokenBased'
|
|
|
- }}
|
|
|
|
|
|
|
+ })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -661,13 +648,13 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{
|
|
|
|
|
|
|
+ ide={ideWithProject({
|
|
|
...project,
|
|
...project,
|
|
|
publicAccesLevel: 'tokenBased',
|
|
publicAccesLevel: 'tokenBased',
|
|
|
features: {
|
|
features: {
|
|
|
collaborators: 0
|
|
collaborators: 0
|
|
|
}
|
|
}
|
|
|
- }}
|
|
|
|
|
|
|
+ })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -684,10 +671,10 @@ describe('<ShareProjectModal/>', function() {
|
|
|
render(
|
|
render(
|
|
|
<ShareProjectModal
|
|
<ShareProjectModal
|
|
|
{...modalProps}
|
|
{...modalProps}
|
|
|
- project={{
|
|
|
|
|
|
|
+ ide={ideWithProject({
|
|
|
...project,
|
|
...project,
|
|
|
publicAccesLevel: 'tokenBased'
|
|
publicAccesLevel: 'tokenBased'
|
|
|
- }}
|
|
|
|
|
|
|
+ })}
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -703,13 +690,11 @@ describe('<ShareProjectModal/>', function() {
|
|
|
const submitButton = screen.getByRole('button', { name: 'Share' })
|
|
const submitButton = screen.getByRole('button', { name: 'Share' })
|
|
|
|
|
|
|
|
const respondWithError = async function(errorReason) {
|
|
const respondWithError = async function(errorReason) {
|
|
|
- await act(async () => {
|
|
|
|
|
- inputElement.focus()
|
|
|
|
|
- await fireEvent.change(inputElement, {
|
|
|
|
|
- target: { value: 'invited-author-1@example.com' }
|
|
|
|
|
- })
|
|
|
|
|
- inputElement.blur()
|
|
|
|
|
|
|
+ inputElement.focus()
|
|
|
|
|
+ fireEvent.change(inputElement, {
|
|
|
|
|
+ target: { value: 'invited-author-1@example.com' }
|
|
|
})
|
|
})
|
|
|
|
|
+ inputElement.blur()
|
|
|
|
|
|
|
|
fetchMock.postOnce(
|
|
fetchMock.postOnce(
|
|
|
'express:/project/:projectId/invite',
|
|
'express:/project/:projectId/invite',
|
|
@@ -748,5 +733,45 @@ describe('<ShareProjectModal/>', function() {
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- // TODO: add test for switching between token-access and private, once project data is in React context
|
|
|
|
|
|
|
+ it('handles switching between access levels', async function() {
|
|
|
|
|
+ fetchMock.post('express:/project/:projectId/settings/admin', 204)
|
|
|
|
|
+
|
|
|
|
|
+ render(
|
|
|
|
|
+ <ShareProjectModal
|
|
|
|
|
+ {...modalProps}
|
|
|
|
|
+ ide={ideWithProject({ ...project, publicAccesLevel: 'private' })}
|
|
|
|
|
+ />
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ await screen.findByText(
|
|
|
|
|
+ 'Link sharing is off, only invited users can view this project.'
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ const enableButton = await screen.findByRole('button', {
|
|
|
|
|
+ name: 'Turn on link sharing'
|
|
|
|
|
+ })
|
|
|
|
|
+ fireEvent.click(enableButton)
|
|
|
|
|
+ await waitFor(() => expect(enableButton.disabled).to.be.true)
|
|
|
|
|
+
|
|
|
|
|
+ const { body: tokenBody } = fetchMock.lastOptions()
|
|
|
|
|
+ expect(JSON.parse(tokenBody)).to.deep.equal({
|
|
|
|
|
+ publicAccessLevel: 'tokenBased'
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ await screen.findByText('Link sharing is on')
|
|
|
|
|
+ const disableButton = await screen.findByRole('button', {
|
|
|
|
|
+ name: 'Turn off link sharing'
|
|
|
|
|
+ })
|
|
|
|
|
+ fireEvent.click(disableButton)
|
|
|
|
|
+ await waitFor(() => expect(disableButton.disabled).to.be.true)
|
|
|
|
|
+
|
|
|
|
|
+ const { body: privateBody } = fetchMock.lastOptions()
|
|
|
|
|
+ expect(JSON.parse(privateBody)).to.deep.equal({
|
|
|
|
|
+ publicAccessLevel: 'private'
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ await screen.findByText(
|
|
|
|
|
+ 'Link sharing is off, only invited users can view this project.'
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|