Skip to content

Commit

Permalink
fix(datagrid): fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Leotheluck authored and dpellier committed Dec 11, 2023
1 parent 653fc37 commit 83ccc56
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ describe('e2e:osds-datagrid', () => {
},
{
columns: JSON.stringify([{ field:'firstname', title:'First name' }, { field:'lastname', title:'Last name' }]),
rows: JSON.stringify([{ lastname:'Simpson', firstname:'Homer' }]),
rows: JSON.stringify([{ firstname:'Homer', lastname:'Simpson' }]),
},
{
columns: JSON.stringify([{ field:'firstname', isSortable: true, title:'First name' }, { field:'lastname', title:'Last name' }]),
rows: JSON.stringify([{ lastname:'Simpson', firstname:'Homer' }]),
rows: JSON.stringify([{ firstname:'Homer', lastname:'Simpson' }]),
},
{
columns: JSON.stringify([{ field:'firstname', title:'First name' }, { field:'lastname', title:'Last name' }]),
isSelectable: true,
rows: JSON.stringify([{ lastname:'Simpson', firstname:'Homer' }]),
rows: JSON.stringify([{ firstname:'Homer', lastname:'Simpson' }]),
},
{
columns: JSON.stringify([{ field:'firstname', title:'First name' }, { field:'lastname', title:'Last name' }, { title: "Button", field: "button", formatter: (cellValue, rowValue) => {
columns: JSON.stringify([{ field:'firstname', title:'First name' }, { field:'lastname', title:'Last name' }, { field: 'button', formatter: (): string => {
return `<osds-menu>
<osds-button slot="menu-title" color="primary" variant="stroked">Menu <osds-icon name='home' size='xs'></osds-icon></osds-button>
<osds-menu-group>
Expand All @@ -58,9 +58,10 @@ describe('e2e:osds-datagrid', () => {
<osds-button color="primary" size='sm' variant='ghost' flex><span slot="start">Action 2</span></osds-button>
</osds-menu-item>
<osds-divider color="text" separator="true"></osds-divider>
</osds-menu>`}}]),
</osds-menu>`;
}, title: 'Button' }]),
hasHideabledColumns: false,
rows: JSON.stringify([{ lastname:'Simpson', firstname:'Homer' }]),
rows: JSON.stringify([{ firstname:'Homer', lastname:'Simpson' }]),
},
].map((attributes) => createContent({ attributes })).join(' ');
await setup(content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('e2e:osds-datagrid', () => {
it('should render 1 rows & 3 columns', async() => {
await setup({ attributes: {
columns: JSON.stringify([{ field: 'firstname', title: 'First name' }, { field: 'lastname', title: 'Last name' }]),
rows: JSON.stringify([{ lastname: 'Simpson', firstname: 'Homer' }]),
rows: JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }]),
} });
const columns = await table?.findAll('.tabulator-col');
expect(columns).toHaveLength(3);
Expand All @@ -49,7 +49,7 @@ describe('e2e:osds-datagrid', () => {
await setup({ attributes: {
columns: JSON.stringify([{ field: 'firstname', title: 'First name' }, { field: 'lastname', title: 'Last name' }]),
isSelectable: true,
rows: JSON.stringify([{ lastname: 'Simpson', firstname: 'Homer' }]),
rows: JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }]),
} });

const selectableHeader = await table?.find('.tabulator-header input[type="checkbox"]');
Expand All @@ -61,7 +61,7 @@ describe('e2e:osds-datagrid', () => {
await setup({ attributes: {
columns: JSON.stringify([{ field: 'firstname', title: 'First name' }, { field: 'lastname', title: 'Last name' }]),
isSelectable: true,
rows: JSON.stringify([{ lastname: 'Simpson', firstname: 'Homer' }]),
rows: JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }]),
} });
const selectableRow = await table?.find('.tabulator-row input[type="checkbox"]');
await selectableRow?.click();
Expand All @@ -76,7 +76,7 @@ describe('e2e:osds-datagrid', () => {
await setup({ attributes: {
columns: JSON.stringify([{ field: 'firstname', title: 'First name' }, { field: 'lastname', title: 'Last name' }]),
isSelectable: true,
rows: JSON.stringify([{ lastname: 'Simpson', firstname: 'Homer' }, { lastname: 'Simpson', firstname: 'Marge' }]),
rows: JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }, { firstname: 'Marge', lastname: 'Simpson' }]),
} });

const selectableHeader = await table?.find('.tabulator-header input[type="checkbox"]');
Expand All @@ -94,7 +94,7 @@ describe('e2e:osds-datagrid', () => {
await setup({ attributes: {
columns: JSON.stringify([{ field: 'firstname', title: 'First name' }, { field: 'lastname', title: 'Last name' }]),
isSelectable: true,
rows: JSON.stringify([{ lastname: 'Simpson', firstname: 'Homer' }, { lastname: 'Simpson', firstname: 'Marge' }]),
rows: JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }, { firstname: 'Marge', lastname: 'Simpson' }]),
} });
const rowSelectionChangeSpy = await el.spyOnEvent('odsRowSelectionChange');

Expand All @@ -109,13 +109,13 @@ describe('e2e:osds-datagrid', () => {
}) ?? []);
expect(isAllSelect.includes(false)).toBe(true);
expect(await selectableHeader?.getProperty('indeterminate')).toBe(true);
expect(rowSelectionChangeSpy).toHaveReceivedEventDetail({ rows: [{ lastname: 'Simpson', firstname: 'Homer' }] });
expect(rowSelectionChangeSpy).toHaveReceivedEventDetail({ rows: [{ firstname: 'Homer', lastname: 'Simpson' }] });
});

it('should have sortable columns', async() => {
await setup({ attributes: {
columns: JSON.stringify([{ field: 'firstname', isSortable: true, title: 'First name' }, { field: 'lastname', title: 'Last name' }]),
rows: JSON.stringify([{ lastname: 'Simpson', firstname: 'Homer' }, { lastname: 'Simpson', firstname: 'Marge' }]),
rows: JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }, { firstname: 'Marge', lastname: 'Simpson' }]),
} });
const sortSpy = await el.spyOnEvent('odsSortChange');

Expand All @@ -138,7 +138,7 @@ describe('e2e:osds-datagrid', () => {
it('should have a column formatter', async() => {
await setup({ attributes: {
columns: [{ field: 'firstname', title: 'First name' }, { field: 'lastname', title: 'Last name' }],
rows: JSON.stringify([{ lastname: 'Simpson', firstname: 'Homer' }, { lastname: 'Simpson', firstname: 'Marge' }]),
rows: JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }, { firstname: 'Marge', lastname: 'Simpson' }]),
} });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await page.$eval('osds-datagrid', (elm: any) => {
Expand All @@ -156,7 +156,7 @@ describe('e2e:osds-datagrid', () => {
await setup({ attributes: {
columns: [{ field: 'firstname', title: 'First name' }, { field: 'lastname', title: 'Last name' }],
height,
rows: JSON.stringify([{ lastname: 'Simpson', firstname: 'Homer' }, { lastname: 'Simpson', firstname: 'Marge' }]),
rows: JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }, { firstname: 'Marge', lastname: 'Simpson' }]),
} });
const style = await table?.getComputedStyle();
expect(style?.height).toBe(height + 'px');
Expand All @@ -167,7 +167,7 @@ describe('e2e:osds-datagrid', () => {
await setup({ attributes: {
columns: [{ field: 'firstname', title: 'First name' }, { field: 'lastname', title: 'Last name' }],
rowHeight,
rows: JSON.stringify([{ lastname: 'Simpson', firstname: 'Homer' }, { lastname: 'Simpson', firstname: 'Marge' }]),
rows: JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }, { firstname: 'Marge', lastname: 'Simpson' }]),
} });
const rows = await table?.findAll('.tabulator-row');
const isAllRowHasHeight = await rows?.every(async(row) => {
Expand All @@ -188,7 +188,7 @@ describe('e2e:osds-datagrid', () => {
await setup({ attributes: {
columns: JSON.stringify([{ field: 'firstname', title: 'First name' }, { field: 'lastname', title: 'Last name' }]),
hasHideableColumns: false,
rows: JSON.stringify([{ lastname: 'Simpson', firstname: 'Homer' }]),
rows: JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }]),
} });
const columns = await table?.findAll('.tabulator-col');
expect(columns).toHaveLength(2);
Expand All @@ -200,9 +200,9 @@ describe('e2e:osds-datagrid', () => {
await setup({ attributes: {
columns: JSON.stringify([{ field: 'firstname', title: 'First name' }, { field: 'lastname', title: 'Last name' }]),
hasHideableColumns: false,
rows: JSON.stringify([{ lastname: 'Simpson', firstname: 'Homer' }]),
rows: JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }]),
} });
el.setProperty('rows', JSON.stringify([{ lastname: 'Simpson', firstname: 'Homer' }, { lastname: 'Simpson', firstname: 'Marge' }]));
el.setProperty('rows', JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }, { firstname: 'Marge', lastname: 'Simpson' }]));
await page.waitForChanges();

const rows = JSON.parse(await el.getProperty('rows'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('spec:osds-datagrid', () => {
odsUnitTestAttribute<OdsDatagridAttribute, 'rows'>({
defaultValue: DEFAULT_ATTRIBUTE.rows,
name: 'rows',
newValue: JSON.stringify([{ lastname: 'Homer', firstname: 'Simpson' }]),
newValue: JSON.stringify([{ firstname: 'Homer', lastname: 'Simpson' }]),
setup: (value) => setup({ attributes: { ['rows']: value } }),
value: '[]',
...config,
Expand Down

0 comments on commit 83ccc56

Please sign in to comment.