Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-5557 - Refactoring Admin Tables Data Filter #2954

Merged
merged 68 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
d32ef7e
initial implementation of datafilter
muratmerdoglu-dp Nov 1, 2023
8a872b9
Merge branch 'BC-3844-vue3-webpack' into vue3-data-filter
muratmerdoglu-dp Dec 4, 2023
e318e58
move folders
muratmerdoglu-dp Dec 5, 2023
5359761
create filter dialog component
muratmerdoglu-dp Dec 5, 2023
30b6787
create components and basic functionilities
muratmerdoglu-dp Dec 5, 2023
b94d717
BC-5557: add date picker in timebetween component
muratmerdoglu-dp Dec 5, 2023
bfea3a2
chore: remove console.log()
muratmerdoglu-dp Dec 5, 2023
b88dc93
BC-5557: add composable file for filtering
muratmerdoglu-dp Dec 6, 2023
615df4c
BC-5557: move logics into the composable
muratmerdoglu-dp Dec 6, 2023
87cfbb2
BC-5557: add feature on chips to open the dialog
muratmerdoglu-dp Dec 6, 2023
893bced
BC-5557: create filterApi composable
muratmerdoglu-dp Dec 6, 2023
93e47ab
BC-5557: create and move composables
muratmerdoglu-dp Dec 7, 2023
77e5fdf
chore: fix imports
muratmerdoglu-dp Dec 7, 2023
47f0282
BC-5557: implement saving local storage
muratmerdoglu-dp Dec 7, 2023
08b3dd6
BC-5557: create update method in student overview
muratmerdoglu-dp Dec 8, 2023
088d9d3
BC-5557: create ListSelection component
muratmerdoglu-dp Dec 8, 2023
fb09441
BC-5557: delete Classes and Registration comps
muratmerdoglu-dp Dec 8, 2023
edacf31
BC-5557: add default dates
muratmerdoglu-dp Dec 11, 2023
c9e89a1
BC-5557: set filterQuery after mounting component
muratmerdoglu-dp Dec 11, 2023
16285a1
BC-5557: add selected filters to dialog options
muratmerdoglu-dp Dec 11, 2023
21b2585
chore: clean up variable names
muratmerdoglu-dp Dec 11, 2023
71b2d15
chore: add type to prop
muratmerdoglu-dp Dec 12, 2023
0b0d746
chore: fix compaling error
muratmerdoglu-dp Dec 12, 2023
e296033
BC-5557: add functionality to teachers page
muratmerdoglu-dp Dec 12, 2023
f212671
BC-5557: add features both students and teachers
muratmerdoglu-dp Dec 12, 2023
3cf5590
chore: delete feature folder
muratmerdoglu-dp Dec 13, 2023
d9009e9
chore: remove unnecessary comments
muratmerdoglu-dp Dec 13, 2023
7c48717
Merge branch 'BC-3844-vue3-webpack' into BC-5557-vue3-data-filter
muratmerdoglu-dp Dec 13, 2023
a475b71
BC-5557: install pinia
muratmerdoglu-dp Dec 13, 2023
ee2d328
delete filterApi composable file
muratmerdoglu-dp Dec 14, 2023
60531a2
create setUserType method
muratmerdoglu-dp Dec 14, 2023
e29ba1e
BC-5557: refactor storage composable with vueUse library
muratmerdoglu-dp Dec 15, 2023
6b2d352
BC-5557: create pinia store for localStorage composable
muratmerdoglu-dp Dec 15, 2023
335bb6d
chore: fix some minor localstorage namings
muratmerdoglu-dp Dec 18, 2023
70e2d8b
BC-5557: create a chip title prepare function
muratmerdoglu-dp Dec 18, 2023
f86ea16
BC-5557: fix types and add i18n keys
muratmerdoglu-dp Dec 18, 2023
62598fa
BC-5557: create a barrel file for types and enums
muratmerdoglu-dp Dec 18, 2023
7cddb1f
BC-5557: change component naming
muratmerdoglu-dp Dec 19, 2023
69c5913
chore: create a test file for FilterActionButtons component
muratmerdoglu-dp Dec 19, 2023
272f1f3
chore: fix loading actual menu items on refresh
muratmerdoglu-dp Dec 19, 2023
c231fe4
BC-5557: remove vue-filter-ui dependency
muratmerdoglu-dp Dec 20, 2023
f5d1e3e
Merge branch 'BC-3844-vue3-webpack' into BC-5557-vue3-data-filter
muratmerdoglu-dp Dec 20, 2023
8343fbd
BC-5557: add unit tests for filterActionButtons component
muratmerdoglu-dp Dec 20, 2023
0752c67
BC-5557: add unit tests for FilterChips component
muratmerdoglu-dp Dec 20, 2023
b622d2c
BC-5557: add unit tests for ListSelection component
muratmerdoglu-dp Dec 20, 2023
c467643
BC-5557: use i18n keys in DateBetween component
muratmerdoglu-dp Dec 21, 2023
a5241a1
chore: create unit test for localStorage composable
muratmerdoglu-dp Dec 22, 2023
6934e9a
chore: fix type
muratmerdoglu-dp Jan 8, 2024
10cc216
chore: remove required props in components
muratmerdoglu-dp Jan 8, 2024
d57cb73
BC-5557: implement unit tests for the FilterDialog component
muratmerdoglu-dp Jan 8, 2024
fe822eb
BC:5557: implement unit tests for DateBetween component
muratmerdoglu-dp Jan 8, 2024
af81fc0
BC-5557: implement unit tests for localStorage composable file
muratmerdoglu-dp Jan 8, 2024
157970a
Merge branch 'BC-3844-vue3-webpack' into BC-5557-vue3-data-filter
muratmerdoglu-dp Jan 8, 2024
ff803b0
BC:5557: implement unit tests for filter.composable file
muratmerdoglu-dp Jan 9, 2024
98ba1cb
BC-5557: move classlist logic to main component
muratmerdoglu-dp Jan 10, 2024
99c9c37
BC-5557: implement unit tests for main component
muratmerdoglu-dp Jan 10, 2024
2b12bc2
BC-5557: delete old filter components and files
muratmerdoglu-dp Jan 11, 2024
ad0ae7a
Merge branch 'BC-3844-vue3-webpack' into BC-5557-vue3-data-filter
muratmerdoglu-dp Jan 11, 2024
cf29583
BC-5557: remove pinia dependency
muratmerdoglu-dp Jan 12, 2024
8e70fb4
chore: correction of naming in DataFilter unit tests
muratmerdoglu-dp Jan 12, 2024
3959e79
BC-5557: fix empty chip title
muratmerdoglu-dp Jan 12, 2024
4105edb
chore: add more test for Listselection component
muratmerdoglu-dp Jan 12, 2024
9d320f9
BC-5557: add unit test cases if date is undefined in dateselection co…
muratmerdoglu-dp Jan 12, 2024
4d46762
chore: remove unnecessary awaited nexttick()
muratmerdoglu-dp Jan 12, 2024
83a10e6
chore: remove shared composable
muratmerdoglu-dp Jan 15, 2024
713ed94
BC-5557: improve test cases
muratmerdoglu-dp Jan 15, 2024
698ecd6
Merge branch 'BC-3844-vue3-webpack' into BC-5557-vue3-data-filter
muratmerdoglu-dp Jan 15, 2024
8a834e9
chore: remove some leftover comment lines
muratmerdoglu-dp Jan 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 1 addition & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"vue": "^3.3.4",
"vue-dndrop": "^1.3.1",
"vue-dompurify-html": "^4.1.4",
"vue-filter-ui": "^0.8.0",
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.4",
"vue3-mq": "^3.1.3",
Expand Down
65 changes: 0 additions & 65 deletions src/components/organisms/DataFilter/DataFilter.md

