Skip to content

Commit 1b6bc90

Browse files
authored
Added disabled badge for not enabled fields (#116)
* Added disabled badge for not enabled fields * E2E fixed * Comments resolved * Updated the E2E test case with multiple chips
1 parent d1b18b5 commit 1b6bc90

18 files changed

Lines changed: 141 additions & 43 deletions

File tree

‎packages/oc-docs/e2e/components/overview/collection-configuration.component.ts‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1-
import type { Locator } from '@playwright/test';
2-
import { BaseComponent } from '../base.component';
3-
import { SecretValueComponent } from '../secret-value.component';
1+
import type { Locator } from "@playwright/test";
2+
import { BaseComponent } from "../base.component";
3+
import { SecretValueComponent } from "../secret-value.component";
44

55
export class ConfigurationSection extends BaseComponent {
6-
readonly root = this.page.getByTestId('collection-config');
6+
readonly root = this.page.getByTestId("collection-config");
77

8-
readonly copyButton = this.root.getByTestId('collection-config-tests-copy');
8+
readonly copyButton = this.root.getByTestId("collection-config-tests-copy");
99

10-
readonly secret = new SecretValueComponent(this.page, 'collection-config-auth-secret');
10+
readonly secret = new SecretValueComponent(
11+
this.page,
12+
"collection-config-auth-secret",
13+
);
14+
15+
readonly disabledRows = this.root
16+
.getByTestId("property-value-line")
17+
.filter({ has: this.page.getByTestId("disabled-badge") });
1118

1219
subHeading(name: string): Locator {
13-
return this.root.getByTestId('collection-config-subheading').filter({ hasText: name });
20+
return this.root
21+
.getByTestId("collection-config-subheading")
22+
.filter({ hasText: name });
1423
}
1524

1625
async copyToClipboard(): Promise<void> {

‎packages/oc-docs/e2e/tests/overview/overview.spec.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
import { test, expect } from '../../playwright';
2+
import type { Locator } from '@playwright/test';
3+
4+
const boundingBoxOf = async (locator: Locator) => {
5+
const box = await locator.boundingBox();
6+
if (box === null) throw new Error('expected the element to have a bounding box');
7+
return box;
8+
};
29

310
test.describe('Collection Overview', () => {
411
test.beforeEach(async ({ overviewPage }) => {
@@ -79,4 +86,38 @@ test.describe('Collection Overview', () => {
7986
});
8087
});
8188
});
89+
90+
test('mobile: every Disabled chip stays pinned at the row end without overflowing', async ({ overviewPage, page }) => {
91+
await page.setViewportSize({ width: 360, height: 800 });
92+
const { configuration } = overviewPage;
93+
94+
const rows = configuration.disabledRows;
95+
const count = await rows.count();
96+
expect(count).toBeGreaterThan(0);
97+
98+
const card = await boundingBoxOf(configuration.root);
99+
100+
for (let i = 0; i < count; i += 1) {
101+
const row = rows.nth(i);
102+
const value = row.getByTestId('property-value');
103+
const chip = await boundingBoxOf(row.getByTestId('disabled-badge'));
104+
const valueBox = await boundingBoxOf(value);
105+
106+
await test.step(`row ${i}: the chip sits at the end — to the right of the value`, () => {
107+
expect(chip.x).toBeGreaterThanOrEqual(valueBox.x + valueBox.width);
108+
});
109+
110+
await test.step(`row ${i}: the chip stays within the config card, never clipped or overflowing`, () => {
111+
expect(chip.x + chip.width).toBeLessThanOrEqual(card.x + card.width);
112+
});
113+
114+
await test.step(`row ${i}: the value keeps its truncation styling, so a long value ellipsizes rather than pushing the chip off`, async () => {
115+
const style = await value.evaluate((el) => {
116+
const cs = getComputedStyle(el);
117+
return { overflow: cs.overflow, textOverflow: cs.textOverflow, whiteSpace: cs.whiteSpace };
118+
});
119+
expect(style).toEqual({ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' });
120+
});
121+
}
122+
});
82123
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import { describe, it, expect } from 'vitest';
3+
import { useRenderToDom } from '../../hooks/useRenderToDom';
4+
import { query } from '../../test-utils/dom';
5+
import { DisabledBadge } from './DisabledBadge';
6+
7+
describe('DisabledBadge', () => {
8+
it('renders a "Disabled" chip', () => {
9+
const root = useRenderToDom(<DisabledBadge />);
10+
expect(query(root, '.disabled-badge').text.trim()).toBe('Disabled');
11+
});
12+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import { StyledWrapper } from './StyledWrapper';
3+
4+
export const DisabledBadge: React.FC = () => (
5+
<StyledWrapper className="disabled-badge" data-testid="disabled-badge">Disabled</StyledWrapper>
6+
);
7+
8+
export default DisabledBadge;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import styled from '@emotion/styled';
2+
3+
export const StyledWrapper = styled.span`
4+
display: inline-flex;
5+
align-items: center;
6+
flex-shrink: 0;
7+
font-size: 0.6875rem;
8+
font-weight: 500;
9+
line-height: 1;
10+
white-space: nowrap;
11+
color: var(--text-muted);
12+
background: var(--badge-bg);
13+
border: 0.0625rem solid var(--border-color);
14+
border-radius: 0.25rem;
15+
padding: 0.125rem 0.375rem;
16+
`;

‎packages/oc-docs/src/components/ExecutionContext/AssertList/AssertList.spec.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ describe('AssertList', () => {
2525
expect(root.querySelector('.assert-expr')?.text.trim()).toBe('res.body.token is defined');
2626
});
2727

28-
it('marks a disabled assertion with the is-disabled class', () => {
28+
it('marks a disabled assertion with the Disabled chip', () => {
2929
const root = useRenderToDom(<AssertList assertions={[disabled]} />);
30-
expect(root.querySelector('.assert-item.is-disabled')).not.toBeNull();
30+
expect(root.querySelector('.disabled-badge')).not.toBeNull();
3131
});
3232
});

‎packages/oc-docs/src/components/ExecutionContext/AssertList/AssertList.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { ScopeTag } from '../ScopeTag/ScopeTag';
3+
import { DisabledBadge } from '../../DisabledBadge/DisabledBadge';
34
import { VariableText } from '../../VariableText/VariableText';
45
import { TruncatedText } from '../../TruncatedText/TruncatedText';
56
import { Description } from '../../Description/Description';
@@ -25,14 +26,15 @@ export const AssertList: React.FC<AssertListProps> = ({ assertions }) => {
2526
{assertions.map((assert, index) => {
2627
const text = assertionText(assert);
2728
return (
28-
<div key={`${assert.expression}-${index}`} className={`assert-item ${assert.disabled ? 'is-disabled' : ''}`}>
29+
<div key={`${assert.expression}-${index}`} className="assert-item">
2930
<div className="assert-row">
3031
<ScopeTag scope={assert.level} />
3132
<code className="assert-expr">
3233
<TruncatedText text={text}>
3334
<VariableText value={text} />
3435
</TruncatedText>
3536
</code>
37+
{assert.disabled ? <DisabledBadge /> : null}
3638
</div>
3739
<Description text={assert.description} />
3840
</div>

‎packages/oc-docs/src/components/ExecutionContext/AssertList/StyledWrapper.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ export const StyledWrapper = styled.div`
77
.assert-item:not(:first-child) {
88
border-top: 0.0625rem solid var(--oc-border-border0);
99
}
10-
.assert-item.is-disabled {
11-
opacity: 0.55;
12-
}
1310
.assert-row {
1411
display: flex;
1512
align-items: center;

‎packages/oc-docs/src/components/ExecutionContext/VariablesPanel/VariablesPanel.spec.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ describe('VariablesPanel', () => {
4444
expect(html).toContain('JWT access token');
4545
});
4646

47-
it('marks a disabled variable so it can be visually dimmed', () => {
47+
it('marks a disabled variable with the Disabled chip', () => {
4848
const html = renderToStaticMarkup(
4949
<VariablesPanel preVars={[{ name: 'legacy', value: 'v1', disabled: true }]} postVars={[]} />
5050
);
5151
expect(html).toContain('legacy');
52-
expect(html).toContain('property-row--disabled'); // PropertyTable's disabled-row class
52+
expect(html).toContain('disabled-badge');
5353
});
5454

5555
describe('stacked variant (overview)', () => {

‎packages/oc-docs/src/components/FolderConfiguration/FolderConfiguration.spec.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('FolderConfiguration', () => {
6262
expect(root.querySelector('[data-testid="folder-config-tests"]')).toBeTruthy();
6363
});
6464

65-
it('renders disabled headers (dimmed) and their descriptions', () => {
65+
it('renders disabled headers with a Disabled chip and their descriptions', () => {
6666
const config: FolderConfig = {
6767
...baseConfig,
6868
headers: [{ name: 'X-Debug', value: 'on', disabled: true, description: 'toggles debug logging' }]
@@ -72,7 +72,7 @@ describe('FolderConfiguration', () => {
7272
const headers = root.querySelector('[data-testid="folder-config-headers"]');
7373
expect(headers).toBeTruthy();
7474
expect(headers?.querySelector('.property-key')?.text.trim()).toBe('X-Debug');
75-
expect(headers?.querySelector('.property-row--disabled')).toBeTruthy();
75+
expect(headers?.querySelector('.disabled-badge')).toBeTruthy();
7676
expect(headers?.text).toContain('toggles debug logging');
7777
});
7878

0 commit comments

Comments
 (0)