mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Test that apps with bundle data have sections
This commit is contained in:
parent
149ede5615
commit
8e476abea6
1 changed files with 44 additions and 2 deletions
46
test/main.js
46
test/main.js
|
|
@ -1,14 +1,26 @@
|
|||
import { promises as fs } from 'fs'
|
||||
// import { promises as fs } from 'fs'
|
||||
|
||||
|
||||
import fs from 'fs-extra'
|
||||
import test from 'ava'
|
||||
import parser from 'fast-xml-parser'
|
||||
import axios from 'axios'
|
||||
import { structuredDataTest } from 'structured-data-testing-tool'
|
||||
import { Google, Twitter } from 'structured-data-testing-tool/presets'
|
||||
|
||||
// require('dotenv').config()
|
||||
require('dotenv').config()
|
||||
|
||||
function isString( maybeString ) {
|
||||
return (typeof maybeString === 'string' || maybeString instanceof String)
|
||||
}
|
||||
|
||||
async function pageContains ( needle, pageUrlString ) {
|
||||
const pageUrlInstance = new URL( pageUrlString )
|
||||
const pagePath = `./dist${ pageUrlInstance.pathname }/index.html`
|
||||
const pageHtml = await fs.readFile( pagePath , 'utf-8' )
|
||||
|
||||
return pageHtml.includes( needle )
|
||||
}
|
||||
|
||||
async function testStructuredData ( options ) {
|
||||
const {
|
||||
|
|
@ -200,3 +212,33 @@ test('All TV pages have valid VideoObject structured data', async (t) => {
|
|||
t.pass()
|
||||
|
||||
})
|
||||
|
||||
test('All App pages with bundle data have bundle data visuals', async (t) => {
|
||||
|
||||
const appUrls = t.context.sitemapUrls.filter( url => url.pathname.startsWith('/app/') )
|
||||
|
||||
const appsWithBundleIds = await fs.readJson('./static/app-list.json', 'utf-8').then( appList => {
|
||||
return appList.filter( app => {
|
||||
return app.bundleIds.length > 0
|
||||
})
|
||||
})
|
||||
|
||||
t.log(`${appsWithBundleIds.length} apps with bundle IDs`)
|
||||
|
||||
try {
|
||||
|
||||
for ( const app of appsWithBundleIds ) {
|
||||
const hasAppBundlesSection = await pageContains( 'App Bundles', `${ process.env.URL }${app.endpoint}` )
|
||||
|
||||
if ( !hasAppBundlesSection ) throw new Error(`Couldn't find App Bundles section on ${ app.endpoint }`)
|
||||
}
|
||||
|
||||
} catch ( error ) {
|
||||
console.log('failed', error)
|
||||
t.fail( error.message )
|
||||
}
|
||||
|
||||
t.log( `${appsWithBundleIds.length} valid app pages` )
|
||||
t.pass()
|
||||
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue