Skip to content

Commit

Permalink
Fix failing playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
florimondmanca committed Sep 18, 2023
1 parent 100154a commit c53300b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion templates/regulation/_vehicle_set_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

{% for option in form.allVehicles %}
<div class="fr-fieldset__element">
<div class="fr-radio-group fr-radio-rich {% if option.vars.value == 'no' %}app-someVehicles__radiogroup{% endif %}">
<div class="fr-radio-group fr-radio-rich {% if option.vars.value == 'no' %}app-someVehicles__radiogroup{% endif %}" data-testid="allVehicles-{{ index }}-{{ option.vars.value }}">
{{ form_widget(option, {
attr: {
'data-controller': 'condition',
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/pages/regulation_order.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class RegulationOrderPage {

await this.page.getByLabel('Voie ou ville').fill(address);
await this.page.getByLabel('Type de restriction').selectOption({ label: restrictionType });
await this.page.getByText('Tous les véhicules', { exact: true }).check({ force: true });
await this.page.getByTestId('allVehicles-0-yes').click();
await this.saveBtn.click();
this.addedLocationTitles.push(expectedTitle);
return this.getLocationByTitle(expectedTitle);
Expand Down Expand Up @@ -96,7 +96,7 @@ export class RegulationOrderPage {
const restrictionTypeField = measure.getByRole('combobox', { name: 'Type de restriction' });
expect(await restrictionTypeField.getAttribute('name')).toBe(`location_form[measures][${expectedIndex}][type]`);
await restrictionTypeField.selectOption({ label: restrictionType });
await measure.getByText('Tous les véhicules', { exact: true }).check();
await this.page.getByTestId(`allVehicles-${expectedIndex}-yes`).click();

// Advanced vehicles options are not shown
await expect(measure.getByLabel('Types de véhicules concernés', { exact: true })).not.toBeVisible(); // Restricted
Expand Down Expand Up @@ -149,7 +149,7 @@ export class RegulationOrderPage {

// Define restricted vehicles
const restrictedVehiclesFieldset = measure.getByRole('radiogroup', { name: 'Véhicules concernés' });
await restrictedVehiclesFieldset.getByText('Certains véhicules', { exact: true }).click();
await restrictedVehiclesFieldset.getByTestId(`allVehicles-${measureIndex}-no`).click();
for (const vehicleType of restrictedVehicleTypes) {
await restrictedVehiclesFieldset.getByLabel('Types de véhicules concernés').getByLabel(vehicleType, { exact: true }).click();
}
Expand Down

0 comments on commit c53300b

Please sign in to comment.