Merge branch 'master' into develop

This commit is contained in:
Sam Carlton 2021-05-16 15:30:13 -05:00
commit cc3e7063e4
4 changed files with 4165 additions and 16 deletions

View file

@ -2,7 +2,7 @@ import renderPoster from './poster.js'
function renderTimestamps ( video ) {
if ( video.timestamps.length > 0 ) return ''
if ( video.timestamps.length === 0 ) return ''
const timestampsForRender = video.timestamps.map( timestamp => {
const [ minutes, seconds ] = timestamp.time.split(':')

4031
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,13 @@
"description": "Find out the latest app support for Apple Silicon and the Apple M1 Processor",
"author": "Sam Carlton",
"private": true,
"ava": {
"require": [
"esm"
]
},
"scripts": {
"test": "ava --timeout=1m --verbose",
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
@ -51,6 +57,7 @@
"@nuxt/postcss8": "^1.1.3",
"@nuxtjs/tailwindcss": "^3.3.4",
"autoprefixer": "^8.6.4",
"ava": "^3.15.0",
"babel-eslint": "^8.2.1",
"cssnano": "^4.1.10",
"dotenv": "^8.2.0",
@ -60,6 +67,7 @@
"eslint-plugin-prettier": "2.6.2",
"eslint-plugin-vue": "^4.0.0",
"esm": "^3.2.25",
"fast-xml-parser": "^3.19.0",
"node-fetch": "^2.6.1",
"nodemon": "^1.11.0",
"nuxt": "^2.14.11",
@ -67,6 +75,7 @@
"postcss-cli": "^8.3.1",
"prettier": "1.14.3",
"replace-css-url": "^1.2.6",
"structured-data-testing-tool": "^4.5.0",
"tailwindcss": "^1.9.6"
}
}

139
test/main.js Normal file
View file

@ -0,0 +1,139 @@
import { promises as fs } from 'fs'
import test from 'ava'
import parser from 'fast-xml-parser'
import { structuredDataTest } from 'structured-data-testing-tool'
import { Google, Twitter } from 'structured-data-testing-tool/presets'
// require('dotenv').config()
async function testStructuredData ( options ) {
const {
pageUrls,
// Check for compliance with Google, Twitter and Facebook recommendations
presets = [
Google
],
// Check the page includes a specific Schema (see https://schema.org/docs/full.html for a list)
schemas
} = options
for ( const url of pageUrls ) {
const pagePath = `./dist${ url.pathname }/index.html`
const pageHtml = await fs.readFile( pagePath , 'utf-8' )
// https://github.com/glitchdigital/structured-data-testing-tool#api
await structuredDataTest( pageHtml , {
presets,
schemas
}).then(res => {
return res
}).catch(err => {
// console.log( 'err.res.failed', err.res.failed )
if (err.type === 'VALIDATION_FAILED') {
// t.fail( 'Some structured data tests failed.' )
const validationError = new Error( 'Some structured data tests failed.' )
validationError.failed = err.res.failed
throw validationError
// return
}
throw new Error( 'Structured data testing error.', err )
})
// console.log('result', tvUrl.pathname, Object.keys( result ))
}
}
test.before(async t => {
const sitemapXml = await fs.readFile('./dist/sitemap.xml', 'utf-8')
const sitemap = parser.parse( sitemapXml )
// Store sitemap urls to context
t.context.sitemapUrls = sitemap.urlset.url.map( tag => new URL( tag.loc ) )
})
test('All Category pages have valid FAQPage structured data', async (t) => {
const categoryUrls = t.context.sitemapUrls.filter( url => url.pathname.startsWith('/kind/') )
try {
await testStructuredData({
pageUrls: categoryUrls,
schemas: [ 'FAQPage' ],
presets: [
Google,
// Twitter
],
})
} catch ( error ) {
console.log('failed', error.failed)
t.fail( error.message )
}
t.pass()
})
test('All Device pages have valid FAQPage structured data', async (t) => {
const deviceUrls = t.context.sitemapUrls.filter( url => url.pathname.startsWith('/device/') )
try {
await testStructuredData({
pageUrls: deviceUrls,
schemas: [ 'FAQPage' ],
presets: [
Google,
// Twitter
],
})
} catch ( error ) {
console.log('failed', error.failed)
t.fail( error.message )
}
t.pass()
})
test('All TV pages have valid VideoObject structured data', async (t) => {
const tvUrls = t.context.sitemapUrls.filter( url => url.pathname.startsWith('/tv/') )
try {
await testStructuredData({
pageUrls: tvUrls,
schemas: [ 'VideoObject' ]
})
} catch ( error ) {
console.log('failed', error.failed)
t.fail( error.message )
}
t.pass()
})