Repository navigation
[web-console] Cut long tag names to the width of their container - #8157
Karakatiza666 wants to merge 2 commits into
Conversation
| const hit = hitAt(contentRight - 4, box.top + box.height / 2) | ||
|
|
||
| expect(hit.closest('a')?.getAttribute('href')).toMatch(/\/pipelines\/alpha\/$/) | ||
| roleState.current = undefined |
There was a problem hiding this comment.
pitfall (medium): This reset runs only when the assertion above passes. If the test fails, roleState stays write for every later test in the file, so one failure causes others. Reset it in the afterEach of this describe, as the Table — tags block does.
There was a problem hiding this comment.
Fixed in 16be7dd: the afterEach of the Table — row link block resets roleState now.
|
LGTM. I found no correctness bugs and no feldera-pr-checks gate fails. The change affects only how the web console looks, so it needs no docs. What I ran
missing (low–medium): cases the PR's tests do not cover. They all pass on this branch, so add them only if you want them as regression tests:
QA tests (Tags.svelte.spec.ts)it('QA: with two tags, hides the second in "+1" when it does not fit', async () => {
const longTag = 'a-very-long-tag-name-that-does-not-fit'
const { container } = renderTags({ tags: [longTag, 'second'] })
container.style.width = '200px'
const showAll = page.getByRole('button', { name: 'Show all tags' })
await expect.element(showAll).toHaveTextContent('+1')
const right = container.getBoundingClientRect().right
expect(showAll.element().getBoundingClientRect().right).toBeLessThanOrEqual(right)
expect(isTruncated(chipTextOf(container, longTag)!)).toBe(true)
})
it('QA: read-only row cuts a long tag and keeps "+N" inside', async () => {
roleState.current = 'read'
const longTag = 'a-very-long-tag-name-that-does-not-fit'
const { container } = renderTags({ tags: [longTag, 'second', 'third'] })
container.style.width = '200px'
await expect.element(page.getByText('+2')).toBeVisible()
const right = container.getBoundingClientRect().right
expect(page.getByText('+2').element().getBoundingClientRect().right).toBeLessThanOrEqual(right)
expect(isTruncated(chipTextOf(container, longTag)!)).toBe(true)
})
it('QA: re-measures when a long tag is replaced by a short one', async () => {
const longTag = 'a-very-long-tag-name-that-does-not-fit'
const { container, rerender } = renderTags({ tags: [longTag, 'second', 'third'] })
container.style.width = '200px'
const showAll = page.getByRole('button', { name: 'Show all tags' })
await expect.element(showAll).toHaveTextContent('+2')
await rerender({ tags: ['short', 'second', 'third'] })
await expect.element(showAll).toHaveTextContent('+1')
await expect.element(page.getByRole('button', { name: 'second' })).toBeVisible()
})
it('QA: very narrow container keeps "+N" inside', async () => {
const { container } = renderTags({ tags: ['production', 'second', 'third'] })
container.style.width = '60px'
const showAll = page.getByRole('button', { name: 'Show all tags' })
await expect.element(showAll).toHaveTextContent('+2')
const right = container.getBoundingClientRect().right
expect(showAll.element().getBoundingClientRect().right).toBeLessThanOrEqual(right)
}) |
jackgale
left a comment
There was a problem hiding this comment.
Looks good to me, we can iterate on the max width and arrive at something less arbitrary with more data. But this is a good place to start.
4d81770 to
abbf1ae
Compare
Fixes #6862. - In the pipelines table, only the last tag chip that fits is cut with an ellipsis. The tags that do not fit go into the "+N" count. - The table has a set width, so `table-layout: fixed` applies and a long tag no longer makes its column wider than the user set it. - The default width of the Tags column fits about two and a half tags of 10 characters. - In the tag popup, a long tag name is cut, so the edit button stays visible.
A failed assertion skipped the reset and left the write role set for the later tests.
16be7dd to
52871b1
Compare
Fixes #6862.
Tests
Table.svelte.spec.ts: a screenshot test of the Tags column with long tags and the tag popup open. Also tests that a column with a long tag keeps its set width, and that a click on the empty part of a Tags cell reaches the row link.Tags.svelte.spec.ts: tests for the cut first chip, for a cut second chip only, for a hidden chip that shows again when the container grows, for a removed tag, and for the edit button of a long tag in the popup.