Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur- committed Dec 19, 2024
1 parent d0f9aa0 commit 2f35e8c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useDataProvider } from '@vaadin/hilla-react-crud';
import type Person from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/Person.js';
import { PersonService } from 'Frontend/generated/endpoints.js';
import { Button } from '@vaadin/react-components/Button.js';
import { Grid } from '@vaadin/react-components/Grid';
import { GridSortColumn } from '@vaadin/react-components/GridSortColumn';
import { Button } from '@vaadin/react-components/Button.js';
import { TextField } from '@vaadin/react-components/TextField.js';
import PropertyStringFilter from 'Frontend/generated/com/vaadin/hilla/crud/filter/PropertyStringFilter';
import { useState } from 'react';
import Matcher from 'Frontend/generated/com/vaadin/hilla/crud/filter/PropertyStringFilter/Matcher';
import type PropertyStringFilter from 'Frontend/generated/com/vaadin/flow/spring/data/filter/PropertyStringFilter';
import Matcher from 'Frontend/generated/com/vaadin/flow/spring/data/filter/PropertyStringFilter/Matcher';
import Gender from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/Person/Gender';
import type Person from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/Person.js';
import { PersonService } from 'Frontend/generated/endpoints.js';

type GridBodyReactRendererProps<TItem> = {
item: TItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
import { AutoGrid, type HeaderFilterRendererProps } from '@vaadin/hilla-react-crud';
import { GridColumn } from '@vaadin/react-components/GridColumn';
import { TextField } from '@vaadin/react-components/TextField.js';
import { AutoGrid, HeaderFilterRendererProps } from '@vaadin/hilla-react-crud';
import type FilterUnion from 'Frontend/generated/com/vaadin/flow/spring/data/filter/FilterUnion';
import type OrFilter from 'Frontend/generated/com/vaadin/flow/spring/data/filter/OrFilter';
import type Person from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/Person';
import PersonModel from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/PersonModel.js';
import Person from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/Person';
import { PersonService } from 'Frontend/generated/endpoints.js';
import { GridColumn } from '@vaadin/react-components/GridColumn';
import type FilterUnion from 'Frontend/generated/com/vaadin/hilla/crud/filter/FilterUnion.js';
import type OrFilter from 'Frontend/generated/com/vaadin/hilla/crud/filter/OrFilter.js';

const HeaderFilterRenderer = ({ setFilter }: HeaderFilterRendererProps) => {
return (
<TextField
id="filter"
style={{ width: '20em' }}
placeholder="Search for first or last name"
onValueChanged={({ detail: { value } }) => {
const firstNameFilter = {
'@type': 'propertyString',
propertyId: 'firstName',
matcher: 'CONTAINS',
filterValue: value,
};
const lastNameFilter = {
'@type': 'propertyString',
propertyId: 'lastName',
matcher: 'CONTAINS',
filterValue: value,
};
const HeaderFilterRenderer = ({ setFilter }: HeaderFilterRendererProps) => (
<TextField
id="filter"
style={{ width: '20em' }}
placeholder="Search for first or last name"
onValueChanged={({ detail: { value } }) => {
const firstNameFilter = {
'@type': 'propertyString',
propertyId: 'firstName',
matcher: 'CONTAINS',
filterValue: value,
};
const lastNameFilter = {
'@type': 'propertyString',
propertyId: 'lastName',
matcher: 'CONTAINS',
filterValue: value,
};

const filter: OrFilter = {
'@type': 'or',
children: [firstNameFilter, lastNameFilter],
};
const filter: OrFilter = {
'@type': 'or',
children: [firstNameFilter, lastNameFilter],
};

setFilter(filter as FilterUnion);
}}
></TextField>
);
};
setFilter(filter as FilterUnion);
}}
></TextField>
);

const FullNameRenderer = ({ item }: { item: Person }): JSX.Element => (
<span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TextField } from '@vaadin/react-components/TextField.js';
import { AutoGrid } from '@vaadin/hilla-react-crud';
import { TextField } from '@vaadin/react-components/TextField.js';
import { useState } from 'react';
import type FilterUnion from 'Frontend/generated/com/vaadin/hilla/crud/filter/FilterUnion.js';
import type FilterUnion from 'Frontend/generated/com/vaadin/flow/spring/data/filter/FilterUnion';
import PersonModel from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/PersonModel.js';
import { PersonService } from 'Frontend/generated/endpoints.js';

Expand All @@ -27,7 +27,7 @@ export function ReadOnlyGridOrFilter(): JSX.Element {
matcher: 'CONTAINS',
filterValue: value,
};
setFilter({ '@type': 'or', children: [firstNameFilter, lasttNameFilter]});
setFilter({ '@type': 'or', children: [firstNameFilter, lasttNameFilter] });
}}
></TextField>
<AutoGrid service={PersonService} model={PersonModel} experimentalFilter={filter} noHeaderFilters />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { TextField } from '@vaadin/react-components/TextField.js';
import { AutoGrid } from '@vaadin/hilla-react-crud';
import { TextField } from '@vaadin/react-components/TextField.js';
import { useState } from 'react';
import type FilterUnion from 'Frontend/generated/com/vaadin/hilla/crud/filter/FilterUnion.js';
import Matcher from 'Frontend/generated/com/vaadin/hilla/crud/filter/PropertyStringFilter/Matcher.js';
import type FilterUnion from 'Frontend/generated/com/vaadin/flow/spring/data/filter/FilterUnion';
import Matcher from 'Frontend/generated/com/vaadin/flow/spring/data/filter/PropertyStringFilter/Matcher';
import PersonModel from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/PersonModel.js';
import { PersonService } from 'Frontend/generated/endpoints.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.vaadin.hilla.test.reactgrid;

import com.vaadin.flow.component.button.testbench.ButtonElement;
import com.vaadin.flow.component.textfield.testbench.TextFieldElement;
import com.vaadin.testbench.TestBenchElement;
import org.junit.Assert;
import org.junit.Test;

import com.vaadin.flow.component.button.testbench.ButtonElement;
import com.vaadin.flow.component.textfield.testbench.TextFieldElement;

public class GridUseDataProviderHookIT extends AbstractGridTest {

protected String getTestPath() {
Expand Down

0 comments on commit 2f35e8c

Please sign in to comment.