Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat/add-names-worl…
Browse files Browse the repository at this point in the history
…d-deploy
  • Loading branch information
meelrossi committed May 21, 2024
2 parents a67c464 + f1266d7 commit 24e217f
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ describe('when the world has a scene deployed', () => {
projects = [{ id: '1' } as Project]
})

it('should show edit scene button', () => {
it('should show the edit scene button', () => {
const screen = renderPublishSceneButton({ projects, deploymentsByWorlds })
expect(screen.getByRole('button', { name: t('worlds_list_page.table.edit_scene') })).toBeInTheDocument()
})

describe('when editScene button is clicked', () => {
describe('when the editScene button is clicked', () => {
it('should trigger onEditScene callback action', () => {
const onEditScene = jest.fn()
const screen = renderPublishSceneButton({ onEditScene, projects, deploymentsByWorlds })
Expand All @@ -74,12 +74,12 @@ describe('when the world has a scene deployed', () => {
projects = []
})

it('should show unpublish scene button', () => {
it('should show the unpublish scene button', () => {
const screen = renderPublishSceneButton({ projects, deploymentsByWorlds })
expect(screen.getByRole('button', { name: t('worlds_list_page.table.unpublish_scene') })).toBeInTheDocument()
})

describe('when unpublish button is clicked', () => {
describe('when the unpublish button is clicked', () => {
it('should trigger onUnpublish callback action', () => {
const onUnpublishScene = jest.fn()
const screen = renderPublishSceneButton({ onUnpublishScene, projects, deploymentsByWorlds })
Expand All @@ -92,12 +92,12 @@ describe('when the world has a scene deployed', () => {
})

describe('when the world has no scene deployed', () => {
it('should show publish scene button', () => {
it('should show the publish scene button', () => {
const screen = renderPublishSceneButton({})
expect(screen.getByRole('button', { name: t('worlds_list_page.table.publish_scene') })).toBeInTheDocument()
})

describe('when publish button is clicked', () => {
describe('when the publish button is clicked', () => {
it('should trigger onPublish callback action', () => {
const onPublishScene = jest.fn()
const screen = renderPublishSceneButton({ onPublishScene })
Expand Down
16 changes: 0 additions & 16 deletions src/components/WorldListPage/WorldListPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,6 @@
flex-direction: row;
}

.WorldListPage .TableRow .world-url {
display: flex;
width: 100%;
justify-content: space-between;
}

.WorldListPage .TableRow .world-url .right {
display: flex;
align-items: center;
margin-right: 20px;
}

.WorldListPage .TableRow .world-url .right .link {
color: var(--text);
}

.WorldListPage .TableRow .empty-url {
color: #ffffffcc;
font-style: italic;
Expand Down
15 changes: 15 additions & 0 deletions src/components/WorldListPage/WorldUrl/WorldUrl.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.worldUrl {
display: flex;
width: 100%;
justify-content: space-between;
}

.rightContainer {
display: flex;
align-items: center;
margin-right: 20px;
}

.rightContainer .copyUrn {
color: var(--text);
}
8 changes: 4 additions & 4 deletions src/components/WorldListPage/WorldUrl/WorldUrl.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function renderWorldUrl(props: Partial<Props>) {
return render(<WorldUrl ens={ens} deploymentsByWorlds={{}} {...props} />)
}

describe('when world has a scene deployed', () => {
it('should show world url', () => {
describe('when the world has a scene deployed', () => {
it('should show the world url', () => {
deploymentsByWorlds = {
[ens.subdomain]: {
projectId: 'projectId'
Expand All @@ -30,8 +30,8 @@ describe('when world has a scene deployed', () => {
})
})

describe('when world has no scene deployed', () => {
it('should show world url', () => {
describe('when the world has no scene deployed', () => {
it('should show the world url', () => {
deploymentsByWorlds = {}
const screen = renderWorldUrl({ deploymentsByWorlds })
expect(screen.getByText(t('worlds_list_page.table.empty_url'))).toBeInTheDocument()
Expand Down
8 changes: 5 additions & 3 deletions src/components/WorldListPage/WorldUrl/WorldUrl.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { Icon } from 'decentraland-ui'
import classNames from 'classnames'
import { t } from 'decentraland-dapps/dist/modules/translation'
import CopyToClipboard from 'components/CopyToClipboard/CopyToClipboard'
import { getExplorerUrl, isWorldDeployed } from '../utils'
import { Props } from './WorldUrl.types'
import styles from './WorldUrl.module.css'

export default function WorldUrl({ ens, deploymentsByWorlds }: Props) {
const url = getExplorerUrl(ens.subdomain)
return isWorldDeployed(deploymentsByWorlds, ens) ? (
<div className="world-url">
<div className={styles.worldUrl}>
<span>{url}</span>
<div className="right">
<div className={styles.rightContainer}>
<CopyToClipboard role="button" text={url} showPopup={true}>
<Icon aria-label="Copy urn" aria-hidden="false" className="link copy" name="copy outline" />
<Icon aria-label="Copy urn" aria-hidden="false" className={classNames('copy', styles.copyUrn)} name="copy outline" />
</CopyToClipboard>
<a href={url} target="_blank" rel="noopener noreferrer">
<Icon name="external alternate" />
Expand Down
8 changes: 4 additions & 4 deletions src/modules/ens/reducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe('when handling the CLEAR_ENS_ERRORS action', () => {

describe('when handling fetch contributable names actions', () => {
describe('when handling fetch contributable names request action', () => {
it('should reset contributable names error', () => {
it('should reset the contributable names error', () => {
const stateWithError = {
...state,
contributableNamesError: { message: 'an error' }
Expand All @@ -218,7 +218,7 @@ describe('when handling fetch contributable names actions', () => {
)
})

it('should set contributable names action as loading', () => {
it('should set the contributable names action as loading', () => {
const stateWithoutLoading = {
...state,
loading: []
Expand All @@ -243,15 +243,15 @@ describe('when handling fetch contributable names actions', () => {
ens = { name: 'test.dcl.eth', subdomain: 'test.dcl.eth' } as ENS
})

it('should add contributable names to the state', () => {
it('should add the contributable names to the state', () => {
expect(ensReducer(state, fetchContributableNamesSuccess([ens]))).toEqual(
expect.objectContaining({
contributableNames: { 'test.dcl.eth': ens }
})
)
})

it('should add contributable names to the state', () => {
it('should remove the loading action from the state', () => {
expect(ensReducer(state, fetchContributableNamesSuccess([ens]))).toEqual(
expect.objectContaining({
loading: []
Expand Down
46 changes: 46 additions & 0 deletions src/modules/ens/sagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,5 +373,51 @@ describe('when handling the fetching of contributable names', () => {
.silentRun()
})
})

describe('and fetching the names owners throws an error', () => {
let ensError: ENSError
let error: Error

beforeEach(() => {
error = new Error('Some Error')
ensError = { message: error.message }
})

it('should dispatch an error action with the error', async () => {
await expectSaga(ensSaga, builderClient, ensApi, worldsAPIContent)
.provide([
[call([worldsAPIContent, 'fetchContributableDomains']), [contributableName]],
[call([lists, 'fetchBannedNames']), []],
[call([marketplace, 'fetchENSOwnerByDomain'], ['test']), throwError(error)],
[call([ensApi, 'fetchExternalENSOwners'], []), {}]
])
.put(fetchContributableNamesFailure(ensError))
.dispatch(fetchContributableNamesRequest())
.silentRun()
})
})

describe('and fetching the external ens owners throws an error', () => {
let ensError: ENSError
let error: Error

beforeEach(() => {
error = new Error('Some Error')
ensError = { message: error.message }
})

it('should dispatch an error action with the error', async () => {
await expectSaga(ensSaga, builderClient, ensApi, worldsAPIContent)
.provide([
[call([worldsAPIContent, 'fetchContributableDomains']), [contributableName]],
[call([lists, 'fetchBannedNames']), []],
[call([marketplace, 'fetchENSOwnerByDomain'], ['test']), { test: '0x123' }],
[call([ensApi, 'fetchExternalENSOwners'], []), throwError(error)]
])
.put(fetchContributableNamesFailure(ensError))
.dispatch(fetchContributableNamesRequest())
.silentRun()
})
})
})
})
6 changes: 3 additions & 3 deletions src/modules/ens/selectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ describe('when using getContributableNames selector', () => {
})
})

describe('when using getContributableNamesError selector', () => {
describe('when using the getContributableNamesError selector', () => {
let contributableNamesError: ENSState['contributableNamesError']
describe('when there was an error laoding the contributable names', () => {
beforeEach(() => {
Expand All @@ -232,7 +232,7 @@ describe('when using getContributableNamesError selector', () => {
}
})

it('should return a record of contributable names', () => {
it('should return a record of the contributable names', () => {
expect(getContributableNamesError(state)).toEqual(contributableNamesError)
})
})
Expand All @@ -249,7 +249,7 @@ describe('when using getContributableNamesError selector', () => {
}
})

it('should return a record of contributable names', () => {
it('should return a record of the contributable names', () => {
expect(getContributableNamesError(state)).toEqual(contributableNamesError)
})
})
Expand Down

0 comments on commit 24e217f

Please sign in to comment.