test: remove redundant expectations (#11932)

This commit is contained in:
Alex Rudenko 2024-02-16 11:40:08 +01:00 committed by GitHub
parent aef584c815
commit e35aff81e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 1154 deletions

File diff suppressed because it is too large Load Diff

View File

@ -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>

View File

@ -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();

View File

@ -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 => {