Skip to content

Commit

Permalink
add 'Table with topForm' test
Browse files Browse the repository at this point in the history
  • Loading branch information
QProgS committed Feb 9, 2019
1 parent ac2e19b commit 8cb8727
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/scripts/be5/components/tables/Table.test.js
Expand Up @@ -63,6 +63,23 @@ test('Table', () => {
expect(component.toJSON()).toMatchSnapshot();
});

test('Table with topForm', () => {
const json = '{"data":{"attributes":{"category":"users","columns":[{"name":"User","title":"User"}],"layout":{"topForm":"TopFilter"},"length":10,"offset":0,"orderColumn":-1,"orderDir":"asc","page":"All records","parameters":{},"rows":[{"cells":[{"content":"test","options":{}}],"id":"test"},{"cells":[{"content":"Administrator","options":{}}],"id":"Administrator"},{"cells":[{"content":"test2","options":{}}],"id":"test2"}],"selectable":true,"title":"Пользователи","totalNumberOfRows":3},' +
'"links":{"self":"table/users/All records"},"type":"table"},"included":[' +
'{"attributes":{"bean":{"values":{"user_name":"","_search_presets_":"","_search_":true},"meta":{"/user_name":{"displayName":"Логин","canBeNull":true,"columnSize":"100"},"/_search_presets_":{"displayName":"_search_presets_","hidden":true,"readOnly":true,"canBeNull":true},"/_search_":{"displayName":"_search_","type":"Boolean","hidden":true,"readOnly":true,"canBeNull":true}},"order":["/user_name","/_search_presets_","/_search_"]},' +
'"entity":"users","layout":{"properties":"user_name"},"operation":"TopFilter","operationParams":{},"operationResult":{"status":"GENERATE"},"query":"All records","title":"Пользователи: "},' +
'"id":"topForm","links":{"self":"form/users/All records/TopFilter"},"type":"form"},' +
'{"attributes":[{"clientSide":false,"layout":{"properties":"user_name"},"name":"TopFilter","requiresConfirmation":false,"title":"","visibleWhen":"always"}],' +
'"type":"documentOperations"},' +
'{"attributes":{"operationParamsInfo":[]},"type":"filterInfo"}],"meta":{"_ts_":"1549734295598"}}';
const component = renderer.create(
<TestProvider>
<Table value={JSON.parse(json)} frontendParams={{documentName: 'test'}} />
</TestProvider>
);
expect(component.toJSON()).toMatchSnapshot();
});

test('Table on MAIN_DOCUMENT', () => {
const component = renderer.create(
<TestProvider>
Expand Down
118 changes: 118 additions & 0 deletions test/scripts/be5/components/tables/__snapshots__/Table.test.js.snap
Expand Up @@ -191,6 +191,124 @@ exports[`Table on MAIN_DOCUMENT 1`] = `
</div>
`;

exports[`Table with topForm 1`] = `
<div
className="table-component users_All-records"
>
<div
className="be5-form users_TopFilter form-inline-mini"
>
<form
className="form-inline"
onSubmit={[Function]}
>
<label
className="mr-sm-2 col-form-label-sm"
>
<strong>
Пользователи:
</strong>
</label>
<div
className="property form-group mr-sm-2"
>
<label
className="form-control-label mr-sm-2 col-form-label-sm"
htmlFor="user_namePropertyInput"
>
Логин
</label>
<input
className="property-input form-control form-control-sm"
id="user_namePropertyInput"
maxLength="100"
onBlur={[Function]}
onChange={[Function]}
onInput={[Function]}
onInvalid={[Function]}
pattern={undefined}
placeholder={undefined}
required={false}
size={undefined}
type="text"
value=""
/>
</div>
<div
className="property form-group mr-sm-2 display-none"
>
<label
className="form-control-label mr-sm-2 col-form-label-sm"
htmlFor="_search_presets_PropertyInput"
>
_search_presets_
</label>
<input
className="property-input form-control form-control-sm"
id="_search_presets_PropertyInput"
maxLength={undefined}
onBlur={[Function]}
onChange={[Function]}
onInput={[Function]}
onInvalid={[Function]}
pattern={undefined}
placeholder={undefined}
readOnly="readonly"
required={false}
size={undefined}
type="text"
value=""
/>
</div>
<div
className="property form-check mr-sm-2 display-none"
>
<input
checked={true}
className="property-input form-check-input"
disabled="disabled"
id="_search_PropertyInput"
onChange={[Function]}
required={false}
size={undefined}
type="checkbox"
/>
<label
className="form-check-label col-form-label-sm"
htmlFor="_search_PropertyInput"
>
_search_
</label>
</div>
<button
className="btn btn-primary btn-sm"
disabled={false}
onClick={[Function]}
title=""
type="submit"
>
Submit
</button>
</form>
</div>
<h1
className="table-component__title"
>
Пользователи
</h1>
<div
className="operationList"
/>
<div
className="table-wrap"
>
<div
className="row data-table-wrapper"
/>
</div>
</div>
`;

exports[`TableForm 1`] = `
<div
className="table-form"
Expand Down

0 comments on commit 8cb8727

Please sign in to comment.