Skip to content

Commit 9978d3e

Browse files
authored
Merge pull request #379 from chromaui/update-graphql-schema
Update GraphQL schema and handle `ComparisonResult.SKIPPED` value
2 parents 3b1e6de + 41a22f0 commit 9978d3e

10 files changed

+127
-9
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default [
2222
),
2323
{
2424
files: ['**/*.ts', '**/*.tsx'],
25+
ignores: ['**/node_modules/**', '**/coverage/**', '**/dist/**', '**/src/gql/**'],
2526
plugins: {
2627
'simple-import-sort': simpleImportSort,
2728
},

src/components/BrowserSelector.stories.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ export const WithSingleBrowserEqual: Story = {
6363
},
6464
};
6565

66+
export const WithSingleBrowserSkipped: Story = {
67+
args: {
68+
selectedBrowser: browserChrome,
69+
browserResults: [
70+
{
71+
browser: browserChrome,
72+
result: ComparisonResult.Skipped,
73+
},
74+
],
75+
},
76+
};
77+
6678
export const WithSingleBrowserError: Story = {
6779
args: {
6880
selectedBrowser: browserChrome,

src/components/BrowserSelector.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ export const BrowserSelector = ({
7171
if (!aggregate) return null;
7272

7373
let icon = browserIcons[selectedBrowser.key];
74-
if (!isAccepted && aggregate !== ComparisonResult.Equal && browserResults.length >= 2) {
74+
if (
75+
!isAccepted &&
76+
![ComparisonResult.Equal, ComparisonResult.Skipped].includes(aggregate) &&
77+
browserResults.length >= 2
78+
) {
7579
icon = <StatusDotWrapper status={aggregate}>{icon}</StatusDotWrapper>;
7680
}
7781

@@ -84,7 +88,10 @@ export const BrowserSelector = ({
8488
active: selectedBrowser === browser,
8589
id: browser.id,
8690
onClick: () => onSelectBrowser(browser),
87-
right: !isAccepted && result !== ComparisonResult.Equal && <StatusDot status={result} />,
91+
right: !isAccepted &&
92+
![ComparisonResult.Equal, ComparisonResult.Skipped].includes(aggregate) && (
93+
<StatusDot status={result} />
94+
),
8895
icon: browserIcons[browser.key],
8996
title: browser.name,
9097
})

src/components/ModeSelector.stories.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ export const WithSingleViewportEqual: Story = {
5959
},
6060
};
6161

62+
export const WithSingleViewportSkipped: Story = {
63+
args: {
64+
selectedMode: viewport1200Px,
65+
modeResults: [
66+
{
67+
mode: viewport1200Px,
68+
result: ComparisonResult.Skipped,
69+
},
70+
],
71+
},
72+
};
73+
6274
export const WithSingleViewportError: Story = {
6375
args: {
6476
selectedMode: viewport1200Px,

src/components/ModeSelector.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ export const ModeSelector = ({
8282
if (!aggregate) return null;
8383

8484
let icon = <DiamondIcon />;
85-
if (!isAccepted && aggregate !== ComparisonResult.Equal && modeResults.length >= 2) {
85+
if (
86+
!isAccepted &&
87+
![ComparisonResult.Equal, ComparisonResult.Skipped].includes(aggregate) &&
88+
modeResults.length >= 2
89+
) {
8690
icon = <StatusDotWrapper status={aggregate}>{icon}</StatusDotWrapper>;
8791
}
8892

@@ -92,7 +96,10 @@ export const ModeSelector = ({
9296
.map(({ mode, result }) => ({
9397
id: mode.name,
9498
title: mode.name,
95-
right: !isAccepted && result !== ComparisonResult.Equal && <StatusDot status={result} />,
99+
right: !isAccepted &&
100+
![ComparisonResult.Equal, ComparisonResult.Skipped].includes(aggregate) && (
101+
<StatusDot status={result} />
102+
),
96103
onClick: () => onSelectMode(mode),
97104
active: selectedMode.name === mode.name,
98105
}))

src/components/StatusDot.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const Dot = styled.div<StatusDotProps & { overlay?: boolean }>(
2323
[TestStatus.Denied]: theme.color.positive,
2424
[TestStatus.Broken]: theme.color.negative,
2525
[TestStatus.Failed]: theme.color.negative,
26+
[ComparisonResult.Skipped]: 'transparent',
2627
[ComparisonResult.Equal]: theme.color.positive,
2728
[ComparisonResult.Fixed]: theme.color.positive,
2829
[ComparisonResult.Added]: theme.color.gold,

src/gql/graphql.ts

Lines changed: 38 additions & 3 deletions
Large diffs are not rendered by default.

src/gql/public-schema.graphql

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ type Test implements Node & Temporal {
490490
parameters: TestParameters!
491491

492492
"""
493-
The mode applied to this test. If this test was not using modes, the viewport is set as the mode name (e.g. "[viewport]px")
493+
The mode applied to this test. If this test was not using modes, the viewport is set as the mode name (e.g. "[viewport]px")
494494
"""
495495
mode: TestMode!
496496

@@ -559,6 +559,9 @@ enum ComparisonResult {
559559

560560
"""Either the head capture or the diff failed due to a system error."""
561561
SYSTEM_ERROR
562+
563+
"""We didn't capture the story as it was skipped"""
564+
SKIPPED
562565
}
563566

564567
type ViewportInfo {
@@ -657,6 +660,12 @@ enum CaptureErrorKind {
657660
"""The page took too long to load."""
658661
NAVIGATION_TIMEOUT
659662

663+
"""The Storybook render took too long to complete."""
664+
RENDER_TIMEOUT
665+
666+
"""The interaction test took too long to complete."""
667+
INTERACTION_TEST_TIMEOUT
668+
660669
"""The page does not contain (valid) JavaScript."""
661670
NO_JS
662671

@@ -1461,6 +1470,38 @@ type CaptureErrorScreenshotTimeout implements CaptureError {
14611470
screenshotTimeoutMs: Int!
14621471
}
14631472

1473+
type CaptureErrorTimeoutType implements CaptureError {
1474+
"""The ID of the capture error."""
1475+
id: ID!
1476+
1477+
"""The kind of capture error."""
1478+
kind: CaptureErrorKind!
1479+
}
1480+
1481+
type CaptureErrorRenderTimeout implements CaptureError {
1482+
"""The ID of the capture error."""
1483+
id: ID!
1484+
1485+
"""The kind of capture error."""
1486+
kind: CaptureErrorKind!
1487+
1488+
"""The maximum number of milliseconds allowed for a story to render."""
1489+
timeoutMs: Int!
1490+
}
1491+
1492+
type CaptureErrorInteractionTestTimeout implements CaptureError {
1493+
"""The ID of the capture error."""
1494+
id: ID!
1495+
1496+
"""The kind of capture error."""
1497+
kind: CaptureErrorKind!
1498+
1499+
"""
1500+
The maximum number of milliseconds allowed for interaction tests to run.
1501+
"""
1502+
timeoutMs: Int!
1503+
}
1504+
14641505
type Query {
14651506
account(id: ID!): Account
14661507
build(id: ID!): Build

src/utils/aggregateResult.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ComparisonResult } from '../gql/graphql';
22

33
export const resultOrder = [
44
undefined,
5+
ComparisonResult.Skipped,
56
ComparisonResult.Equal,
67
ComparisonResult.Fixed,
78
ComparisonResult.Added,

src/utils/useTests.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const useGlobalValue = (key: string) => {
1818
};
1919

2020
const hasChanges = ({ result }: StoryTestFieldsFragment['comparisons'][number]) =>
21-
result !== ComparisonResult.Equal && result !== ComparisonResult.Fixed;
21+
result &&
22+
![ComparisonResult.Equal, ComparisonResult.Fixed, ComparisonResult.Skipped].includes(result);
2223

2324
/**
2425
* Select the initial test based on the following criteria (in order of priority):

0 commit comments

Comments
 (0)