Skip to content

Commit aab9c5c

Browse files
committed
Fix pagination tests
1 parent c64f3da commit aab9c5c

File tree

1 file changed

+83
-91
lines changed

1 file changed

+83
-91
lines changed

packages/firestore/test/integration/api/pipeline.test.ts

Lines changed: 83 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,109 +2953,101 @@ apiDescribe.only('Pipelines', persistence => {
29532953
});
29542954
}
29552955

2956-
// sort on __name__ is not working, see b/409358591
2957-
itIf(testUnsupportedFeatures)(
2958-
'supports pagination with filters',
2959-
async () => {
2960-
await addBooks(randomCol);
2961-
const pageSize = 2;
2962-
const pipeline = firestore
2963-
.pipeline()
2964-
.collection(randomCol.path)
2965-
.select('title', 'rating', '__name__')
2966-
.sort(field('rating').descending(), field('__name__').ascending());
2956+
it('supports pagination with filters', async () => {
2957+
await addBooks(randomCol);
2958+
const pageSize = 2;
2959+
const pipeline = firestore
2960+
.pipeline()
2961+
.collection(randomCol.path)
2962+
.select('title', 'rating', '__name__')
2963+
.sort(field('rating').descending(), field('__name__').ascending());
29672964

2968-
let snapshot = await execute(pipeline.limit(pageSize));
2969-
expectResults(
2970-
snapshot,
2971-
{ title: 'The Lord of the Rings', rating: 4.7 },
2972-
{ title: 'Jonathan Strange & Mr Norrell', rating: 4.6 }
2973-
);
2965+
let snapshot = await execute(pipeline.limit(pageSize));
2966+
expectResults(
2967+
snapshot,
2968+
{ title: 'The Lord of the Rings', rating: 4.7 },
2969+
{ title: 'Dune', rating: 4.6 }
2970+
);
29742971

2975-
const lastDoc = snapshot.results[snapshot.results.length - 1];
2972+
const lastDoc = snapshot.results[snapshot.results.length - 1];
29762973

2977-
snapshot = await execute(
2978-
pipeline
2979-
.where(
2980-
or(
2981-
and(
2982-
field('rating').eq(lastDoc.get('rating')),
2983-
field('__path__').gt(lastDoc.ref?.id)
2984-
),
2985-
field('rating').lt(lastDoc.get('rating'))
2986-
)
2974+
snapshot = await execute(
2975+
pipeline
2976+
.where(
2977+
or(
2978+
and(
2979+
field('rating').eq(lastDoc.get('rating')),
2980+
field('__name__').gt(lastDoc.ref)
2981+
),
2982+
field('rating').lt(lastDoc.get('rating'))
29872983
)
2988-
.limit(pageSize)
2989-
);
2990-
expectResults(
2991-
snapshot,
2992-
{ title: 'Pride and Prejudice', rating: 4.5 },
2993-
{ title: 'Crime and Punishment', rating: 4.3 }
2994-
);
2995-
}
2996-
);
2984+
)
2985+
.limit(pageSize)
2986+
);
2987+
expectResults(
2988+
snapshot,
2989+
{ title: 'Jonathan Strange & Mr Norrell', rating: 4.6 },
2990+
{ title: 'The Master and Margarita', rating: 4.6 }
2991+
);
2992+
});
29972993

2998-
// sort on __name__ is not working, see b/409358591
2999-
itIf(testUnsupportedFeatures)(
3000-
'supports pagination with offsets',
3001-
async () => {
3002-
await addBooks(randomCol);
2994+
it('supports pagination with offsets', async () => {
2995+
await addBooks(randomCol);
30032996

3004-
const secondFilterField = '__path__';
2997+
const secondFilterField = '__name__';
30052998

3006-
const pipeline = firestore
3007-
.pipeline()
3008-
.collection(randomCol.path)
3009-
.select('title', 'rating', secondFilterField)
3010-
.sort(
3011-
field('rating').descending(),
3012-
field(secondFilterField).ascending()
3013-
);
2999+
const pipeline = firestore
3000+
.pipeline()
3001+
.collection(randomCol.path)
3002+
.select('title', 'rating', secondFilterField)
3003+
.sort(
3004+
field('rating').descending(),
3005+
field(secondFilterField).ascending()
3006+
);
30143007

3015-
const pageSize = 2;
3016-
let currPage = 0;
3008+
const pageSize = 2;
3009+
let currPage = 0;
30173010

3018-
let snapshot = await execute(
3019-
pipeline.offset(currPage++ * pageSize).limit(pageSize)
3020-
);
3011+
let snapshot = await execute(
3012+
pipeline.offset(currPage++ * pageSize).limit(pageSize)
3013+
);
30213014

3022-
expectResults(
3023-
snapshot,
3024-
{
3025-
title: 'The Lord of the Rings',
3026-
rating: 4.7
3027-
},
3028-
{ title: 'Dune', rating: 4.6 }
3029-
);
3015+
expectResults(
3016+
snapshot,
3017+
{
3018+
title: 'The Lord of the Rings',
3019+
rating: 4.7
3020+
},
3021+
{ title: 'Dune', rating: 4.6 }
3022+
);
30303023

3031-
snapshot = await execute(
3032-
pipeline.offset(currPage++ * pageSize).limit(pageSize)
3033-
);
3034-
expectResults(
3035-
snapshot,
3036-
{
3037-
title: 'Jonathan Strange & Mr Norrell',
3038-
rating: 4.6
3039-
},
3040-
{ title: 'The Master and Margarita', rating: 4.6 }
3041-
);
3024+
snapshot = await execute(
3025+
pipeline.offset(currPage++ * pageSize).limit(pageSize)
3026+
);
3027+
expectResults(
3028+
snapshot,
3029+
{
3030+
title: 'Jonathan Strange & Mr Norrell',
3031+
rating: 4.6
3032+
},
3033+
{ title: 'The Master and Margarita', rating: 4.6 }
3034+
);
30423035

3043-
snapshot = await execute(
3044-
pipeline.offset(currPage++ * pageSize).limit(pageSize)
3045-
);
3046-
expectResults(
3047-
snapshot,
3048-
{
3049-
title: 'A Long Way to a Small, Angry Planet',
3050-
rating: 4.6
3051-
},
3052-
{
3053-
title: 'Pride and Prejudice',
3054-
rating: 4.5
3055-
}
3056-
);
3057-
}
3058-
);
3036+
snapshot = await execute(
3037+
pipeline.offset(currPage++ * pageSize).limit(pageSize)
3038+
);
3039+
expectResults(
3040+
snapshot,
3041+
{
3042+
title: 'A Long Way to a Small, Angry Planet',
3043+
rating: 4.6
3044+
},
3045+
{
3046+
title: 'Pride and Prejudice',
3047+
rating: 4.5
3048+
}
3049+
);
3050+
});
30593051
});
30603052

30613053
describe('console support', () => {

0 commit comments

Comments
 (0)