mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Test that video preload data is valid
This commit is contained in:
parent
6d3f0f20c5
commit
b8d973fb07
2 changed files with 127 additions and 78 deletions
97
test/helpers/head.js
Normal file
97
test/helpers/head.js
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
import {
|
||||||
|
isValidHttpUrl,
|
||||||
|
isValidImageUrl,
|
||||||
|
isNonEmptyString,
|
||||||
|
isPositiveNumberString
|
||||||
|
} from '~/helpers/check-types.js'
|
||||||
|
|
||||||
|
export const headPropertyTypes = {
|
||||||
|
'meta[charset]': {
|
||||||
|
charset: isNonEmptyString
|
||||||
|
},
|
||||||
|
|
||||||
|
// <meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
'meta[name="viewport"]': {
|
||||||
|
content: isNonEmptyString
|
||||||
|
},
|
||||||
|
|
||||||
|
// <meta property="og:image" content="https://doesitarm.com/images/og-image.png">
|
||||||
|
'meta[property="og:image"]': {
|
||||||
|
content: isValidImageUrl
|
||||||
|
},
|
||||||
|
|
||||||
|
// <meta property="og:image:width" content="1200">
|
||||||
|
'meta[property="og:image:width"]': {
|
||||||
|
content: isPositiveNumberString
|
||||||
|
},
|
||||||
|
|
||||||
|
// <meta property="og:image:height" content="627">
|
||||||
|
'meta[property="og:image:height"]': {
|
||||||
|
content: isPositiveNumberString
|
||||||
|
},
|
||||||
|
|
||||||
|
// <meta property="og:image:alt" content="Does It ARM Logo">
|
||||||
|
'meta[property="og:image:alt"]': {
|
||||||
|
content: isNonEmptyString
|
||||||
|
},
|
||||||
|
|
||||||
|
// <meta property="twitter:card" content="summary">
|
||||||
|
'meta[property="twitter:card"]': {
|
||||||
|
content: isNonEmptyString
|
||||||
|
},
|
||||||
|
|
||||||
|
// <meta property="twitter:title" content="Does It ARM">
|
||||||
|
'meta[property="twitter:title"]': {
|
||||||
|
content: isNonEmptyString
|
||||||
|
},
|
||||||
|
|
||||||
|
// <meta property="twitter:description" content="Find out the latest app support for Apple Silicon and the Apple M1 Pro and M1 Max Processors">
|
||||||
|
'meta[property="twitter:description"]': {
|
||||||
|
content: isNonEmptyString
|
||||||
|
},
|
||||||
|
|
||||||
|
// <meta property="twitter:url" content="https://doesitarm.com">
|
||||||
|
'meta[property="twitter:url"]': {
|
||||||
|
content: isValidHttpUrl
|
||||||
|
},
|
||||||
|
|
||||||
|
// <meta property="twitter:image" content="https://doesitarm.com/images/mark.png">
|
||||||
|
'meta[property="twitter:image"]': {
|
||||||
|
content: isValidImageUrl,
|
||||||
|
},
|
||||||
|
|
||||||
|
// <meta data-hid="description" name="description" content={ headDescription }>
|
||||||
|
'meta[name="description"]': {
|
||||||
|
content: isNonEmptyString
|
||||||
|
},
|
||||||
|
|
||||||
|
// <meta data-hid="twitter:title" property="twitter:title" content="Apple Silicon and Apple M1 Pro and M1 Max app and game compatibility list">
|
||||||
|
'meta[property="twitter:title"]': {
|
||||||
|
content: isNonEmptyString
|
||||||
|
},
|
||||||
|
|
||||||
|
// <link rel="icon" type="image/x-icon" href="/favicon.ico">
|
||||||
|
'link[rel="icon"]': {
|
||||||
|
href: isNonEmptyString
|
||||||
|
},
|
||||||
|
|
||||||
|
// <!-- Preconnect Assets -->
|
||||||
|
// <link rel="preconnect" href="https://www.googletagmanager.com">
|
||||||
|
// <link rel="preconnect" href="https://cdn.carbonads.com">
|
||||||
|
// <link rel="preconnect" href="https://srv.carbonads.net">
|
||||||
|
// <link rel="preconnect" href="https://cdn4.buysellads.net"></link>
|
||||||
|
'link[rel="preconnect"]': {
|
||||||
|
href: isValidHttpUrl
|
||||||
|
},
|
||||||
|
|
||||||
|
// <link rel="preload" as="image" href="large-image.webp" media="(min-width: 768px)" imagesrcset="large-image.webp, large-image-2x.webp 2x" type="image/webp" />
|
||||||
|
'link[rel="preload"]': {
|
||||||
|
as: isNonEmptyString,
|
||||||
|
href: isValidHttpUrl,
|
||||||
|
media: isNonEmptyString,
|
||||||
|
imagesrcset: isNonEmptyString,
|
||||||
|
type: isNonEmptyString,
|
||||||
|
|
||||||
|
count: false
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -4,16 +4,13 @@ import test from 'ava'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { JSDOM } from 'jsdom'
|
import { JSDOM } from 'jsdom'
|
||||||
|
|
||||||
import {
|
|
||||||
isValidHttpUrl,
|
|
||||||
isValidImageUrl,
|
|
||||||
isNonEmptyString,
|
|
||||||
isPositiveNumberString
|
|
||||||
} from '~/helpers/check-types.js'
|
|
||||||
import {
|
import {
|
||||||
makeApiPathFromEndpoint,
|
makeApiPathFromEndpoint,
|
||||||
|
getVideoImages,
|
||||||
ListingDetails
|
ListingDetails
|
||||||
} from '~/helpers/listing-page.js'
|
} from '~/helpers/listing-page.js'
|
||||||
|
import { headPropertyTypes } from '~/test/helpers/head.js'
|
||||||
import { PageHead } from '~/helpers/config.js'
|
import { PageHead } from '~/helpers/config.js'
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -24,18 +21,21 @@ const listingsCases = {
|
||||||
'/app/spotify': {
|
'/app/spotify': {
|
||||||
endpoint: '/app/spotify',
|
endpoint: '/app/spotify',
|
||||||
apiEndpointPath: '/api/app/spotify.json',
|
apiEndpointPath: '/api/app/spotify.json',
|
||||||
|
expectInitialVideo: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Electron
|
// Electron
|
||||||
'/app/electron-framework': {
|
'/app/electron-framework': {
|
||||||
endpoint: '/app/electron-framework',
|
endpoint: '/app/electron-framework',
|
||||||
apiEndpointPath: '/api/app/electron-framework.json',
|
apiEndpointPath: '/api/app/electron-framework.json',
|
||||||
|
expectInitialVideo: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Express VPN Benchmarks
|
// Express VPN Benchmarks
|
||||||
'/app/expressvpn/benchmarks/': {
|
'/app/expressvpn/benchmarks/': {
|
||||||
endpoint: '/app/expressvpn/benchmarks/',
|
endpoint: '/app/expressvpn/benchmarks/',
|
||||||
apiEndpointPath: '/api/app/expressvpn.json',
|
apiEndpointPath: '/api/app/expressvpn.json',
|
||||||
|
expectInitialVideo: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +85,6 @@ function parseHTML ( htmlString ) {
|
||||||
test( 'Listings have valid api endpoints', async t => {
|
test( 'Listings have valid api endpoints', async t => {
|
||||||
const { listingsDetails } = t.context
|
const { listingsDetails } = t.context
|
||||||
|
|
||||||
|
|
||||||
for ( const [ caseEndpoint, listingCase ] of listingCaseEntries ) {
|
for ( const [ caseEndpoint, listingCase ] of listingCaseEntries ) {
|
||||||
|
|
||||||
const apiPath = listingsDetails[ caseEndpoint ].apiEndpointPath
|
const apiPath = listingsDetails[ caseEndpoint ].apiEndpointPath
|
||||||
|
|
@ -94,86 +93,39 @@ test( 'Listings have valid api endpoints', async t => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test( 'Listings with videos have preload data for initialVideo', async t => {
|
||||||
|
const { listingsDetails } = t.context
|
||||||
|
|
||||||
const headPropertyTypes = {
|
for ( const [ caseEndpoint, listingCase ] of listingCaseEntries ) {
|
||||||
'meta[charset]': {
|
|
||||||
charset: isNonEmptyString
|
|
||||||
},
|
|
||||||
|
|
||||||
// <meta name="viewport" content="width=device-width,initial-scale=1">
|
const listingDetails = listingsDetails[ caseEndpoint ]
|
||||||
'meta[name="viewport"]': {
|
|
||||||
content: isNonEmptyString
|
|
||||||
},
|
|
||||||
|
|
||||||
// <meta property="og:image" content="https://doesitarm.com/images/og-image.png">
|
t.assert( listingDetails.hasInitialVideo === listingCase.expectInitialVideo, `${ caseEndpoint } has initial video` )
|
||||||
'meta[property="og:image"]': {
|
|
||||||
content: isValidImageUrl
|
|
||||||
},
|
|
||||||
|
|
||||||
// <meta property="og:image:width" content="1200">
|
// Stop here if we don't have an initial video
|
||||||
'meta[property="og:image:width"]': {
|
if ( !listingDetails.hasInitialVideo ) continue
|
||||||
content: isPositiveNumberString
|
|
||||||
},
|
|
||||||
|
|
||||||
// <meta property="og:image:height" content="627">
|
// t.log('listingDetails.initialVideo', listingDetails.initialVideo)
|
||||||
'meta[property="og:image:height"]': {
|
|
||||||
content: isPositiveNumberString
|
|
||||||
},
|
|
||||||
|
|
||||||
// <meta property="og:image:alt" content="Does It ARM Logo">
|
// Get headProperties for image preloading
|
||||||
'meta[property="og:image:alt"]': {
|
const preloadHeadChecks = headPropertyTypes[ 'link[rel="preload"]' ]
|
||||||
content: isNonEmptyString
|
|
||||||
},
|
|
||||||
|
|
||||||
// <meta property="twitter:card" content="summary">
|
const images = getVideoImages( listingDetails.initialVideo )
|
||||||
'meta[property="twitter:card"]': {
|
|
||||||
content: isNonEmptyString
|
|
||||||
},
|
|
||||||
|
|
||||||
// <meta property="twitter:title" content="Does It ARM">
|
// Check if the head object properties are correct
|
||||||
'meta[property="twitter:title"]': {
|
for ( const preload of images.preloads ) {
|
||||||
content: isNonEmptyString
|
for ( const [ propertyName, checkMethod ] of Object.entries( preloadHeadChecks ) ) {
|
||||||
},
|
// Skip count property
|
||||||
|
if ( propertyName === 'count' ) continue
|
||||||
|
|
||||||
// <meta property="twitter:description" content="Find out the latest app support for Apple Silicon and the Apple M1 Pro and M1 Max Processors">
|
const value = preload[ propertyName ]
|
||||||
'meta[property="twitter:description"]': {
|
|
||||||
content: isNonEmptyString
|
|
||||||
},
|
|
||||||
|
|
||||||
// <meta property="twitter:url" content="https://doesitarm.com">
|
t.assert( checkMethod( value ), `${ propertyName } failed. Value is '${ value }' for '${ images.imgSrc }'` )
|
||||||
'meta[property="twitter:url"]': {
|
}
|
||||||
content: isValidHttpUrl
|
}
|
||||||
},
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// <meta property="twitter:image" content="https://doesitarm.com/images/mark.png">
|
|
||||||
'meta[property="twitter:image"]': {
|
|
||||||
content: isValidImageUrl,
|
|
||||||
},
|
|
||||||
|
|
||||||
// <meta data-hid="description" name="description" content={ headDescription }>
|
|
||||||
'meta[name="description"]': {
|
|
||||||
content: isNonEmptyString
|
|
||||||
},
|
|
||||||
|
|
||||||
// <meta data-hid="twitter:title" property="twitter:title" content="Apple Silicon and Apple M1 Pro and M1 Max app and game compatibility list">
|
|
||||||
'meta[property="twitter:title"]': {
|
|
||||||
content: isNonEmptyString
|
|
||||||
},
|
|
||||||
|
|
||||||
// <link rel="icon" type="image/x-icon" href="/favicon.ico">
|
|
||||||
'link[rel="icon"]': {
|
|
||||||
href: isNonEmptyString
|
|
||||||
},
|
|
||||||
|
|
||||||
// <!-- Preconnect Assets -->
|
|
||||||
// <link rel="preconnect" href="https://www.googletagmanager.com">
|
|
||||||
// <link rel="preconnect" href="https://cdn.carbonads.com">
|
|
||||||
// <link rel="preconnect" href="https://srv.carbonads.net">
|
|
||||||
// <link rel="preconnect" href="https://cdn4.buysellads.net"></link>
|
|
||||||
'link[rel="preconnect"]': {
|
|
||||||
href: isValidHttpUrl
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
test('Listings have valid headings', async t => {
|
test('Listings have valid headings', async t => {
|
||||||
const { listingsDetails } = t.context
|
const { listingsDetails } = t.context
|
||||||
|
|
@ -196,9 +148,9 @@ test('Listings have valid headings', async t => {
|
||||||
|
|
||||||
let count = 1
|
let count = 1
|
||||||
|
|
||||||
if ( has( checks, ['count'] ) ) {
|
if ( has( checks, 'count' ) ) {
|
||||||
count = checks.count
|
count = checks.count
|
||||||
delete checks.count
|
// delete checks.count
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( count !== false ) {
|
if ( count !== false ) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue