-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WRQ-4709 : Added performance tests for agate components (#79)
* added performance tests for agate components * code review fixes * Solved lint errors. Added fallback script for serve * minor update README --------- Co-authored-by: Seungho Park <[email protected]>
- Loading branch information
1 parent
2017ac1
commit b001733
Showing
91 changed files
with
6,067 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/* global CPUThrottling, page, minFPS, maxFID, maxCLS, stepNumber, maxDCL, maxFCP, maxLCP, passRatio, serverAddr, targetEnv */ | ||
|
||
const TestResults = require('../../TestResults'); | ||
const {CLS, FID, FPS, getAverageFPS, PageLoadingMetrics} = require('../../TraceModel'); | ||
const {clsValue, firstInputValue, getFileName, newPageMultiple} = require('../../utils'); | ||
|
||
describe('ArcPicker', () => { | ||
const component = 'ArcPicker'; | ||
TestResults.newFile(component); | ||
|
||
describe('click', () => { | ||
it('animates', async () => { | ||
await FPS(); | ||
await page.goto(`http://${serverAddr}/arcPicker`); | ||
await page.waitForSelector('#arcPicker'); | ||
await page.click('#arcPicker'); // to move mouse on the button. | ||
await page.mouse.down(); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.mouse.up(); | ||
await page.mouse.down(); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.mouse.up(); | ||
await page.mouse.down(); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.mouse.up(); | ||
await page.mouse.down(); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.mouse.up(); | ||
|
||
const averageFPS = await getAverageFPS(); | ||
TestResults.addResult({component: component, type: 'FPS Click', actualValue: Math.round((averageFPS + Number.EPSILON) * 1000) / 1000}); | ||
|
||
expect(averageFPS).toBeGreaterThan(minFPS); | ||
}); | ||
}); | ||
|
||
describe('keypress', () => { | ||
it('animates', async () => { | ||
await FPS(); | ||
await page.goto(`http://${serverAddr}/arcPicker`); | ||
await page.waitForSelector('#arcPicker'); | ||
await page.focus('#arcPicker'); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.keyboard.down('ArrowUp'); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.keyboard.up('ArrowUp'); | ||
await page.keyboard.down('ArrowUp'); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.keyboard.up('ArrowUp'); | ||
await page.keyboard.down('ArrowDown'); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.keyboard.up('ArrowDown'); | ||
await page.keyboard.down('ArrowDown'); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.keyboard.up('ArrowDown'); | ||
|
||
const averageFPS = await getAverageFPS(); | ||
TestResults.addResult({component: component, type: 'FPS Keypress', actualValue: Math.round((averageFPS + Number.EPSILON) * 1000) / 1000}); | ||
|
||
expect(averageFPS).toBeGreaterThan(minFPS); | ||
}); | ||
}); | ||
|
||
it('should have a good FID and CLS', async () => { | ||
await page.evaluateOnNewDocument(FID); | ||
await page.evaluateOnNewDocument(CLS); | ||
await page.goto(`http://${serverAddr}/arcPicker`); | ||
await page.waitForSelector('#arcPicker'); | ||
await page.focus('#arcPicker'); | ||
await page.keyboard.down('ArrowUp'); | ||
await new Promise(r => setTimeout(r, 200)); | ||
|
||
let actualFirstInput = await firstInputValue(); | ||
let actualCLS = await clsValue(); | ||
|
||
TestResults.addResult({component: component, type: 'FID', actualValue: Math.round((actualFirstInput + Number.EPSILON) * 1000) / 1000}); | ||
TestResults.addResult({component: component, type: 'CLS', actualValue: Math.round((actualCLS + Number.EPSILON) * 1000) / 1000}); | ||
|
||
expect(actualFirstInput).toBeLessThan(maxFID); | ||
expect(actualCLS).toBeLessThan(maxCLS); | ||
}); | ||
|
||
it('should have a good DCL, FCP and LCP', async () => { | ||
const filename = getFileName(component); | ||
|
||
let passContDCL = 0; | ||
let passContFCP = 0; | ||
let passContLCP = 0; | ||
let avgDCL = 0; | ||
let avgFCP = 0; | ||
let avgLCP = 0; | ||
for (let step = 0; step < stepNumber; step++) { | ||
const arcPickerPage = targetEnv === 'TV' ? page : await newPageMultiple(); | ||
await arcPickerPage.emulateCPUThrottling(CPUThrottling); | ||
|
||
await arcPickerPage.tracing.start({path: filename, screenshots: false}); | ||
await arcPickerPage.goto(`http://${serverAddr}/arcPicker`); | ||
await arcPickerPage.waitForSelector('#arcPicker'); | ||
await new Promise(r => setTimeout(r, 200)); | ||
|
||
await arcPickerPage.tracing.stop(); | ||
|
||
const {actualDCL, actualFCP, actualLCP} = PageLoadingMetrics(filename); | ||
avgDCL = avgDCL + actualDCL; | ||
if (actualDCL < maxDCL) { | ||
passContDCL += 1; | ||
} | ||
|
||
avgFCP = avgFCP + actualFCP; | ||
if (actualFCP < maxFCP) { | ||
passContFCP += 1; | ||
} | ||
|
||
avgLCP = avgLCP + actualLCP; | ||
if (actualLCP < maxLCP) { | ||
passContLCP += 1; | ||
} | ||
|
||
if (targetEnv === 'PC') await arcPickerPage.close(); | ||
} | ||
avgDCL = avgDCL / stepNumber; | ||
avgFCP = avgFCP / stepNumber; | ||
avgLCP = avgLCP / stepNumber; | ||
|
||
TestResults.addResult({component: component, type: 'DCL', actualValue: Math.round((avgDCL + Number.EPSILON) * 1000) / 1000}); | ||
TestResults.addResult({component: component, type: 'FCP', actualValue: Math.round((avgFCP + Number.EPSILON) * 1000) / 1000}); | ||
TestResults.addResult({component: component, type: 'LCP', actualValue: Math.round((avgLCP + Number.EPSILON) * 1000) / 1000}); | ||
|
||
expect(passContDCL).toBeGreaterThan(passRatio * stepNumber); | ||
expect(avgDCL).toBeLessThan(maxDCL); | ||
|
||
expect(passContFCP).toBeGreaterThan(passRatio * stepNumber); | ||
expect(avgFCP).toBeLessThan(maxFCP); | ||
|
||
expect(passContLCP).toBeGreaterThan(passRatio * stepNumber); | ||
expect(avgLCP).toBeLessThan(maxLCP); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/* global CPUThrottling, page, minFPS, maxFID, maxCLS, stepNumber, maxDCL, maxFCP, maxLCP, passRatio, serverAddr, targetEnv */ | ||
|
||
const TestResults = require('../../TestResults'); | ||
const {CLS, FID, FPS, getAverageFPS, PageLoadingMetrics} = require('../../TraceModel'); | ||
const {clsValue, firstInputValue, getFileName, newPageMultiple} = require('../../utils'); | ||
|
||
describe('ArcSlider', () => { | ||
const component = 'ArcSlider'; | ||
TestResults.newFile(component); | ||
|
||
describe('click', () => { | ||
it('animates', async () => { | ||
await FPS(); | ||
await page.goto(`http://${serverAddr}/arcSlider`); | ||
await page.waitForSelector('#arcSlider'); | ||
await page.click('#arcSlider'); // to move mouse on the button. | ||
await page.mouse.down(); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.mouse.up(); | ||
await page.mouse.down(); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.mouse.up(); | ||
await page.mouse.down(); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.mouse.up(); | ||
await page.mouse.down(); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.mouse.up(); | ||
|
||
const averageFPS = await getAverageFPS(); | ||
TestResults.addResult({component: component, type: 'FPS Click', actualValue: Math.round((averageFPS + Number.EPSILON) * 1000) / 1000}); | ||
|
||
expect(averageFPS).toBeGreaterThan(minFPS); | ||
}); | ||
}); | ||
|
||
describe('keypress', () => { | ||
it('animates', async () => { | ||
await FPS(); | ||
await page.goto(`http://${serverAddr}/arcSlider`); | ||
await page.waitForSelector('#arcSlider'); | ||
await page.focus('#arcSlider'); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.keyboard.down('ArrowUp'); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.keyboard.up('ArrowUp'); | ||
await page.keyboard.down('ArrowUp'); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.keyboard.up('ArrowUp'); | ||
await page.keyboard.down('ArrowDown'); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.keyboard.up('ArrowDown'); | ||
await page.keyboard.down('ArrowDown'); | ||
await new Promise(r => setTimeout(r, 100)); | ||
await page.keyboard.up('ArrowDown'); | ||
|
||
const averageFPS = await getAverageFPS(); | ||
TestResults.addResult({component: component, type: 'FPS Keypress', actualValue: Math.round((averageFPS + Number.EPSILON) * 1000) / 1000}); | ||
|
||
expect(averageFPS).toBeGreaterThan(minFPS); | ||
}); | ||
}); | ||
|
||
it('should have a good FID and CLS', async () => { | ||
await page.evaluateOnNewDocument(FID); | ||
await page.evaluateOnNewDocument(CLS); | ||
await page.goto(`http://${serverAddr}/arcSlider`); | ||
await page.waitForSelector('#arcSlider'); | ||
await page.focus('#arcSlider'); | ||
await page.keyboard.down('ArrowUp'); | ||
await new Promise(r => setTimeout(r, 200)); | ||
|
||
let actualFirstInput = await firstInputValue(); | ||
let actualCLS = await clsValue(); | ||
|
||
TestResults.addResult({component: component, type: 'FID', actualValue: Math.round((actualFirstInput + Number.EPSILON) * 1000) / 1000}); | ||
TestResults.addResult({component: component, type: 'CLS', actualValue: Math.round((actualCLS + Number.EPSILON) * 1000) / 1000}); | ||
|
||
expect(actualFirstInput).toBeLessThan(maxFID); | ||
expect(actualCLS).toBeLessThan(maxCLS); | ||
}); | ||
|
||
it('should have a good DCL, FCP and LCP', async () => { | ||
const filename = getFileName(component); | ||
|
||
let passContDCL = 0; | ||
let passContFCP = 0; | ||
let passContLCP = 0; | ||
let avgDCL = 0; | ||
let avgFCP = 0; | ||
let avgLCP = 0; | ||
for (let step = 0; step < stepNumber; step++) { | ||
const buttonPage = targetEnv === 'TV' ? page : await newPageMultiple(); | ||
await buttonPage.emulateCPUThrottling(CPUThrottling); | ||
|
||
await buttonPage.tracing.start({path: filename, screenshots: false}); | ||
await buttonPage.goto(`http://${serverAddr}/arcSlider`); | ||
await buttonPage.waitForSelector('#arcSlider'); | ||
await new Promise(r => setTimeout(r, 200)); | ||
|
||
await buttonPage.tracing.stop(); | ||
|
||
const {actualDCL, actualFCP, actualLCP} = PageLoadingMetrics(filename); | ||
avgDCL = avgDCL + actualDCL; | ||
if (actualDCL < maxDCL) { | ||
passContDCL += 1; | ||
} | ||
|
||
avgFCP = avgFCP + actualFCP; | ||
if (actualFCP < maxFCP) { | ||
passContFCP += 1; | ||
} | ||
|
||
avgLCP = avgLCP + actualLCP; | ||
if (actualLCP < maxLCP) { | ||
passContLCP += 1; | ||
} | ||
|
||
if (targetEnv === 'PC') await buttonPage.close(); | ||
} | ||
avgDCL = avgDCL / stepNumber; | ||
avgFCP = avgFCP / stepNumber; | ||
avgLCP = avgLCP / stepNumber; | ||
|
||
TestResults.addResult({component: component, type: 'DCL', actualValue: Math.round((avgDCL + Number.EPSILON) * 1000) / 1000}); | ||
TestResults.addResult({component: component, type: 'FCP', actualValue: Math.round((avgFCP + Number.EPSILON) * 1000) / 1000}); | ||
TestResults.addResult({component: component, type: 'LCP', actualValue: Math.round((avgLCP + Number.EPSILON) * 1000) / 1000}); | ||
|
||
expect(passContDCL).toBeGreaterThan(passRatio * stepNumber); | ||
expect(avgDCL).toBeLessThan(maxDCL); | ||
|
||
expect(passContFCP).toBeGreaterThan(passRatio * stepNumber); | ||
expect(avgFCP).toBeLessThan(maxFCP); | ||
|
||
expect(passContLCP).toBeGreaterThan(passRatio * stepNumber); | ||
expect(avgLCP).toBeLessThan(maxLCP); | ||
}); | ||
}); | ||
|
Oops, something went wrong.