This file was deleted.

125 changes: 125 additions & 0 deletions src/components/organisms/DataFilter/DataFilter.unit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { ComponentMountingOptions, mount } from "@vue/test-utils";
import {
createTestingI18n,
createTestingVuetify,
} from "@@/tests/test-utils/setup";
import DataFilter from "./DataFilter.vue";
import { useDataTableFilter } from "./composables/filter.composable";
import { computed, ref } from "vue";

jest.mock("./composables/filter.composable");

const mockedUseBoardApi = jest.mocked(useDataTableFilter);
describe("@components/DataFilter/DataFilter.vue", () => {
const updateFilterMock = jest.fn();
const removeFilterMock = jest.fn();
const removeChipFilterMock = jest.fn();
const defaultFilterMenuItems = [
{ label: "Registration", value: "consentStatus" },
{ label: "Class(es)", value: "classes" },
{ label: "Creation date", value: "createdAt" },
{ label: "Last migrated on", value: "lastLoginSystemChange" },
{ label: "Obsolete since", value: "outdatedSince" },
];

const setup = (options: ComponentMountingOptions<typeof DataFilter> = {}) => {
mockedUseBoardApi.mockReturnValue({
defaultFilterMenuItems,
filterChipTitles: ref([{ item: "classes", title: "Class(es) = 1A" }]),
filterMenuItems: ref([]),
filterQuery: ref({}),
isDateFiltering: computed(() => false),
isSelectFiltering: computed(() => false),
registrationOptions: {
student: [],
teacher: [],
},
selectedFilterType: ref("classes"),
userType: "",
removeChipFilter: removeChipFilterMock,
removeFilter: removeFilterMock,
updateFilter: updateFilterMock,
});
return mount(DataFilter, {
global: {
plugins: [createTestingVuetify(), createTestingI18n()],
},
...options,
});
};

describe("should render the component", () => {
afterEach(() => {
jest.clearAllMocks();
});

it("should render the component", () => {
const wrapper = setup({ props: { filterFor: "student" } });
expect(wrapper.exists()).toBe(true);
expect(mockedUseBoardApi).toHaveBeenCalledWith("student");
});

it("should emit 'update:filter' when chip components be closed", async () => {
const wrapper = setup();
const filterChipsComponent = wrapper.getComponent({
name: "FilterChips",
});
filterChipsComponent.vm.$emit("remove:filter");

expect(wrapper.emitted()).toHaveProperty("update:filter");
});

it("should emit 'update:filter' when chip components be closed", async () => {
const wrapper = setup({ props: { filterFor: "student" } });
const filterChipsComponent = wrapper.getComponent({
name: "FilterChips",
});
await filterChipsComponent.vm.$emit("remove:filter");

expect(wrapper.emitted()).toHaveProperty("update:filter");
expect(removeChipFilterMock).toHaveBeenCalled();
});

describe("filter dialog", () => {
it("should set the 'dialogOpen' false when 'close' event be emitted", async () => {
const wrapper = setup({ props: { filterFor: "student" } });

const filterDialogComponent = wrapper.getComponent({
name: "FilterDialog",
});
expect(filterDialogComponent.props("isOpen")).toBe(false);
wrapper.vm.dialogOpen = true;
await wrapper.vm.$nextTick();

expect(filterDialogComponent.props("isOpen")).toBe(true);

await filterDialogComponent.vm.$emit("dialog-closed");

expect(filterDialogComponent.props("isOpen")).toBe(false);
expect(wrapper.vm.dialogOpen).toBe(false);
});

it("should call updateFilter method", async () => {
const wrapper = setup({ props: { filterFor: "teacher" } });
wrapper.vm.dialogOpen = true;

const filterDialogComponent = wrapper.getComponent({
name: "FilterDialog",
});

await filterDialogComponent.vm.$emit("remove:filter");
expect(removeFilterMock).toHaveBeenCalled();
});
});

it("should set filter title", () => {
const wrapper = setup();

const filterTitleElement = wrapper.find('[data-testid="filter-title"]');

expect(filterTitleElement.text()).toContain(
"components.organisms.DataFilter.add"
);
});
});
});
Loading
Loading