Skip to content

Commit

Permalink
Update test to use Flow crud classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur- committed Dec 20, 2024
1 parent 3880eb2 commit 4fe3541
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 63 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,14 +1,18 @@
package com.vaadin.hilla.test.reactgrid;

import com.vaadin.hilla.BrowserCallable;
import com.vaadin.hilla.crud.CrudRepositoryService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.stereotype.Service;

import com.vaadin.flow.server.auth.AnonymousAllowed;
import com.vaadin.flow.spring.data.jpa.CrudRepositoryService;
import com.vaadin.hilla.BrowserCallable;

@BrowserCallable
@Service
@AnonymousAllowed
public class AppointmentService extends
CrudRepositoryService<Appointment, Long, AppointmentRepository> {
AppointmentService(AppointmentRepository repository) {
super(repository);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.vaadin.hilla.test.reactgrid;

import com.vaadin.hilla.BrowserCallable;
import com.vaadin.hilla.crud.CrudRepositoryService;

import com.vaadin.flow.server.auth.AnonymousAllowed;
import com.vaadin.flow.spring.data.jpa.CrudRepositoryService;
import com.vaadin.hilla.BrowserCallable;

@BrowserCallable
@AnonymousAllowed
public class CompanyService
extends CrudRepositoryService<Company, Long, CompanyRepository> {
CompanyService(CompanyRepository repository) {
super(repository);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.vaadin.hilla.test.reactgrid;

import com.vaadin.hilla.BrowserCallable;
import com.vaadin.hilla.crud.ListRepositoryService;

import com.vaadin.flow.server.auth.AnonymousAllowed;
import com.vaadin.flow.spring.data.jpa.ListRepositoryService;
import com.vaadin.hilla.BrowserCallable;

@BrowserCallable
@AnonymousAllowed
public class PersonListOnlyService
extends ListRepositoryService<Person, Long, PersonRepository> {

PersonListOnlyService(PersonRepository repository) {
super(repository);
}

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.vaadin.hilla.test.reactgrid;

import com.vaadin.hilla.BrowserCallable;
import com.vaadin.hilla.crud.CrudRepositoryService;

import com.vaadin.flow.server.auth.AnonymousAllowed;
import com.vaadin.flow.spring.data.jpa.CrudRepositoryService;
import com.vaadin.hilla.BrowserCallable;

@BrowserCallable
@AnonymousAllowed
public class PersonService
extends CrudRepositoryService<Person, Long, PersonRepository> {

PersonService(PersonRepository repository) {
super(repository);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.vaadin.hilla.test.reactgrid.entityreferences;

import com.vaadin.hilla.BrowserCallable;
import com.vaadin.hilla.crud.ListRepositoryService;

import com.vaadin.flow.server.auth.AnonymousAllowed;
import com.vaadin.flow.spring.data.jpa.ListRepositoryService;
import com.vaadin.hilla.BrowserCallable;

@BrowserCallable
@AnonymousAllowed
public class EmployeeService
extends ListRepositoryService<Employee, Long, EmployeeRepository> {

public EmployeeService(EmployeeRepository repository) {
super(repository);
}

}
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import java.util.Locale;
import java.util.function.Consumer;

import com.vaadin.hilla.crud.filter.PropertyStringFilter.Matcher;
import org.junit.Test;

import com.vaadin.flow.component.datepicker.testbench.DatePickerElement;
import com.vaadin.flow.component.timepicker.testbench.TimePickerElement;
import com.vaadin.flow.component.select.testbench.SelectElement;
import com.vaadin.flow.component.textfield.testbench.NumberFieldElement;
import com.vaadin.flow.component.textfield.testbench.TextFieldElement;
import com.vaadin.flow.component.timepicker.testbench.TimePickerElement;
import com.vaadin.flow.spring.data.filter.PropertyStringFilter.Matcher;
import com.vaadin.testbench.TestBench;
import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elementsbase.Element;
Expand Down

0 comments on commit 4fe3541

Please sign in to comment.