import {ShardingTest} from "jstests/libs/shardingtest.js";
const st = new ShardingTest({shards: 1});
const testDB = st.s.getDB(jsTestName());
assert.commandWorked(st.s.adminCommand({enableSharding: testDB.getName()}));
assert.commandWorked(
testDB.sales.insertMany([{product: "widget"}, {product: "widget"}, {product: "gizmo"}]));
assert.commandWorked(
testDB.createView("topSeller", "sales", [{$sortByCount: "$product"}, {$limit: 1}]));
assert.commandWorked(testDB.reports.insert({product: "gizmo"}));
const res =
testDB.reports
.aggregate(
[{$lookup: {from: "topSeller", localField: "product", foreignField: "_id", as: "t"}}])
.toArray();
assert.eq(0, res[0].t.length);
st.stop();