Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions pages/container-queries.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ function MeasureReporter(props: { id?: string; style?: React.CSSProperties; type
[props.type]
);
if (value === null) {
return <div ref={ref}>Loading...</div>;
return (
<div ref={ref} style={{ ...boxStyles, ...props.style }}>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the same styles already in the initial render, because cloudscape-design/component-toolkit#165 applies to the initial render only.

Loading...
</div>
);
}
return (
<div id={props.id} ref={ref} style={{ ...boxStyles, ...props.style }}>
Expand Down Expand Up @@ -72,8 +76,15 @@ export default function ColumnLayoutPage() {
type={measureType}
/>

<h2>Reports content-box dimensions when border is present</h2>
<MeasureReporter
id="test-border"
style={{ inlineSize: 300, blockSize: 50, border: '2px solid blue' }}
type={measureType}
/>

<h2>Adjusts as the element changes size (resize browser)</h2>
<MeasureReporter id="test-updates" style={{ blockSize: 50 }} type={measureType} />
<MeasureReporter id="test-updates" style={{ blockSize: 50, border: '2px solid blue' }} type={measureType} />

<h2>Returns correct breakpoints</h2>
<BreakpointReporter id="test-breakpoints" style={{ blockSize: 50 }} />
Expand Down
10 changes: 7 additions & 3 deletions src/mixed-line-bar-chart/__tests__/mixed-chart.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ jest.mock('../../../lib/components/popover/utils/positions', () => {
};
});

jest.mock('@cloudscape-design/component-toolkit', () => ({
...jest.requireActual('@cloudscape-design/component-toolkit'),
// Mock the chart width with enough space to fit all expected elements (labels, x ticks, etc)
useContainerQuery: () => [900, null],
}));

jest.mock('@cloudscape-design/component-toolkit/internal', () => ({
...jest.requireActual('@cloudscape-design/component-toolkit/internal'),
getIsRtl: jest.fn().mockReturnValue(false),
Expand Down Expand Up @@ -113,7 +119,7 @@ const thresholdSeries: MixedLineBarChartProps.ThresholdSeries = {
// Transformation to fallback colors for browsers that don't support them are covered by the `parseCssVariable` utility.
const originalCSS = window.CSS;

let originalGetComputedStyle: Window['getComputedStyle'];
const originalGetComputedStyle = window.getComputedStyle;
const fakeGetComputedStyle: Window['getComputedStyle'] = (...args) => {
const result = originalGetComputedStyle(...args);
result.borderWidth = '2px'; // Approximate mock value for the popover body' border width
Expand All @@ -124,9 +130,7 @@ const fakeGetComputedStyle: Window['getComputedStyle'] = (...args) => {

beforeEach(() => {
window.CSS.supports = () => true;
originalGetComputedStyle = window.getComputedStyle;
window.getComputedStyle = fakeGetComputedStyle;

jest.resetAllMocks();
});
afterEach(() => {
Expand Down
Loading