Skip to content

Commit

Permalink
Add basic link field test for grid list component
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Nov 14, 2023
1 parent b40e88a commit 3173f84
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
20 changes: 14 additions & 6 deletions client/src/components/Grid/GridList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,25 @@ const testGrid = {
title: "id",
type: "text",
},
{
key: "link",
title: "link",
type: "link",
},
],
filtering: new Filtering({}, undefined, false, false),
getData: () => {
const data = [
{
id: "test-1",
id: "id-1",
link: "link-1",
},
{
id: "test-2",
id: "id-2",
link: "link-2",
},
];
const totalMatches = 1000;
return [data, totalMatches];
return [data, data.length];
},
plural: "Tests",
sortBy: "update_time",
Expand Down Expand Up @@ -63,7 +69,9 @@ describe("GridList", () => {
const findAction = wrapper.find("[data-description='grid action test']");
expect(findAction.text()).toBe("test");
await wrapper.vm.$nextTick();
expect(wrapper.find("[data-description='grid text 0-0']").text()).toBe("test-1");
expect(wrapper.find("[data-description='grid text 1-0']").text()).toBe("test-2");
expect(wrapper.find("[data-description='grid cell 0-0']").text()).toBe("id-1");
expect(wrapper.find("[data-description='grid cell 1-0']").text()).toBe("id-2");
expect(wrapper.find("[data-description='grid cell 0-1'] > a").text()).toBe("link-1");
expect(wrapper.find("[data-description='grid cell 1-1'] > a").text()).toBe("link-2");
});
});
8 changes: 3 additions & 5 deletions client/src/components/Grid/GridList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,14 @@ watch(operationMessage, () => {
v-for="(fieldEntry, fieldIndex) in config.fields"
:key="fieldIndex"
class="px-2 py-3"
:style="{ width: fieldEntry.width }">
:style="{ width: fieldEntry.width }"
:data-description="`grid cell ${rowIndex}-${fieldIndex}`">
<GridOperations
v-if="fieldEntry.type == 'operations'"
:operations="fieldEntry.operations"
:row-data="rowData"
@execute="onOperation($event, rowData)" />
<GridText
v-else-if="fieldEntry.type == 'text'"
:data-description="`grid text ${rowIndex}-${fieldIndex}`"
:text="rowData[fieldEntry.key]" />
<GridText v-else-if="fieldEntry.type == 'text'" :text="rowData[fieldEntry.key]" />
<GridLink
v-else-if="fieldEntry.type == 'link'"
:text="rowData[fieldEntry.key]"
Expand Down

0 comments on commit 3173f84

Please sign in to comment.