Skip to content

Commit

Permalink
test(Playwright): add beforeMount theme and mobile provider (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
NasgulNexus authored Mar 12, 2024
1 parent 7f60298 commit 3ea1d38
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
26 changes: 10 additions & 16 deletions playwright/core/DynamicForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';

import {MobileProvider, ThemeProvider} from '@gravity-ui/uikit';

import noop from 'lodash/noop';
import {Form} from 'react-final-form';

Expand All @@ -13,19 +11,15 @@ export const DynamicForm = ({spec}: {spec: Spec}) => {
const generateRandomValue = () => 'value';

return (
<ThemeProvider>
<MobileProvider>
<Form initialValues={{}} onSubmit={noop}>
{() => (
<DynamicField
name="input"
spec={spec}
config={dynamicConfig}
generateRandomValue={generateRandomValue}
/>
)}
</Form>
</MobileProvider>
</ThemeProvider>
<Form initialValues={{}} onSubmit={noop}>
{() => (
<DynamicField
name="input"
spec={spec}
config={dynamicConfig}
generateRandomValue={generateRandomValue}
/>
)}
</Form>
);
};
10 changes: 1 addition & 9 deletions playwright/core/DynamicView.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import React from 'react';

import {MobileProvider, ThemeProvider} from '@gravity-ui/uikit';

import {DynamicView as DynamicViewBase} from '../../src/lib/core/components/View/DynamicView';
import {Spec} from '../../src/lib/core/types/specs';
import {FormValue} from '../../src/lib/core/types/value';
import {dynamicViewConfig} from '../../src/lib/kit/constants/config';

export const DynamicView = ({spec, value}: {spec: Spec; value: FormValue}) => {
return (
<ThemeProvider>
<MobileProvider>
<DynamicViewBase spec={spec} value={value} config={dynamicViewConfig} />
</MobileProvider>
</ThemeProvider>
);
return <DynamicViewBase spec={spec} value={value} config={dynamicViewConfig} />;
};
15 changes: 15 additions & 0 deletions playwright/playwright/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
import React from 'react';

import {beforeMount} from '@playwright/experimental-ct-react/hooks';
import {MobileProvider, ThemeProvider} from '@gravity-ui/uikit';

import './index.scss';

beforeMount(async ({App}) => {
return (
<ThemeProvider theme="light">
<MobileProvider>
<App />
</MobileProvider>
</ThemeProvider>
);
});

0 comments on commit 3ea1d38

Please sign in to comment.