-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
790cdd1
commit cd48d98
Showing
4 changed files
with
194 additions
and
28 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
{ | ||
"id": 1, | ||
"teamId": "1", | ||
"title": "Test Title", | ||
"description": "Test Description", | ||
"price": "1", | ||
"currency": "ETH", | ||
"image": "https://b507f59d2508ebfb5e70996008095782.ipfscdn.io/ipfs/bafybeigj5k75odq5azftrivrnjlsdd7jqs7f72qmgzfi67znkbooeriy3e/", | ||
"metadata": "", | ||
"startTime": 0, | ||
"endTime": 0, | ||
"shipping": "false" | ||
} |
66 changes: 66 additions & 0 deletions
66
ui/cypress/integration/subscription/buy-team-listing-modal.cy.tsx
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,66 @@ | ||
import { PrivyProvider } from '@privy-io/react-auth' | ||
import { Sepolia } from '@thirdweb-dev/chains' | ||
import { ZERO_ADDRESS } from 'const/config' | ||
import CitizenProvider from '@/lib/citizen/CitizenProvider' | ||
import { PrivyThirdwebSDKProvider } from '@/lib/privy/PrivyThirdwebSDKProvider' | ||
import BuyTeamListingModal from '@/components/subscription/BuyTeamListingModal' | ||
import { TeamListing } from '@/components/subscription/TeamListing' | ||
|
||
describe('<BuyTeamListingModal />', () => { | ||
let props: any | ||
let listing: TeamListing | ||
|
||
before(() => { | ||
cy.fixture('marketplace/listing').then((l) => { | ||
listing = l | ||
}) | ||
}) | ||
|
||
beforeEach(() => { | ||
props = { | ||
selectedChain: Sepolia, | ||
listing, | ||
recipient: ZERO_ADDRESS, | ||
setEnabled: cy.stub(), | ||
} | ||
|
||
cy.mount( | ||
<PrivyProvider appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID as string}> | ||
<PrivyThirdwebSDKProvider selectedChain={Sepolia}> | ||
<BuyTeamListingModal {...props} /> | ||
</PrivyThirdwebSDKProvider> | ||
</PrivyProvider> | ||
) | ||
}) | ||
|
||
it('Renders the component', () => { | ||
cy.contains('h2', 'Buy a Listing').should('be.visible') | ||
cy.contains(listing.title).should('be.visible') | ||
cy.contains(listing.description).should('be.visible') | ||
cy.contains(`${listing.price} ${listing.currency}`).should('be.visible') | ||
}) | ||
|
||
it('Shows markedup price for non-citizens', () => { | ||
cy.get('#listing-price').should( | ||
'have.text', | ||
`${+listing.price * 1.1} ${listing.currency}` | ||
) | ||
}) | ||
|
||
it('Shows regular price for citizens', () => { | ||
cy.mount( | ||
<PrivyProvider appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID as string}> | ||
<PrivyThirdwebSDKProvider selectedChain={Sepolia}> | ||
<CitizenProvider selectedChain={Sepolia} mock={true}> | ||
<BuyTeamListingModal {...props} /> | ||
</CitizenProvider> | ||
</PrivyThirdwebSDKProvider> | ||
</PrivyProvider> | ||
) | ||
|
||
cy.get('#listing-price').should( | ||
'have.text', | ||
`${listing.price} ${listing.currency}` | ||
) | ||
}) | ||
}) |
115 changes: 115 additions & 0 deletions
115
ui/cypress/integration/subscription/team-listing.cy.tsx
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,115 @@ | ||
import { PrivyProvider } from '@privy-io/react-auth' | ||
import { Sepolia } from '@thirdweb-dev/chains' | ||
import { PrivyThirdwebSDKProvider } from '@/lib/privy/PrivyThirdwebSDKProvider' | ||
import TeamListing, { | ||
TeamListing as TeamListingType, | ||
} from '@/components/subscription/TeamListing' | ||
|
||
describe('<TeamListing />', () => { | ||
let listing: TeamListingType | ||
let props: any | ||
|
||
before(() => { | ||
cy.fixture('marketplace/listing').then((l) => { | ||
listing = l | ||
}) | ||
}) | ||
|
||
beforeEach(() => { | ||
props = { | ||
selectedChain: Sepolia, | ||
listing, | ||
teamContract: { | ||
erc721: { | ||
get: cy.stub().resolves({ | ||
metadata: { name: 'Test Team Name' }, | ||
owner: '0x123', | ||
}), | ||
}, | ||
}, | ||
marketplaceTableContract: { | ||
call: cy.stub().resolves(), | ||
}, | ||
refreshListings: cy.stub(), | ||
teamName: true, | ||
queriedListingId: 1, | ||
} | ||
}) | ||
|
||
it('Renders the component', () => { | ||
cy.mount( | ||
<PrivyProvider appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID as string}> | ||
<PrivyThirdwebSDKProvider selectedChain={Sepolia}> | ||
<TeamListing {...props} teamName /> | ||
</PrivyThirdwebSDKProvider> | ||
</PrivyProvider> | ||
) | ||
|
||
cy.get('#listing-team-name').should('exist') | ||
cy.get('#main-header').should('have.text', props.listing.title) | ||
cy.get('#listing-description').should( | ||
'have.text', | ||
props.listing.description | ||
) | ||
}) | ||
|
||
it('Shows markedup price for non-citizens', () => { | ||
cy.mount( | ||
<PrivyProvider appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID as string}> | ||
<PrivyThirdwebSDKProvider selectedChain={Sepolia}> | ||
<TeamListing {...props} /> | ||
</PrivyThirdwebSDKProvider> | ||
</PrivyProvider> | ||
) | ||
|
||
cy.get('#listing-price').should((price) => { | ||
const parsedPrice = parseFloat(price.text()) | ||
expect(parsedPrice.toFixed(5)).to.equal((+listing.price * 1.1).toFixed(5)) | ||
}) | ||
}) | ||
|
||
it('Shows regular price for citizens', () => { | ||
cy.mount( | ||
<PrivyProvider appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID as string}> | ||
<PrivyThirdwebSDKProvider selectedChain={Sepolia}> | ||
<TeamListing {...props} isCitizen /> | ||
</PrivyThirdwebSDKProvider> | ||
</PrivyProvider> | ||
) | ||
|
||
cy.get('#listing-price').should((price) => { | ||
const parsedPrice = parseFloat(price.text()) | ||
expect(parsedPrice.toFixed(5)).to.equal((+listing.price).toFixed(5)) | ||
}) | ||
}) | ||
|
||
it('Opens the edit modal when the edit button is clicked', () => { | ||
cy.mount( | ||
<PrivyProvider appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID as string}> | ||
<PrivyThirdwebSDKProvider selectedChain={Sepolia}> | ||
<TeamListing {...props} editable /> | ||
</PrivyThirdwebSDKProvider> | ||
</PrivyProvider> | ||
) | ||
|
||
cy.get('#edit-listing-button').click() | ||
cy.get('#team-marketplace-listing-modal-backdrop').should('exist') | ||
}) | ||
|
||
it('Deletes the listing when the delete button is clicked', () => { | ||
cy.mount( | ||
<PrivyProvider appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID as string}> | ||
<PrivyThirdwebSDKProvider selectedChain={Sepolia}> | ||
<TeamListing {...props} editable /> | ||
</PrivyThirdwebSDKProvider> | ||
</PrivyProvider> | ||
) | ||
|
||
cy.get('#delete-listing-button').click() | ||
cy.wrap(props.marketplaceTableContract.call).should( | ||
'be.calledWith', | ||
'deleteFromTable', | ||
[listing.id, listing.teamId] | ||
) | ||
}) | ||
}) |