-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests(viewer): add pptr test for viewer #5025
Conversation
assert.deepStrictEqual(pageErrors, []); | ||
}); | ||
|
||
it('should contain all categories', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
below is all basically identical to the extension test
} else { | ||
// Otherwise, disallow file requests outside of LH folder or from node_modules | ||
const filePathDir = path.parse(absoluteFilePath).dir; | ||
if (!filePathDir.startsWith(lhRootDirPath) || filePathDir.includes('node_modules')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drive-by tightening :)
await viewerPage.goto(viewerUrl, {waitUntil: 'networkidle2'}); | ||
const fileInput = await viewerPage.$('#hidden-file-input'); | ||
await fileInput.uploadFile(sampleLhr); | ||
await viewerPage.waitForSelector('.lh-container'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to set a smaller timeout for this and goto? Default is 30s. If the link fails, we should know about it sooner. Speed up the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, yes, misread that as 3s and thought it sounded great :)
|
||
const selectors = { | ||
audits: '.lh-audit,.lh-timeline-metric,.lh-perf-hint', | ||
titles: '.lh-score__title, .lh-perf-hint__title, .lh-timeline-metric__title', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces here too: '.lh-audit, .lh-timeline-metric, .lh-perf-hint',
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
}; | ||
|
||
it('should load with no errors', async () => { | ||
assert.deepStrictEqual(pageErrors, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol. just check pageErrors.length === 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just check pageErrors.length === 0
I got the idea from the audit errors check below when I had errors at first. The error diff prints out the errors the page was seeing (instead of x !== 0
), which is actually pretty nice when things go wrong and you don't have to do an extra debug step to print them
browser = await puppeteer.launch({ | ||
headless: false, | ||
executablePath: process.env.CHROME_PATH, | ||
args: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kill?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
// start puppeteer | ||
browser = await puppeteer.launch({ | ||
headless: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need headful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need headful?
...we're testing as a user? I don't know, I copied from #4640 :) Does it really matter in this instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yea. That's because extensions dont work in headless. You could use headless here but I'm not sure it really matters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headless! lets do it.
used it over there because extensions yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headless! lets do it.
done
}); | ||
viewerPage = await browser.newPage(); | ||
viewerPage.on('pageerror', pageError => pageErrors.push(pageError)); | ||
await viewerPage.goto(viewerUrl, {waitUntil: 'networkidle2'}); | ||
await viewerPage.goto(viewerUrl, {waitUntil: 'networkidle2', timeout: 3000}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will throw if they timeout. Do you want to catch those as errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will throw if they timeout. Do you want to catch those as errors?
I think it's fine? It'll throw and fail in before
, which will fail the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headless but w/e the rest is fine or w/e
const auditErrors = await viewerPage.$$eval('.lh-debug', getDebugStrings, selectors); | ||
const errors = auditErrors.filter(item => item.debugString.includes('Audit error:')); | ||
const unexpectedErrrors = errors.filter(item => { | ||
return !item.debugString.includes('Required RobotsTxt gatherer did not run'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you confirm the savedartifacts are out of date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, no RobotsTxt
artifact in artifacts.json
|
||
// start puppeteer | ||
browser = await puppeteer.launch({ | ||
headless: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headless! lets do it.
used it over there because extensions yes.
executablePath: process.env.CHROME_PATH, | ||
}); | ||
viewerPage = await browser.newPage(); | ||
viewerPage.on('pageerror', pageError => pageErrors.push(pageError)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
travis seems to be unhappy though |
48085fb
to
3154866
Compare
travis unhappiness was due to report changes in #5009. extension test got updates for that but this obviously did not :) |
As we start major work again on the report, it'd be good to have an easy way to verify we aren't breaking viewer. While viewer does already have compile and (a few) basic unit tests, this PR rips off @wardpeet's hard work from #4640 to make a pptr integration test for viewer as well.
Ideally we'd extract some sort of "use puppeteer to test a live report interface" test and have each individual directory file only in charge of setup and teardown, but I think(?) this is sufficient for now as we have more pressing matters.