Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(content-explorer): add story and visual regression for theming #3889

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DEFAULT_HOSTNAME_API } from '../../constants';
import { DEFAULT_HOSTNAME_API } from '../../../constants';

const apiV2Path = `${DEFAULT_HOSTNAME_API}/2.0`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const mockSubFolder = {
const mockSubfolder = {
type: 'folder',
id: '73426618530',
etag: '3',
Expand Down Expand Up @@ -154,4 +154,4 @@ const mockSubFolder = {
},
};

export default mockSubFolder;
export default mockSubfolder;
642 changes: 642 additions & 0 deletions src/elements/common/__mocks__/mockTheme.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow

import ContentExplorer from '../ContentExplorer';
import mockTheme from '../../common/__mocks__/mockTheme';

export const basic = {};

Expand All @@ -25,6 +26,12 @@ export const withSidebar = {
},
};

export const withTheming = {
args: {
theme: mockTheme,
},
};

export default {
title: 'Elements/ContentExplorer',
component: ContentExplorer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { http, HttpResponse } from 'msw';
import { expect, userEvent, waitFor, within, screen } from '@storybook/test';

import ContentExplorer from '../../ContentExplorer';
import { mockEmptyRootFolder, mockRootFolder } from '../__mocks__/mockRootFolder';
import mockSubFolder from '../__mocks__/mockSubFolder';
import { mockEmptyRootFolder, mockRootFolder } from '../../../common/__mocks__/mockRootFolder';
import mockSubfolder from '../../../common/__mocks__/mockSubfolder';

import { DEFAULT_HOSTNAME_API } from '../../../../constants';

Expand Down Expand Up @@ -243,6 +243,16 @@ export const searchEmptyState = {
},
};

export const withTheming = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);

await waitFor(async () => {
expect(await canvas.getByText('Preview Test Folder')).toBeInTheDocument();
});
},
};

export default {
title: 'Elements/ContentExplorer/tests/ContentExplorer/visual',
component: ContentExplorer,
Expand All @@ -258,7 +268,7 @@ export default {
return HttpResponse.json(mockRootFolder);
}),
http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/73426618530`, () => {
return HttpResponse.json(mockSubFolder);
return HttpResponse.json(mockSubfolder);
}),
http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/74729718131`, () => {
return HttpResponse.json(mockEmptyRootFolder);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, userEvent, waitFor, within } from '@storybook/test';
import { http, HttpResponse } from 'msw';
import ContentPicker from '../../ContentPicker';
import { mockRootFolder } from '../../../content-explorer/stories/__mocks__/mockRootFolder';
import { mockRootFolder } from '../../../common/__mocks__/mockRootFolder';

import { DEFAULT_HOSTNAME_API } from '../../../../constants';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, userEvent, waitFor, within } from '@storybook/test';
import { Notification } from '@box/blueprint-web';
import { http, HttpResponse } from 'msw';

import { mockEventRequest, mockFileRequest, mockUserRequest } from '../../../__mocks__/mockRequests';
import { mockEventRequest, mockFileRequest, mockUserRequest } from '../../../common/__mocks__/mockRequests';
import { DEFAULT_HOSTNAME_API } from '../../../../constants';

import ContentPreview from '../../ContentPreview';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type StoryObj } from '@storybook/react';
import { http, HttpResponse } from 'msw';
import ContentSidebar from '../../ContentSidebar';
import BoxAISidebar from '../../BoxAISidebar';
import { mockFileRequest, mockUserRequest } from '../../../__mocks__/mockRequests';
import { mockFileRequest, mockUserRequest } from '../../../common/__mocks__/mockRequests';

const mockFeatures = {
'boxai.sidebar.enabled': true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
mockGlobalMetadataTemplates,
mockMetadataInstances,
} from '../__mocks__/MetadataSidebarRedesignedMocks';
import { mockUserRequest } from '../../../__mocks__/mockRequests';
import { mockUserRequest } from '../../../common/__mocks__/mockRequests';

const token = global.TOKEN;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
// @flow
import ContentUploader from '../ContentUploader';
import mockTheme from '../../common/__mocks__/mockTheme';

export const basic = {};

export const withTheming = {
args: {
theme: mockTheme,
},
};

export default {
title: 'Elements/ContentUploader',
component: ContentUploader,
Expand Down
Loading