2018-12-29 01:27:37 +01:00
|
|
|
import { isEmpty } from '@ember/utils';
|
2023-10-15 20:37:03 +02:00
|
|
|
import { findAll, fillIn, click } from '@ember/test-helpers';
|
2015-10-18 14:04:04 +02:00
|
|
|
|
2023-10-15 20:37:03 +02:00
|
|
|
export default async function (name, selections) {
|
2018-12-29 01:27:37 +01:00
|
|
|
if (!isEmpty(name)) {
|
2018-12-29 20:35:04 +01:00
|
|
|
await fillIn('.participation .name input', name);
|
2015-10-18 14:04:04 +02:00
|
|
|
}
|
2015-11-12 15:52:14 +01:00
|
|
|
|
2023-10-15 20:37:03 +02:00
|
|
|
const isFreeText =
|
|
|
|
findAll('.participation .selections .radio').length > 0 ? false : true;
|
2018-12-29 20:35:04 +01:00
|
|
|
for (let [index, selection] of selections.entries()) {
|
2018-12-29 01:27:37 +01:00
|
|
|
if (!isEmpty(selection)) {
|
2015-10-18 14:04:04 +02:00
|
|
|
if (isFreeText) {
|
2023-10-15 20:37:03 +02:00
|
|
|
await fillIn(
|
|
|
|
`.participation .selections .form-group:nth-child(${
|
|
|
|
index + 1
|
|
|
|
}) input`,
|
2023-10-17 10:44:45 +02:00
|
|
|
selection,
|
2023-10-15 20:37:03 +02:00
|
|
|
);
|
2015-10-18 14:04:04 +02:00
|
|
|
} else {
|
2023-10-15 20:37:03 +02:00
|
|
|
await click(
|
|
|
|
`.participation .selections .form-group:nth-child(${
|
|
|
|
index + 1
|
2023-10-17 10:44:45 +02:00
|
|
|
}) .${selection}.radio input`,
|
2023-10-15 20:37:03 +02:00
|
|
|
);
|
2015-10-18 14:04:04 +02:00
|
|
|
}
|
|
|
|
}
|
2018-12-29 20:35:04 +01:00
|
|
|
}
|
2015-11-12 15:52:14 +01:00
|
|
|
|
2018-12-29 20:35:04 +01:00
|
|
|
await click('.participation button[type="submit"]');
|
|
|
|
}
|