Skip to content

Commit 37898b9

Browse files
committed
feat: radio buttons e2e test
1 parent a761e5d commit 37898b9

File tree

1 file changed

+65
-4
lines changed

1 file changed

+65
-4
lines changed

packages/ketchup/src/components/kup-input-panel/kup-input-panel.e2e.ts

+65-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('kup-input-panel', () => {
6666
expect(label).toEqualText(data.columns[i].title);
6767

6868
const input = await textField.find('input');
69-
expect(label).not.toBeNull();
69+
expect(input).not.toBeNull();
7070
const value = await input.getProperty('value');
7171
expect(value).toBe('');
7272

@@ -274,9 +274,7 @@ describe('kup-input-panel', () => {
274274
it('renders checkbox', async () => {
275275
const page = await newE2EPage();
276276

277-
await page.setContent(
278-
'<kup-input-panel></kup-input-panel> <div kup-dynamic-position></div>'
279-
);
277+
await page.setContent('<kup-input-panel></kup-input-panel>');
280278
const inputPanel = await page.find('kup-input-panel');
281279
const data = {
282280
columns: [
@@ -323,4 +321,67 @@ describe('kup-input-panel', () => {
323321
const value = await input.getProperty('value');
324322
expect(value).toBe('off');
325323
});
324+
325+
it('renders radio buttons', async () => {
326+
const page = await newE2EPage();
327+
328+
await page.setContent('<kup-input-panel></kup-input-panel>');
329+
const inputPanel = await page.find('kup-input-panel');
330+
const data = {
331+
columns: [
332+
{
333+
name: 'RAD',
334+
title: 'Radio Buttons',
335+
visible: true,
336+
},
337+
],
338+
rows: [
339+
{
340+
cells: {
341+
RAD: {
342+
value: '1',
343+
options: ['1', '2', '3', '4'],
344+
editable: true,
345+
shape: 'RAD',
346+
},
347+
},
348+
},
349+
],
350+
};
351+
352+
inputPanel.setProperty('data', data);
353+
354+
await page.waitForChanges();
355+
356+
const inputPanelContent = await page.find(
357+
'kup-input-panel >>> form.input-panel'
358+
);
359+
expect(inputPanelContent).not.toBeNull();
360+
361+
const radioButtonsCell = await inputPanelContent.find(
362+
'.f-cell.radio-cell'
363+
);
364+
expect(radioButtonsCell).not.toBeNull();
365+
366+
const radioOptions = data.rows[0].cells.RAD.options;
367+
const radioButtons = await radioButtonsCell.findAll('div.form-field');
368+
expect(radioButtons).toHaveLength(radioOptions.length);
369+
370+
for (const [i, radioButton] of radioButtons.entries()) {
371+
const label = await radioButton.find('label');
372+
expect(label).not.toBeNull();
373+
expect(label).toEqualText(radioOptions[i]);
374+
375+
const input = await radioButton.find('input');
376+
expect(input).not.toBeNull();
377+
378+
const value = await input.getProperty('value');
379+
expect(value).toBe(radioOptions[i]);
380+
381+
if (data.rows[0].cells.RAD.value === radioOptions[i]) {
382+
const radioButtonCircle = await radioButton.find('div.radio');
383+
expect(radioButtonCircle).toHaveClass('radio--checked');
384+
}
385+
}
386+
});
326387
});

0 commit comments

Comments
 (0)