uniswap-interface-uncensored/functions/nfts/collection/collection.test.ts

59 lines
2.8 KiB
TypeScript
Raw Normal View History

const collections = [
{
address: '0xed5af388653567af2f388e6224dc7c4b3241c544',
collectionName: 'Azuki',
feat: dynamically generated images for rich link previews (#6902) * feat: add token and nft injection * feat: basic tests * fix: get jest configured properly * fix: change timeout * fix: uninstall port ready * fix: readd port ready * fix: local tests work * Update yarn.lock * add lint disable for setup files * fix: update dependencies * fix: basic test suite for nfts/tokens * feat: collection data * fix: make tests more comprehensive * fix: change matches to contains * fix: tests for twitter alt image tag * fix: image gen * fix: add patch-package * fix: update yarn install * feat: basic image gen for nfts and collections * fix: remove vibrant attempt * use watermark asset * dynamically grab color * modularize code and prototype for token preview * refactor code * finalize css * fix color grabber * update tests * fix up css * refactor code a bit more * remove console logs * tests * update tests * update images based on design feedback * network logos * update lint * slight refactoring * more refactoring * fix packages * Update yarn.lock * remove dynamically generated image stuff * Revert "remove dynamically generated image stuff" This reverts commit a80241edb3a970a724b9a07ce36e492ff8a1c2af. * change image reference and revamp tests * cleanup return values * Create README.md * Revert "Create README.md" This reverts commit 7a91c98d384995fba914c9bf9a2fb3072793621f. * First round of feedback * comments * feat: cache * Update test.yml * Update test.yml * Update test.yml * feedback round 2 * final feedback * final final feedback * add coverage and other options * Update test.yml * start typecheck * update cache * update snapshots? * Update jest.config.json * Update jest.config.json * give timeout some buffer * update import * upgrade ts * fix typing for apollo deps * finalize typechecks * downgrade typescript to original version * add cache directory to jest * remove coverage * remove google analytics from tests * merge main * remove timeout * update tests * update graphql queries * review changes * try cache setup * Update cache.test.ts * make cache helper function * cache test * remove unneeded test causing issues * feat: parallelize cache (#6930) * feat: parallelize cache? * remove graph query from concurrency await * most of feedback * move tests * update token tests * singleton cache * restructuring res and cache promise * abstract away repeated graph logic * update tests and functions * refactor * update typing, parallelize, and start tests * fix one tsc issue * final feedback * Update yarn.lock * final final feedback * add svgs * try and setup svg * stashing changes * cleanup! * prepare for start of feedback? * LESS GOO * modify versioning * fix: update wrangler version * Update yarn.lock * downgrade wrangler * Update yarn.lock * Update yarn.lock * fix type error * update github test * cleanup tests * Delete custom.d.ts * fix: cloudfunctions * update tests * final touchups * lint * change github action * Update yarn.lock * styling updates * nate's feedback * feedback p1 * typing feedback * update yarn * Create wrangler.toml * move wrangler.toml location * last try * Delete wrangler.toml * use 2.20? * remove comment * Update yarn.lock * change compatibility date * update wrangler and fix bugs * Update colorthief+2.4.0.patch * build: cleanup flags * cleaner patches * update compatibility date * quick tweeks * cleanup rendering and lint * final color update --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
2023-08-10 22:29:37 +03:00
image: 'http://127.0.0.1:3000/api/image/nfts/collection/0xed5af388653567af2f388e6224dc7c4b3241c544',
},
{
address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d',
collectionName: 'Bored Ape Yacht Club',
feat: dynamically generated images for rich link previews (#6902) * feat: add token and nft injection * feat: basic tests * fix: get jest configured properly * fix: change timeout * fix: uninstall port ready * fix: readd port ready * fix: local tests work * Update yarn.lock * add lint disable for setup files * fix: update dependencies * fix: basic test suite for nfts/tokens * feat: collection data * fix: make tests more comprehensive * fix: change matches to contains * fix: tests for twitter alt image tag * fix: image gen * fix: add patch-package * fix: update yarn install * feat: basic image gen for nfts and collections * fix: remove vibrant attempt * use watermark asset * dynamically grab color * modularize code and prototype for token preview * refactor code * finalize css * fix color grabber * update tests * fix up css * refactor code a bit more * remove console logs * tests * update tests * update images based on design feedback * network logos * update lint * slight refactoring * more refactoring * fix packages * Update yarn.lock * remove dynamically generated image stuff * Revert "remove dynamically generated image stuff" This reverts commit a80241edb3a970a724b9a07ce36e492ff8a1c2af. * change image reference and revamp tests * cleanup return values * Create README.md * Revert "Create README.md" This reverts commit 7a91c98d384995fba914c9bf9a2fb3072793621f. * First round of feedback * comments * feat: cache * Update test.yml * Update test.yml * Update test.yml * feedback round 2 * final feedback * final final feedback * add coverage and other options * Update test.yml * start typecheck * update cache * update snapshots? * Update jest.config.json * Update jest.config.json * give timeout some buffer * update import * upgrade ts * fix typing for apollo deps * finalize typechecks * downgrade typescript to original version * add cache directory to jest * remove coverage * remove google analytics from tests * merge main * remove timeout * update tests * update graphql queries * review changes * try cache setup * Update cache.test.ts * make cache helper function * cache test * remove unneeded test causing issues * feat: parallelize cache (#6930) * feat: parallelize cache? * remove graph query from concurrency await * most of feedback * move tests * update token tests * singleton cache * restructuring res and cache promise * abstract away repeated graph logic * update tests and functions * refactor * update typing, parallelize, and start tests * fix one tsc issue * final feedback * Update yarn.lock * final final feedback * add svgs * try and setup svg * stashing changes * cleanup! * prepare for start of feedback? * LESS GOO * modify versioning * fix: update wrangler version * Update yarn.lock * downgrade wrangler * Update yarn.lock * Update yarn.lock * fix type error * update github test * cleanup tests * Delete custom.d.ts * fix: cloudfunctions * update tests * final touchups * lint * change github action * Update yarn.lock * styling updates * nate's feedback * feedback p1 * typing feedback * update yarn * Create wrangler.toml * move wrangler.toml location * last try * Delete wrangler.toml * use 2.20? * remove comment * Update yarn.lock * change compatibility date * update wrangler and fix bugs * Update colorthief+2.4.0.patch * build: cleanup flags * cleaner patches * update compatibility date * quick tweeks * cleanup rendering and lint * final color update --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
2023-08-10 22:29:37 +03:00
image: 'http://127.0.0.1:3000/api/image/nfts/collection/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d',
},
{
address: '0x49cf6f5d44e70224e2e23fdcdd2c053f30ada28b',
collectionName: 'CLONE X - X TAKASHI MURAKAMI',
feat: dynamically generated images for rich link previews (#6902) * feat: add token and nft injection * feat: basic tests * fix: get jest configured properly * fix: change timeout * fix: uninstall port ready * fix: readd port ready * fix: local tests work * Update yarn.lock * add lint disable for setup files * fix: update dependencies * fix: basic test suite for nfts/tokens * feat: collection data * fix: make tests more comprehensive * fix: change matches to contains * fix: tests for twitter alt image tag * fix: image gen * fix: add patch-package * fix: update yarn install * feat: basic image gen for nfts and collections * fix: remove vibrant attempt * use watermark asset * dynamically grab color * modularize code and prototype for token preview * refactor code * finalize css * fix color grabber * update tests * fix up css * refactor code a bit more * remove console logs * tests * update tests * update images based on design feedback * network logos * update lint * slight refactoring * more refactoring * fix packages * Update yarn.lock * remove dynamically generated image stuff * Revert "remove dynamically generated image stuff" This reverts commit a80241edb3a970a724b9a07ce36e492ff8a1c2af. * change image reference and revamp tests * cleanup return values * Create README.md * Revert "Create README.md" This reverts commit 7a91c98d384995fba914c9bf9a2fb3072793621f. * First round of feedback * comments * feat: cache * Update test.yml * Update test.yml * Update test.yml * feedback round 2 * final feedback * final final feedback * add coverage and other options * Update test.yml * start typecheck * update cache * update snapshots? * Update jest.config.json * Update jest.config.json * give timeout some buffer * update import * upgrade ts * fix typing for apollo deps * finalize typechecks * downgrade typescript to original version * add cache directory to jest * remove coverage * remove google analytics from tests * merge main * remove timeout * update tests * update graphql queries * review changes * try cache setup * Update cache.test.ts * make cache helper function * cache test * remove unneeded test causing issues * feat: parallelize cache (#6930) * feat: parallelize cache? * remove graph query from concurrency await * most of feedback * move tests * update token tests * singleton cache * restructuring res and cache promise * abstract away repeated graph logic * update tests and functions * refactor * update typing, parallelize, and start tests * fix one tsc issue * final feedback * Update yarn.lock * final final feedback * add svgs * try and setup svg * stashing changes * cleanup! * prepare for start of feedback? * LESS GOO * modify versioning * fix: update wrangler version * Update yarn.lock * downgrade wrangler * Update yarn.lock * Update yarn.lock * fix type error * update github test * cleanup tests * Delete custom.d.ts * fix: cloudfunctions * update tests * final touchups * lint * change github action * Update yarn.lock * styling updates * nate's feedback * feedback p1 * typing feedback * update yarn * Create wrangler.toml * move wrangler.toml location * last try * Delete wrangler.toml * use 2.20? * remove comment * Update yarn.lock * change compatibility date * update wrangler and fix bugs * Update colorthief+2.4.0.patch * build: cleanup flags * cleaner patches * update compatibility date * quick tweeks * cleanup rendering and lint * final color update --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
2023-08-10 22:29:37 +03:00
image: 'http://127.0.0.1:3000/api/image/nfts/collection/0x49cf6f5d44e70224e2e23fdcdd2c053f30ada28b',
},
]
test.each(collections)('should inject metadata for valid collections', async (collection) => {
const url = 'http://127.0.0.1:3000/nfts/collection/' + collection.address
const body = await fetch(new Request(url)).then((res) => res.text())
expect(body).toMatchSnapshot()
expect(body).toContain(`<meta property="og:title" content="${collection.collectionName} on Uniswap"/>`)
expect(body).toContain(`<meta property="og:image" content="${collection.image}"/>`)
expect(body).toContain(`<meta property="og:image:width" content="1200"/>`)
expect(body).toContain(`<meta property="og:image:height" content="630"/>`)
expect(body).toContain(`<meta property="og:type" content="website"/>`)
expect(body).toContain(`<meta property="og:url" content="${url}"/>`)
expect(body).toContain(`<meta property="og:image:alt" content="${collection.collectionName} on Uniswap"/>`)
expect(body).toContain(`<meta property="twitter:card" content="summary_large_image"/>`)
expect(body).toContain(`<meta property="twitter:title" content="${collection.collectionName} on Uniswap"/>`)
expect(body).toContain(`<meta property="twitter:image" content="${collection.image}"/>`)
expect(body).toContain(`<meta property="twitter:image:alt" content="${collection.collectionName} on Uniswap"/>`)
})
const invalidCollections = [
'http://127.0.0.1:3000/nfts/collection/0xed5af388653567af2f388e6224dc7c4b3241c545',
'http://127.0.0.1:3000/nfts/collection/0xed5af388653567af2f388e6224dc7c4b3241c545//',
]
test.each(invalidCollections)(
feat: automated testing for cloud functions (#6931) * feat: add token and nft injection * feat: basic tests * fix: get jest configured properly * fix: change timeout * fix: uninstall port ready * fix: readd port ready * fix: local tests work * Update yarn.lock * add lint disable for setup files * fix: update dependencies * fix: basic test suite for nfts/tokens * feat: collection data * fix: make tests more comprehensive * fix: change matches to contains * fix: tests for twitter alt image tag * fix: image gen * fix: add patch-package * fix: update yarn install * feat: basic image gen for nfts and collections * fix: remove vibrant attempt * use watermark asset * dynamically grab color * modularize code and prototype for token preview * refactor code * finalize css * fix color grabber * update tests * fix up css * refactor code a bit more * remove console logs * tests * update tests * update images based on design feedback * network logos * update lint * slight refactoring * more refactoring * fix packages * Update yarn.lock * remove dynamically generated image stuff * cleanup return values * Create README.md * Revert "Create README.md" This reverts commit 7a91c98d384995fba914c9bf9a2fb3072793621f. * First round of feedback * comments * Update test.yml * Update test.yml * Update test.yml * feedback round 2 * final feedback * final final feedback * add coverage and other options * Update test.yml * start typecheck * update cache * update snapshots? * Update jest.config.json * Update jest.config.json * give timeout some buffer * update import * upgrade ts * fix typing for apollo deps * finalize typechecks * downgrade typescript to original version * add cache directory to jest * remove coverage * remove google analytics from tests * review changes
2023-07-25 22:12:13 +03:00
'should not inject metadata for invalid collection urls',
async (url) => {
const body = await fetch(new Request(url)).then((res) => res.text())
expect(body).not.toContain('og:title')
expect(body).not.toContain('og:image')
expect(body).not.toContain('og:image:width')
expect(body).not.toContain('og:image:height')
expect(body).not.toContain('og:type')
expect(body).not.toContain('og:url')
expect(body).not.toContain('og:image:alt')
expect(body).not.toContain('twitter:card')
expect(body).not.toContain('twitter:title')
expect(body).not.toContain('twitter:image')
expect(body).not.toContain('twitter:image:alt')
},
50000
)