Merge pull request #6814 from tchak/test-improuve-selector
test(system): simplify select menu selector
This commit is contained in:
commit
bedf762f06
5 changed files with 28 additions and 34 deletions
|
@ -110,9 +110,17 @@ function ComboMultiple({
|
||||||
extraOptions[0] &&
|
extraOptions[0] &&
|
||||||
extraOptions[0][0] == selectedValue
|
extraOptions[0][0] == selectedValue
|
||||||
) {
|
) {
|
||||||
setNewValues((newValues) => [...newValues, selectedValue]);
|
setNewValues((newValues) => {
|
||||||
|
const set = new Set(newValues);
|
||||||
|
set.add(selectedValue);
|
||||||
|
return [...set];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
saveSelection((selections) => [...selections, selectedValue]);
|
saveSelection((selections) => {
|
||||||
|
const set = new Set(selections);
|
||||||
|
set.add(selectedValue);
|
||||||
|
return [...set];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
setTerm('');
|
setTerm('');
|
||||||
awaitFormSubmit.done();
|
awaitFormSubmit.done();
|
||||||
|
@ -162,18 +170,17 @@ function ComboMultiple({
|
||||||
};
|
};
|
||||||
|
|
||||||
const onBlur = () => {
|
const onBlur = () => {
|
||||||
if (
|
const shouldSelect =
|
||||||
term &&
|
term &&
|
||||||
[...extraOptions, ...options].map(([label]) => label).includes(term)
|
[...extraOptions, ...options].map(([label]) => label).includes(term);
|
||||||
) {
|
|
||||||
awaitFormSubmit(() => {
|
awaitFormSubmit(() => {
|
||||||
|
if (shouldSelect) {
|
||||||
onSelect(term);
|
onSelect(term);
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
|
||||||
hidePopover();
|
hidePopover();
|
||||||
}, 200);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -232,17 +239,11 @@ function ComboMultiple({
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
{results.map(([label, value], index) => {
|
{results.map(([label], index) => {
|
||||||
if (label.startsWith('--')) {
|
if (label.startsWith('--')) {
|
||||||
return <ComboboxSeparator key={index} value={label} />;
|
return <ComboboxSeparator key={index} value={label} />;
|
||||||
}
|
}
|
||||||
return (
|
return <ComboboxOption key={index} value={label} />;
|
||||||
<ComboboxOption
|
|
||||||
key={index}
|
|
||||||
value={label}
|
|
||||||
data-option-value={value}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
})}
|
||||||
</ComboboxList>
|
</ComboboxList>
|
||||||
</ComboboxPopover>
|
</ComboboxPopover>
|
||||||
|
|
|
@ -122,13 +122,7 @@ function ComboSearch({
|
||||||
const label = getLabel(result);
|
const label = getLabel(result);
|
||||||
const [key, value] = transformResult(result);
|
const [key, value] = transformResult(result);
|
||||||
resultsMap.current[label] = { key, value, result };
|
resultsMap.current[label] = { key, value, result };
|
||||||
return (
|
return <ComboboxOption key={`${key}-${index}`} value={label} />;
|
||||||
<ComboboxOption
|
|
||||||
key={`${key}-${index}`}
|
|
||||||
value={label}
|
|
||||||
data-option-value={value}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
})}
|
||||||
</ComboboxList>
|
</ComboboxList>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
@ -105,8 +105,7 @@ module SystemHelpers
|
||||||
|
|
||||||
def select_combobox(libelle, fill_with, value, check: true)
|
def select_combobox(libelle, fill_with, value, check: true)
|
||||||
fill_in libelle, with: fill_with
|
fill_in libelle, with: fill_with
|
||||||
selector = "li[data-option-value=\"#{value}\"]"
|
find('li[role="option"]', text: value).click
|
||||||
find(selector).click
|
|
||||||
if check
|
if check
|
||||||
check_selected_value(libelle, with: value)
|
check_selected_value(libelle, with: value)
|
||||||
end
|
end
|
||||||
|
|
|
@ -165,8 +165,8 @@ describe 'Instructing a dossier:', js: true do
|
||||||
|
|
||||||
click_on 'Personnes impliquées'
|
click_on 'Personnes impliquées'
|
||||||
|
|
||||||
select_combobox('Emails', instructeur_2.email, instructeur_2.id, check: false)
|
select_combobox('Emails', instructeur_2.email, instructeur_2.email, check: false)
|
||||||
select_combobox('Emails', instructeur_3.email, instructeur_3.id, check: false)
|
select_combobox('Emails', instructeur_3.email, instructeur_3.email, check: false)
|
||||||
|
|
||||||
click_on 'Envoyer'
|
click_on 'Envoyer'
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe "procedure filters" do
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "should add be able to add created_at column", js: true do
|
scenario "should add be able to add created_at column", js: true do
|
||||||
add_column("Créé le", "self/created_at")
|
add_column("Créé le")
|
||||||
within ".dossiers-table" do
|
within ".dossiers-table" do
|
||||||
expect(page).to have_link("Créé le")
|
expect(page).to have_link("Créé le")
|
||||||
expect(page).to have_link(new_unfollow_dossier.created_at.strftime('%d/%m/%Y'))
|
expect(page).to have_link(new_unfollow_dossier.created_at.strftime('%d/%m/%Y'))
|
||||||
|
@ -40,7 +40,7 @@ describe "procedure filters" do
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "should add be able to add and remove custom type_de_champ column", js: true do
|
scenario "should add be able to add and remove custom type_de_champ column", js: true do
|
||||||
add_column(type_de_champ.libelle, "type_de_champ/#{type_de_champ.stable_id}")
|
add_column(type_de_champ.libelle)
|
||||||
within ".dossiers-table" do
|
within ".dossiers-table" do
|
||||||
expect(page).to have_link(type_de_champ.libelle)
|
expect(page).to have_link(type_de_champ.libelle)
|
||||||
expect(page).to have_link(champ.value)
|
expect(page).to have_link(champ.value)
|
||||||
|
@ -123,9 +123,9 @@ describe "procedure filters" do
|
||||||
click_button "Ajouter le filtre"
|
click_button "Ajouter le filtre"
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_column(column_name, column_path)
|
def add_column(column_name)
|
||||||
click_on 'Personnaliser'
|
click_on 'Personnaliser'
|
||||||
select_combobox('Colonne à afficher', column_name, column_path, check: false)
|
select_combobox('Colonne à afficher', column_name, column_name, check: false)
|
||||||
click_button "Enregistrer"
|
click_button "Enregistrer"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue