test: poll for indexer consistency in search e2e (task 0016)
Gitea's issue/PR search endpoint is backed by an asynchronous, eventually- consistent indexer (bleve by default), so a PR opened moments earlier in the e2e `beforeAll` was not yet searchable when `search prs` ran, and the live assertion saw zero matches. Both live-search tests now poll the search via `expect.poll` until the freshly-created content is indexed before asserting on the exact locator-schema output. Record the eventual-consistency behaviour as a project gotcha.
This commit was merged in pull request #17.
This commit is contained in:
@@ -45,6 +45,16 @@ describe.skipIf(!E2E_URL)("end-to-end: search commands", () => {
|
||||
}, 150_000);
|
||||
|
||||
it("returns live issue matches under the locator schema", async () => {
|
||||
// Gitea's search endpoint is backed by an eventually-consistent issue
|
||||
// indexer, so poll until the seeded issue has been indexed and surfaces
|
||||
// under the locator-schema header before asserting on the exact output.
|
||||
await expect
|
||||
.poll(
|
||||
async () => (await runCliTest(["search", "issues", "issue"], { env: env() })).stdout,
|
||||
{ timeout: 20_000, interval: 500 },
|
||||
)
|
||||
.toMatch(/^issues\[\d+\]\{number,title,state,author,created\}:$/m);
|
||||
|
||||
const { stdout, exitCode } = await runCliTest(["search", "issues", "issue"], {
|
||||
env: env(),
|
||||
});
|
||||
@@ -61,6 +71,15 @@ describe.skipIf(!E2E_URL)("end-to-end: search commands", () => {
|
||||
});
|
||||
|
||||
it("returns live pull-request matches under the locator schema", async () => {
|
||||
// The PR was opened moments ago in beforeAll; the indexer needs a beat to
|
||||
// catch up, so poll the search until the PR surfaces before asserting.
|
||||
await expect
|
||||
.poll(
|
||||
async () => (await runCliTest(["search", "prs", "search"], { env: env() })).stdout,
|
||||
{ timeout: 20_000, interval: 500 },
|
||||
)
|
||||
.toMatch(/^pull_requests\[\d+\]\{number,title,state,author,created\}:$/m);
|
||||
|
||||
const { stdout, exitCode } = await runCliTest(["search", "prs", "search"], {
|
||||
env: env(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user