decide.nolog.cz/tests/helpers/poll-participate.js
renovate[bot] 98ff62af80
Update dependency prettier to v3 (#668)
* Update dependency prettier to v3

* upgrade eslint-plugin-prettier and run prettier on all files

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jeldrik Hanschke <admin@jhanschke.de>
2023-10-17 10:44:45 +02:00

31 lines
855 B
JavaScript

import { isEmpty } from '@ember/utils';
import { findAll, fillIn, click } from '@ember/test-helpers';
export default async function (name, selections) {
if (!isEmpty(name)) {
await fillIn('.participation .name input', name);
}
const isFreeText =
findAll('.participation .selections .radio').length > 0 ? false : true;
for (let [index, selection] of selections.entries()) {
if (!isEmpty(selection)) {
if (isFreeText) {
await fillIn(
`.participation .selections .form-group:nth-child(${
index + 1
}) input`,
selection,
);
} else {
await click(
`.participation .selections .form-group:nth-child(${
index + 1
}) .${selection}.radio input`,
);
}
}
}
await click('.participation button[type="submit"]');
}