mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test: remove redundant expectations (#11932)
This commit is contained in:
parent
aef584c815
commit
e35aff81e2
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,8 @@
|
|||||||
<style>
|
<style>
|
||||||
div {
|
div {
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
|
width: 300px;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<div>Hi, I'm frame</div>
|
<div>Hi, I'm frame</div>
|
||||||
|
@ -34,18 +34,14 @@ describe('ElementHandle specs', function () {
|
|||||||
expect(box).toEqual({x: 100, y: 50, width: 50, height: 50});
|
expect(box).toEqual({x: 100, y: 50, width: 50, height: 50});
|
||||||
});
|
});
|
||||||
it('should handle nested frames', async () => {
|
it('should handle nested frames', async () => {
|
||||||
const {page, server, isChrome} = await getTestState();
|
const {page, server} = await getTestState();
|
||||||
|
|
||||||
await page.setViewport({width: 500, height: 500});
|
await page.setViewport({width: 500, height: 500});
|
||||||
await page.goto(server.PREFIX + '/frames/nested-frames.html');
|
await page.goto(server.PREFIX + '/frames/nested-frames.html');
|
||||||
const nestedFrame = page.frames()[1]!.childFrames()[1]!;
|
const nestedFrame = page.frames()[1]!.childFrames()[1]!;
|
||||||
using elementHandle = (await nestedFrame.$('div'))!;
|
using elementHandle = (await nestedFrame.$('div'))!;
|
||||||
const box = await elementHandle.boundingBox();
|
const box = await elementHandle.boundingBox();
|
||||||
if (isChrome) {
|
expect(box).toEqual({x: 28, y: 182, width: 300, height: 18});
|
||||||
expect(box).toEqual({x: 28, y: 182, width: 264, height: 18});
|
|
||||||
} else {
|
|
||||||
expect(box).toEqual({x: 28, y: 182, width: 254, height: 18});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
it('should return null for invisible elements', async () => {
|
it('should return null for invisible elements', async () => {
|
||||||
const {page} = await getTestState();
|
const {page} = await getTestState();
|
||||||
|
@ -81,6 +81,7 @@ for (let i = testExpectations.length - 1; i >= 0; i--) {
|
|||||||
const labels = new Set(expectation.expectations);
|
const labels = new Set(expectation.expectations);
|
||||||
const platforms = new Set(expectation.platforms);
|
const platforms = new Set(expectation.platforms);
|
||||||
|
|
||||||
|
let foundMatch = false;
|
||||||
for (let j = i - 1; j >= 0; j--) {
|
for (let j = i - 1; j >= 0; j--) {
|
||||||
const candidate = testExpectations[j];
|
const candidate = testExpectations[j];
|
||||||
const candidateParams = new Set(candidate.parameters);
|
const candidateParams = new Set(candidate.parameters);
|
||||||
@ -95,6 +96,7 @@ for (let i = testExpectations.length - 1; i >= 0; i--) {
|
|||||||
isSubset(candidateParams, params) &&
|
isSubset(candidateParams, params) &&
|
||||||
isSubset(candidatePlatforms, platforms)
|
isSubset(candidatePlatforms, platforms)
|
||||||
) {
|
) {
|
||||||
|
foundMatch = true;
|
||||||
if (isSubset(candidateLabels, labels)) {
|
if (isSubset(candidateLabels, labels)) {
|
||||||
console.log('removing', expectation, 'already covered by', candidate);
|
console.log('removing', expectation, 'already covered by', candidate);
|
||||||
toBeRemoved.add(expectation);
|
toBeRemoved.add(expectation);
|
||||||
@ -102,6 +104,15 @@ for (let i = testExpectations.length - 1; i >= 0; i--) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!foundMatch && isSubset(new Set(['PASS']), labels)) {
|
||||||
|
console.log(
|
||||||
|
'removing',
|
||||||
|
expectation,
|
||||||
|
'because the default expectation is to pass'
|
||||||
|
);
|
||||||
|
toBeRemoved.add(expectation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testExpectations = testExpectations.filter(item => {
|
testExpectations = testExpectations.filter(item => {
|
||||||
|
Loading…
Reference in New Issue
Block a user