Skip to content

Commit

Permalink
Dyn forms playwright tests (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
NasgulNexus authored Jan 10, 2024
1 parent cd31d6f commit 908b168
Show file tree
Hide file tree
Showing 632 changed files with 5,374 additions and 2 deletions.
10 changes: 10 additions & 0 deletions playwright/core/DynamicView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

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 <DynamicViewBase spec={spec} value={value} config={dynamicViewConfig} />;
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions src/lib/kit/components/Card/__tests__/Card.visual.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React from 'react';

import {ACCORDEON_CARD, SECTION_CARD, VALUE} from './helpers';

import {test} from '~playwright/core';
import {DynamicForm} from '~playwright/core/DynamicForm';
import {DynamicView} from '~playwright/core/DynamicView';

test.describe('Card', () => {
test.describe('Accordeon Card', () => {
test('array spec', async ({mount, expectScreenshot}) => {
await mount(<DynamicForm spec={ACCORDEON_CARD.arraySpec} />);

await expectScreenshot();
});

test('object spec', async ({mount, expectScreenshot}) => {
await mount(<DynamicForm spec={ACCORDEON_CARD.objectSpec} />);

await expectScreenshot();
});
});

test.describe('Section Card', () => {
test('array spec', async ({mount, expectScreenshot}) => {
await mount(<DynamicForm spec={SECTION_CARD.arraySpec} />);

await expectScreenshot();
});

test('object spec', async ({mount, expectScreenshot}) => {
await mount(<DynamicForm spec={SECTION_CARD.objectSpec} />);

await expectScreenshot();
});
});
});

test.describe('Card view', () => {
test.describe('Accordeon Card', () => {
test('array spec', async ({mount, expectScreenshot}) => {
await mount(<DynamicView spec={ACCORDEON_CARD.arraySpec} value={VALUE.array} />);

await expectScreenshot();
});

test('object spec', async ({mount, expectScreenshot}) => {
await mount(<DynamicView spec={ACCORDEON_CARD.objectSpec} value={VALUE.object} />);

await expectScreenshot();
});
});

test.describe('Section Card', () => {
test('array spec', async ({mount, expectScreenshot}) => {
await mount(<DynamicView spec={SECTION_CARD.arraySpec} value={VALUE.array} />);

await expectScreenshot();
});

test('object spec', async ({mount, expectScreenshot}) => {
await mount(<DynamicView spec={SECTION_CARD.objectSpec} value={VALUE.object} />);

await expectScreenshot();
});
});
});
134 changes: 134 additions & 0 deletions src/lib/kit/components/Card/__tests__/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import {ArraySpec, FormValue, ObjectSpec, SpecTypes} from '../../../../core';

export const ACCORDEON_CARD: Record<string, ArraySpec | ObjectSpec> = {
arraySpec: {
defaultValue: ['value'],
type: SpecTypes.Array,
items: {
type: SpecTypes.String,
viewSpec: {
type: 'base',
layout: 'row',
layoutTitle: 'Element',
},
},
viewSpec: {
type: 'base',
layout: 'card_accordeon',
layoutTitle: 'Accordeon Card',
layoutOpen: true,
itemLabel: 'Add element',
},
},
objectSpec: {
defaultValue: {
name: 'value',
age: 10,
license: false,
},
type: SpecTypes.Object,
properties: {
name: {
type: SpecTypes.String,
viewSpec: {
type: 'base',
layout: 'row',
layoutTitle: 'Name',
},
},
age: {
type: SpecTypes.Number,
viewSpec: {
type: 'base',
layout: 'row',
layoutTitle: 'Age',
},
},
license: {
type: SpecTypes.Boolean,
viewSpec: {
type: 'base',
layout: 'row',
layoutTitle: 'License',
},
},
},
viewSpec: {
type: 'base',
layout: 'card_accordeon',
layoutTitle: 'Candidate',
layoutOpen: true,
},
},
};

export const SECTION_CARD: Record<string, ArraySpec | ObjectSpec> = {
arraySpec: {
defaultValue: ['value'],
type: SpecTypes.Array,
items: {
type: SpecTypes.String,
viewSpec: {
type: 'base',
layout: 'row',
layoutTitle: 'Element',
},
},
viewSpec: {
type: 'base',
layout: 'card_section',
layoutTitle: 'Accordeon Card',
layoutOpen: true,
itemLabel: 'Add element',
},
},
objectSpec: {
defaultValue: {
name: 'value',
age: 10,
license: false,
},
type: SpecTypes.Object,
properties: {
name: {
type: SpecTypes.String,
viewSpec: {
type: 'base',
layout: 'row',
layoutTitle: 'Name',
},
},
age: {
type: SpecTypes.Number,
viewSpec: {
type: 'base',
layout: 'row',
layoutTitle: 'Age',
},
},
license: {
type: SpecTypes.Boolean,
viewSpec: {
type: 'base',
layout: 'row',
layoutTitle: 'License',
},
},
},
viewSpec: {
type: 'base',
layout: 'card_section',
layoutTitle: 'Candidate',
layoutOpen: true,
},
},
};

export const VALUE: Record<string, FormValue> = {
array: ['value', 'value'],
object: {
name: 'name',
age: 21,
license: true,
},
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';

import {ARRAY_BASE, DynamicForm} from './helpers';
import {ARRAY_BASE, DynamicForm, VALUE} from './helpers';

import {test} from '~playwright/core';
import {DynamicView} from '~playwright/core/DynamicView';

test.describe('Array Base', () => {
test('default', async ({mount, expectScreenshot}) => {
Expand Down Expand Up @@ -57,3 +58,11 @@ test.describe('Array Base', () => {
await expectScreenshot();
});
});

test.describe('Array Base view', () => {
test('default', async ({mount, expectScreenshot}) => {
await mount(<DynamicView spec={ARRAY_BASE.default} value={VALUE.array} />);

await expectScreenshot();
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import {ArraySpec, Spec, SpecTypes} from '../../../../../core';
import {ArraySpec, FormValue, Spec, SpecTypes} from '../../../../../core';

import {DynamicForm as BaseDynamicForm} from '~playwright/core/DynamicForm';

Expand Down Expand Up @@ -163,6 +163,10 @@ export const ARRAY_BASE: Record<string, ArraySpec> = {
},
};

export const VALUE: Record<string, FormValue> = {
array: ['value', 'value'],
};

export const DynamicForm = ({spec}: {spec: Spec}) => {
return (
<div style={{width: 600}}>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';

import {CARD_ONEOF, VALUE} from './helpers';

import {test} from '~playwright/core';
import {DynamicForm} from '~playwright/core/DynamicForm';
import {DynamicView} from '~playwright/core/DynamicView';

test.describe('Card OneOf', () => {
test('default', async ({mount, expectScreenshot}) => {
await mount(<DynamicForm spec={CARD_ONEOF.default} />);

await expectScreenshot();
});

test('default value object', async ({mount, expectScreenshot}) => {
await mount(<DynamicForm spec={CARD_ONEOF.defaultValueObject} />);

await expectScreenshot();
});

test('default value string', async ({mount, expectScreenshot}) => {
await mount(<DynamicForm spec={CARD_ONEOF.defaultValueString} />);

await expectScreenshot();
});

test('required', async ({mount, expectScreenshot}) => {
await mount(<DynamicForm spec={CARD_ONEOF.required} />);

await expectScreenshot();
});

test('description', async ({mount, expectScreenshot}) => {
await mount(<DynamicForm spec={CARD_ONEOF.desription} />);

await expectScreenshot();
});
});

test.describe('Card OneOf view', () => {
test('object', async ({mount, expectScreenshot}) => {
await mount(<DynamicView spec={CARD_ONEOF.default} value={VALUE.object} />);

await expectScreenshot();
});

test('string', async ({mount, expectScreenshot}) => {
await mount(<DynamicView spec={CARD_ONEOF.default} value={VALUE.string} />);

await expectScreenshot();
});
});
Loading

0 comments on commit 908b168

Please sign in to comment.