From 347c88346ddd44e767cb170addc44d2036b5c36d Mon Sep 17 00:00:00 2001
From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Date: Fri, 11 Sep 2026 19:25:08 +0200
Subject: [PATCH] [Lens] Assert truncate formatter contract instead of pinning
top value (#288956)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes #287650
### Summary
- The `keyword formatters > should display truncate string formatter
correctly` test failed with `expected 'ant...' to sort of equal
'dal...'`.
- The datatable is a `Top 9 values` terms aggregation over a runtime
field emitting `links.raw`, spanning a 3-shard `logstash-*` data view.
Multi-shard terms aggregations are approximate, so when candidate values
are tightly clustered in count the #1 slot flips between runs (`dal...`
vs `ant...`) — both are valid truncations.
- This patch asserts the truncation *contract* (3 chars + `...`) via
`/^.{3}\.\.\.$/` instead of pinning a specific top value, since the
`TRUNCATE` formatter — not which value ranks first — is what this test
verifies.
### Context
- Follows the fix proposed by the [Failed Test
Investigator](https://github.com/elastic/kibana/issues/287650#issuecomment-5524651204):
the returned cell was a valid truncation, so the formatter rendered
correctly; only the non-deterministic underlying top value changed. This
is expected Elasticsearch behavior, not a product or timing bug.
- The new assertion still fails if truncation regresses (wrong length or
missing ellipsis), so formatter coverage is preserved. `.match(RegExp)`
is supported by `@kbn/expect`.
- Failed twice on `kibana-on-merge` (main) — the local pipeline, not
Cloud-specific — consistent with a data/assertion issue rather than an
environment one.
Verification
#### Verified locally
✅ Passed: `node scripts/eslint
x-pack/platform/test/functional/apps/lens/group2/field_formatters.ts`
#### Not verified locally
- This is an FTR test requiring a live Elasticsearch + Kibana, which
cannot be run in this environment. Its CI covers the change once the PR
is open.
> [!NOTE]
> Share feedback in #kibana-qa. Mention `@copilot` to make quick
changes.
> Generated by [Flaky Test
Fixer](https://github.com/elastic/kibana/actions/runs/33747031300) for
#287650 · opus · 156.2 AIC · ⌖ 38 AIC · ⊞ 12.8K ·
[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)
Co-authored-by: Claude Opus 4 (1M context)
Co-authored-by: Marco Vettorello
(cherry picked from commit dfab8eefca509d3f9b3060e22108ca6a0350cb8f)
---
.../test/functional/apps/lens/group2/field_formatters.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/x-pack/platform/test/functional/apps/lens/group2/field_formatters.ts b/x-pack/platform/test/functional/apps/lens/group2/field_formatters.ts
index 82d8e67eeac04..269d3fabb3b1f 100644
--- a/x-pack/platform/test/functional/apps/lens/group2/field_formatters.ts
+++ b/x-pack/platform/test/functional/apps/lens/group2/field_formatters.ts
@@ -106,7 +106,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await header.waitUntilLoadingHasFinished();
});
await lens.waitForVisualization();
- expect(await lens.getDatatableCellText(0, 0)).to.eql('dal...');
+ expect(await lens.getDatatableCellText(0, 0)).to.match(/^.{3}\.\.\.$/);
});
});