Skip to content

Commit

Permalink
fix: Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Sep 25, 2024
1 parent 71ccfc2 commit dd04045
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@
border-radius: 8px;
}

.collectionSelection .disabled {
width: 100%;
height: 100%;
border-radius: 8px;
position: absolute;
top: 0;
left: 0;
opacity: 0.3;
background-color: black;
}

.collectionSelection img {
width: 227px;
height: 110px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { renderWithProviders } from 'specs/utils'
import { CreateCollectionSelectorModal } from './CreateCollectionSelectorModal'
import { Props } from './CreateCollectionSelectorModal.types'
import { CREATE_BUTTON_TEST_ID, DISABLED_DATA_TEST_ID } from './constants'
import { CREATE_BUTTON_TEST_ID } from './constants'
import userEvent from '@testing-library/user-event'

export function renderWorldContributorTab(props: Partial<Props>) {
Expand All @@ -12,8 +12,6 @@ export function renderWorldContributorTab(props: Partial<Props>) {
metadata={{}}
name="aName"
onClose={jest.fn()}
isLoadingThirdParties={false}
isThirdPartyManager={false}
{...props}
/>
)
Expand All @@ -29,8 +27,7 @@ describe('when clicking on the create collection button', () => {
onCreateThirdPartyCollection = jest.fn()
renderedComponent = renderWorldContributorTab({
onCreateCollection,
onCreateThirdPartyCollection,
isThirdPartyManager: true
onCreateThirdPartyCollection
})
})

Expand All @@ -57,42 +54,3 @@ describe('when clicking on the create collection button', () => {
})
})
})

describe('and the linked collections are being loaded', () => {
let renderedComponent: ReturnType<typeof renderWorldContributorTab>
beforeEach(() => {
renderedComponent = renderWorldContributorTab({ isLoadingThirdParties: true })
})

it('should show the disabled overlay for the linked collections', () => {
const disabledOverlay = renderedComponent.getByTestId(DISABLED_DATA_TEST_ID)
expect(disabledOverlay).toBeInTheDocument()
})

it('should disable the create button for the linked collections', () => {
const createButton = renderedComponent.getAllByTestId(CREATE_BUTTON_TEST_ID)[1]
expect(createButton).toBeDisabled()
})

it('should set the button as loading', () => {
const createButton = renderedComponent.getAllByTestId(CREATE_BUTTON_TEST_ID)[1]
expect(createButton).toHaveClass('loading')
})
})

describe('and the user is not a third party manager', () => {
let renderedComponent: ReturnType<typeof renderWorldContributorTab>
beforeEach(() => {
renderedComponent = renderWorldContributorTab({ isThirdPartyManager: false })
})

it('should show the disabled overlay for the linked collections', () => {
const disabledOverlay = renderedComponent.getByTestId(DISABLED_DATA_TEST_ID)
expect(disabledOverlay).toBeInTheDocument()
})

it('should disable the create button for the linked collections', () => {
const createButton = renderedComponent.getAllByTestId(CREATE_BUTTON_TEST_ID)[1]
expect(createButton).toBeDisabled()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import collectionsImage from '../../../images/collections.png'
import linkedCollectionsImage from '../../../images/linked-collections.png'
import { Props } from './CreateCollectionSelectorModal.types'
import styles from './CreateCollectionSelectorModal.module.css'
import { CREATE_BUTTON_TEST_ID, DISABLED_DATA_TEST_ID } from './constants'
import { CREATE_BUTTON_TEST_ID } from './constants'

const CollectionSelectionModal = ({
image,
Expand All @@ -28,7 +28,6 @@ const CollectionSelectionModal = ({
}) => {
return (
<div className={classNames(styles.collectionSelection)}>
{disabled && <div data-testid={DISABLED_DATA_TEST_ID} className={styles.disabled}></div>}
<img src={image} alt={title} />
<div className={styles.content}>
<div className={styles.text}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const DISABLED_DATA_TEST_ID = 'create-collection-selector-modal-disabled'
export const CREATE_BUTTON_TEST_ID = 'create-collection-selector-modal-create-button'

0 comments on commit dd04045

Please sign in to comment.