{
diff --git a/front/src/modules/rollingStock/components/RollingStockSelector/SearchRollingStock.tsx b/front/src/modules/rollingStock/components/RollingStockSelector/SearchRollingStock.tsx
index a3fce71886a..2d60acadf51 100644
--- a/front/src/modules/rollingStock/components/RollingStockSelector/SearchRollingStock.tsx
+++ b/front/src/modules/rollingStock/components/RollingStockSelector/SearchRollingStock.tsx
@@ -114,7 +114,7 @@ const SearchRollingStock = ({
-
+
{filteredRollingStockList.length > 0
? `${filteredRollingStockList.length} ${t('resultsFound')}`
: t('noResultFound')}
diff --git a/front/tests/009-rollingstock-editor.spec.ts b/front/tests/009-rollingstock-editor.spec.ts
index b64b888a7b5..0f94d68b0d5 100644
--- a/front/tests/009-rollingstock-editor.spec.ts
+++ b/front/tests/009-rollingstock-editor.spec.ts
@@ -8,6 +8,7 @@ import {
generateUniqueName,
verifyAndCheckInputById,
fillAndCheckInputById,
+ addRollingStock,
} from './assets/utils';
import PlaywrightRollingstockEditorPage from './pages/rollingstock-editor-page-model';
@@ -16,8 +17,13 @@ const rollingstockDetailsPath = path.resolve(
__dirname,
'../tests/assets/rollingStock/rollingstockDetails.json'
);
+const rollingstockPath = path.resolve(
+ __dirname,
+ '../tests/assets/rollingStock/thermal-electric_rolling_stock.json'
+);
const rollingstockDetails = JSON.parse(fs.readFileSync(rollingstockDetailsPath, 'utf-8'));
-
+const rollingStockJson = JSON.parse(fs.readFileSync(rollingstockPath, 'utf8'));
+const thermalElectricRollingStockName = 'thermal-electric_rolling_stock';
test.describe('Rollingstock editor page', () => {
let uniqueRollingStockName: string;
let uniqueUpdatedRollingStockName: string;
@@ -32,6 +38,7 @@ test.describe('Rollingstock editor page', () => {
await findAndDeleteRollingStock(uniqueRollingStockName);
await findAndDeleteRollingStock(uniqueUpdatedRollingStockName);
await findAndDeleteRollingStock(uniqueDeletedRollingStockName);
+ await findAndDeleteRollingStock(thermalElectricRollingStockName);
});
test.afterEach(async () => {
@@ -39,6 +46,7 @@ test.describe('Rollingstock editor page', () => {
await findAndDeleteRollingStock(uniqueRollingStockName);
await findAndDeleteRollingStock(uniqueUpdatedRollingStockName);
await findAndDeleteRollingStock(uniqueDeletedRollingStockName);
+ await findAndDeleteRollingStock(thermalElectricRollingStockName);
});
test('should correctly create a new rolling stock', async ({ page }) => {
@@ -189,4 +197,134 @@ test.describe('Rollingstock editor page', () => {
rollingStockEditorPage.page.getByTestId(uniqueDeletedRollingStockName)
).toBeHidden();
});
+
+ test('should correctly filter electric rolling stock', async ({ page }) => {
+ const rollingStockEditorPage = new PlaywrightRollingstockEditorPage(page);
+
+ // Navigate to rolling stock editor page
+ await rollingStockEditorPage.navigateToPage();
+
+ // Extract and check the initial count of rolling stock
+ const initialRollingStockFoundNumber =
+ await rollingStockEditorPage.getRollingStockSearchNumber();
+
+ // Perform a filtering action for electric rolling stock
+ await rollingStockEditorPage.electricRollingStockFilter();
+
+ // Verify that filtering reduces the count and all the RS have electic icons
+ expect(await rollingStockEditorPage.getElectricRollingStockIcons.count()).toEqual(
+ await rollingStockEditorPage.getRollingStockSearchNumber()
+ );
+
+ // Clear electric filter
+ await rollingStockEditorPage.electricRollingStockFilter();
+
+ // Verify that the count of rolling stock is back to the initial number
+ expect(await rollingStockEditorPage.getRollingStockList.count()).toEqual(
+ initialRollingStockFoundNumber
+ );
+ });
+
+ test('should correctly filter thermal rolling stock', async ({ page }) => {
+ const rollingStockEditorPage = new PlaywrightRollingstockEditorPage(page);
+
+ // Navigate to rolling stock editor page
+ await rollingStockEditorPage.navigateToPage();
+
+ // Extract and check the initial count of rolling stock
+ const initialRollingStockFoundNumber =
+ await rollingStockEditorPage.getRollingStockSearchNumber();
+
+ // Perform a filtering action for thermal rolling stock
+ await rollingStockEditorPage.themalRollingStockFilter();
+
+ // Verify that filtering reduces the count and all the RS have thermal icons
+ expect(await rollingStockEditorPage.getThermalRollingStockIcons.count()).toEqual(
+ await rollingStockEditorPage.getRollingStockSearchNumber()
+ );
+
+ // Clear thermal filter
+ await rollingStockEditorPage.themalRollingStockFilter();
+
+ // Verify that the count of rolling stock is back to the initial number
+ expect(await rollingStockEditorPage.getRollingStockList.count()).toEqual(
+ initialRollingStockFoundNumber
+ );
+ });
+
+ test('should correctly filter thermal and electric rolling stock', async ({ page }) => {
+ const rollingStockEditorPage = new PlaywrightRollingstockEditorPage(page);
+
+ // Add a rolling stock via postAPI
+ await addRollingStock(thermalElectricRollingStockName, rollingStockJson);
+
+ // Navigate to rolling stock editor page
+ await rollingStockEditorPage.navigateToPage();
+
+ // Extract and check the initial count of rolling stock
+ const initialRollingStockFoundNumber =
+ await rollingStockEditorPage.getRollingStockSearchNumber();
+
+ // Perform a filtering action for combined thermal-electric rolling stock
+ await rollingStockEditorPage.electricRollingStockFilter();
+ await rollingStockEditorPage.themalRollingStockFilter();
+
+ // Verify that filtering reduces the count and all the RS have thermal and electric icons
+ expect(await rollingStockEditorPage.getThermalElectricRollingStockIcons.count()).toEqual(
+ await rollingStockEditorPage.getRollingStockSearchNumber()
+ );
+
+ // Clear filters
+ await rollingStockEditorPage.electricRollingStockFilter();
+ await rollingStockEditorPage.themalRollingStockFilter();
+
+ // Verify that the count of rolling stock is back to the initial number
+ expect(await rollingStockEditorPage.getRollingStockList.count()).toEqual(
+ initialRollingStockFoundNumber
+ );
+ });
+
+ test('should correctly search for a rolling stock', async ({ page }) => {
+ const rollingStockEditorPage = new PlaywrightRollingstockEditorPage(page);
+
+ // Add a rolling stock via postAPI
+ await addRollingStock(thermalElectricRollingStockName, rollingStockJson);
+
+ // Navigate to rolling stock editor page
+ await rollingStockEditorPage.navigateToPage();
+
+ // Extract and check the initial count of rolling stock
+ const initialRollingStockFoundNumber =
+ await rollingStockEditorPage.getRollingStockSearchNumber();
+
+ // Search for the specific rolling stock
+ await rollingStockEditorPage.searchRollingStock(thermalElectricRollingStockName);
+ expect(
+ rollingStockEditorPage.page.getByTestId(
+ `rollingstock-thermal-${thermalElectricRollingStockName}`
+ )
+ ).toBeDefined();
+
+ // Verify that the first rolling stock has the thermal and electric icon
+ await expect(rollingStockEditorPage.getThermalRollingStockFirstIcon).toBeVisible();
+ await expect(rollingStockEditorPage.getElectricRollingStockFirstIcon).toBeVisible();
+
+ // Clear the search
+ await rollingStockEditorPage.clearSearchRollingStock();
+
+ // Verify that the count of rolling stock is back to the initial number
+ expect(await rollingStockEditorPage.getRollingStockList.count()).toEqual(
+ initialRollingStockFoundNumber
+ );
+ // Search for a non existing rolling stock
+ await rollingStockEditorPage.searchRollingStock(
+ `${thermalElectricRollingStockName}-no-results`
+ );
+
+ // Wait for the page to reach the network idle state
+ await rollingStockEditorPage.page.waitForLoadState('networkidle');
+
+ // Verify that the count of rolling stock is 0 (No results Found)
+ expect(await rollingStockEditorPage.getRollingStockSearchNumber()).toEqual(0);
+ });
});
diff --git a/front/tests/assets/rollingStock/thermal-electric_rolling_stock.json b/front/tests/assets/rollingStock/thermal-electric_rolling_stock.json
new file mode 100644
index 00000000000..1eb00b80ed9
--- /dev/null
+++ b/front/tests/assets/rollingStock/thermal-electric_rolling_stock.json
@@ -0,0 +1,367 @@
+{
+ "railjson_version": "3.2",
+ "name": "thermal-electric_rolling_stock",
+ "effort_curves": {
+ "modes": {
+ "25000V": {
+ "curves": [
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": "25000V",
+ "power_restriction_code": "C1"
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 5.294117647058823, 10.588235294117649, 15.882352941176473, 21.176470588235293,
+ 26.470588235294116, 31.764705882352946, 37.05882352941176, 42.35294117647059,
+ 47.64705882352941, 52.94117647058823, 58.23529411764706, 63.52941176470589,
+ 68.82352941176471, 74.11764705882352, 79.41176470588235, 84.70588235294117, 90.0
+ ],
+ "max_efforts": [
+ 450000.0, 445235.2941176471, 440470.5882352941, 435705.8823529412,
+ 430411.7647058823, 423264.70588235295, 416117.6470588235, 408970.5882352941,
+ 398484.1628959276, 383823.5294117647, 369162.89592760184, 348806.7226890756,
+ 328386.55462184874, 288330.8823529411, 210904.411764706, 192705.88235294115,
+ 186352.9411764706, 180000.0
+ ]
+ }
+ },
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": "25000V",
+ "power_restriction_code": "C2"
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 5.294117647058823, 10.588235294117649, 15.882352941176473, 21.176470588235293,
+ 26.470588235294116, 31.764705882352946, 37.05882352941176, 42.35294117647059,
+ 47.64705882352941, 52.94117647058823, 58.23529411764706, 63.52941176470589,
+ 68.82352941176471, 74.11764705882352, 79.41176470588235, 84.70588235294117, 90.0
+ ],
+ "max_efforts": [
+ 400000.0, 395764.705882353, 391529.4117647059, 387294.11764705885,
+ 382588.2352941177, 376235.29411764705, 369882.3529411765, 363529.4117647059,
+ 354208.1447963801, 341176.4705882353, 328144.7963800905, 310050.42016806727,
+ 291899.1596638655, 256294.11764705877, 187470.5882352942, 171294.11764705885,
+ 165647.05882352943, 160000.0
+ ]
+ }
+ },
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": "22500V",
+ "power_restriction_code": "C1"
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 5.294117647058823, 10.588235294117649, 15.882352941176473, 21.176470588235293,
+ 26.470588235294116, 31.764705882352946, 37.05882352941176, 42.35294117647059,
+ 47.64705882352941, 52.94117647058823, 58.23529411764706, 63.52941176470589,
+ 68.82352941176471, 74.11764705882352, 79.41176470588235, 84.70588235294117, 90.0
+ ],
+ "max_efforts": [
+ 405000.0, 400711.7647058824, 396423.5294117647, 392135.2941176471,
+ 387370.5882352941, 380938.2352941177, 374505.8823529412, 368073.5294117647,
+ 358635.74660633487, 345441.17647058825, 332246.6063348417, 313926.0504201681,
+ 295547.8991596639, 259497.794117647, 189813.9705882354, 173435.29411764705,
+ 167717.64705882355, 162000.0
+ ]
+ }
+ },
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": "22500V",
+ "power_restriction_code": "C2"
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 5.294117647058823, 10.588235294117649, 15.882352941176473, 21.176470588235293,
+ 26.470588235294116, 31.764705882352946, 37.05882352941176, 42.35294117647059,
+ 47.64705882352941, 52.94117647058823, 58.23529411764706, 63.52941176470589,
+ 68.82352941176471, 74.11764705882352, 79.41176470588235, 84.70588235294117, 90.0
+ ],
+ "max_efforts": [
+ 360000.0, 356188.2352941177, 352376.4705882353, 348564.705882353, 344329.4117647059,
+ 338611.7647058824, 332894.11764705885, 327176.4705882353, 318787.3303167421,
+ 307058.82352941175, 295330.3167420815, 279045.3781512605, 262709.243697479,
+ 230664.7058823529, 168723.52941176482, 154164.70588235295, 149082.35294117648,
+ 144000.0
+ ]
+ }
+ },
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": "20000V",
+ "power_restriction_code": "C1"
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 5.294117647058823, 10.588235294117649, 15.882352941176473, 21.176470588235293,
+ 26.470588235294116, 31.764705882352946, 37.05882352941176, 42.35294117647059,
+ 47.64705882352941, 52.94117647058823, 58.23529411764706, 63.52941176470589,
+ 68.82352941176471, 74.11764705882352, 79.41176470588235, 84.70588235294117, 90.0
+ ],
+ "max_efforts": [
+ 360000.0, 356188.2352941177, 352376.4705882353, 348564.70588235295,
+ 344329.4117647059, 338611.76470588235, 332894.11764705885, 327176.4705882353,
+ 318787.33031674207, 307058.8235294118, 295330.3167420815, 279045.37815126055,
+ 262709.24369747896, 230664.7058823529, 168723.5294117648, 154164.70588235295,
+ 149082.35294117648, 144000.0
+ ]
+ }
+ },
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": "20000V",
+ "power_restriction_code": "C2"
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 5.294117647058823, 10.588235294117649, 15.882352941176473, 21.176470588235293,
+ 26.470588235294116, 31.764705882352946, 37.05882352941176, 42.35294117647059,
+ 47.64705882352941, 52.94117647058823, 58.23529411764706, 63.52941176470589,
+ 68.82352941176471, 74.11764705882352, 79.41176470588235, 84.70588235294117, 90.0
+ ],
+ "max_efforts": [
+ 320000.0, 316611.7647058824, 313223.52941176476, 309835.2941176471,
+ 306070.58823529416, 300988.23529411765, 295905.8823529412, 290823.52941176476,
+ 283366.51583710406, 272941.17647058825, 262515.83710407245, 248040.33613445383,
+ 233519.32773109243, 205035.29411764705, 149976.4705882354, 137035.29411764708,
+ 132517.64705882355, 128000.0
+ ]
+ }
+ },
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": null,
+ "power_restriction_code": "C1"
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 5.294117647058823, 10.588235294117649, 15.882352941176473, 21.176470588235293,
+ 26.470588235294116, 31.764705882352946, 37.05882352941176, 42.35294117647059,
+ 47.64705882352941, 52.94117647058823, 58.23529411764706, 63.52941176470589,
+ 68.82352941176471, 74.11764705882352, 79.41176470588235, 84.70588235294117, 90.0
+ ],
+ "max_efforts": [
+ 450000.0, 445235.2941176471, 440470.5882352941, 435705.8823529412,
+ 430411.7647058823, 423264.70588235295, 416117.6470588235, 408970.5882352941,
+ 398484.1628959276, 383823.5294117647, 369162.89592760184, 348806.7226890756,
+ 328386.55462184874, 288330.8823529411, 210904.411764706, 192705.88235294115,
+ 186352.9411764706, 180000.0
+ ]
+ }
+ },
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": null,
+ "power_restriction_code": "C2"
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 5.294117647058823, 10.588235294117649, 15.882352941176473, 21.176470588235293,
+ 26.470588235294116, 31.764705882352946, 37.05882352941176, 42.35294117647059,
+ 47.64705882352941, 52.94117647058823, 58.23529411764706, 63.52941176470589,
+ 68.82352941176471, 74.11764705882352, 79.41176470588235, 84.70588235294117, 90.0
+ ],
+ "max_efforts": [
+ 400000.0, 395764.705882353, 391529.4117647059, 387294.11764705885,
+ 382588.2352941177, 376235.29411764705, 369882.3529411765, 363529.4117647059,
+ 354208.1447963801, 341176.4705882353, 328144.7963800905, 310050.42016806727,
+ 291899.1596638655, 256294.11764705877, 187470.5882352942, 171294.11764705885,
+ 165647.05882352943, 160000.0
+ ]
+ }
+ },
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": "25000V",
+ "power_restriction_code": null
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 5.294117647058823, 10.588235294117649, 15.882352941176473, 21.176470588235293,
+ 26.470588235294116, 31.764705882352946, 37.05882352941176, 42.35294117647059,
+ 47.64705882352941, 52.94117647058823, 58.23529411764706, 63.52941176470589,
+ 68.82352941176471, 74.11764705882352, 79.41176470588235, 84.70588235294117, 90.0
+ ],
+ "max_efforts": [
+ 500000.0, 494705.8823529412, 489411.7647058823, 484117.6470588235,
+ 478235.29411764705, 470294.1176470588, 462352.9411764706, 454411.7647058823,
+ 442760.1809954751, 426470.5882352941, 410180.9954751131, 387563.025210084,
+ 364873.9495798319, 320367.64705882344, 234338.23529411777, 214117.64705882352,
+ 207058.82352941175, 200000.0
+ ]
+ }
+ },
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": "22500V",
+ "power_restriction_code": null
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 5.294117647058823, 10.588235294117649, 15.882352941176473, 21.176470588235293,
+ 26.470588235294116, 31.764705882352946, 37.05882352941176, 42.35294117647059,
+ 47.64705882352941, 52.94117647058823, 58.23529411764706, 63.52941176470589,
+ 68.82352941176471, 74.11764705882352, 79.41176470588235, 84.70588235294117, 90.0
+ ],
+ "max_efforts": [
+ 450000.0, 445235.2941176471, 440470.5882352941, 435705.8823529412,
+ 430411.7647058823, 423264.70588235295, 416117.6470588235, 408970.5882352941,
+ 398484.1628959276, 383823.5294117647, 369162.89592760184, 348806.7226890756,
+ 328386.55462184874, 288330.8823529411, 210904.411764706, 192705.88235294115,
+ 186352.9411764706, 180000.0
+ ]
+ }
+ },
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": "20000V",
+ "power_restriction_code": null
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 5.294117647058823, 10.588235294117649, 15.882352941176473, 21.176470588235293,
+ 26.470588235294116, 31.764705882352946, 37.05882352941176, 42.35294117647059,
+ 47.64705882352941, 52.94117647058823, 58.23529411764706, 63.52941176470589,
+ 68.82352941176471, 74.11764705882352, 79.41176470588235, 84.70588235294117, 90.0
+ ],
+ "max_efforts": [
+ 400000.0, 395764.705882353, 391529.4117647059, 387294.11764705885,
+ 382588.2352941177, 376235.29411764705, 369882.3529411765, 363529.4117647059,
+ 354208.1447963801, 341176.4705882353, 328144.7963800905, 310050.42016806727,
+ 291899.1596638655, 256294.11764705877, 187470.5882352942, 171294.11764705885,
+ 165647.05882352943, 160000.0
+ ]
+ }
+ },
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": null,
+ "power_restriction_code": null
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 5.277777777777778, 10.555555555555555, 15.833333333333332, 21.11111111111111,
+ 26.38888888888889, 31.666666666666664, 36.94444444444444, 42.22222222222222,
+ 47.77777777777778, 53.05555555555556, 58.33333333333333, 63.61111111111111,
+ 68.88888888888889, 74.16666666666667, 79.44444444444444, 84.72222222222221, 90.0
+ ],
+ "max_efforts": [
+ 500000.0, 494705.8823529412, 489411.7647058823, 484117.6470588235,
+ 478235.29411764705, 470294.1176470588, 462352.9411764706, 454411.7647058823,
+ 442760.1809954751, 426470.5882352941, 410180.9954751131, 387563.025210084,
+ 364873.9495798319, 320367.64705882344, 234338.23529411777, 214117.64705882352,
+ 207058.82352941175, 200000.0
+ ]
+ }
+ }
+ ],
+ "default_curve": {
+ "speeds": [
+ 0.0, 5.277777777777778, 10.555555555555555, 15.833333333333332, 21.11111111111111,
+ 26.38888888888889, 31.666666666666664, 36.94444444444444, 42.22222222222222,
+ 47.77777777777778, 53.05555555555556, 58.33333333333333, 63.61111111111111,
+ 68.88888888888889, 74.16666666666667, 79.44444444444444, 84.72222222222221, 90.0
+ ],
+ "max_efforts": [
+ 500000.0, 494705.8823529412, 489411.7647058823, 484117.6470588235, 478235.29411764705,
+ 470294.1176470588, 462352.9411764706, 454411.7647058823, 442760.1809954751,
+ 426470.5882352941, 410180.9954751131, 387563.025210084, 364873.9495798319,
+ 320367.64705882344, 234338.23529411777, 214117.64705882352, 207058.82352941175, 200000.0
+ ]
+ },
+ "is_electric": true
+ },
+ "thermal": {
+ "curves": [
+ {
+ "cond": {
+ "comfort": "STANDARD",
+ "electrical_profile_level": null,
+ "power_restriction_code": null
+ },
+ "curve": {
+ "speeds": [
+ 0.0, 2.7777777777777777, 5.555555555555555, 8.333333333333334, 11.11111111111111,
+ 13.88888888888889, 16.666666666666668, 19.444444444444443, 22.22222222222222, 25.0,
+ 27.77777777777778, 30.555555555555554, 33.333333333333336
+ ],
+ "max_efforts": [
+ 126000.0, 126000.0, 126000.0, 102750.0, 80340.0, 65379.99999999999, 54900.0,
+ 47210.0, 41360.0, 36790.0, 33120.0, 30110.0, 27600.0
+ ]
+ }
+ }
+ ],
+ "default_curve": {
+ "speeds": [
+ 0.0, 2.7777777777777777, 5.555555555555555, 8.333333333333334, 11.11111111111111,
+ 13.88888888888889, 16.666666666666668, 19.444444444444443, 22.22222222222222, 25.0,
+ 27.77777777777778, 30.555555555555554, 33.333333333333336
+ ],
+ "max_efforts": [
+ 126000.0, 126000.0, 126000.0, 102750.0, 80340.0, 65379.99999999999, 54900.0, 47210.0,
+ 41360.0, 36790.0, 33120.0, 30110.0, 27600.0
+ ]
+ },
+ "is_electric": false
+ }
+ },
+ "default_mode": "thermal"
+ },
+ "metadata": {
+ "detail": "thermo-electric",
+ "family": "",
+ "type": "",
+ "grouping": "",
+ "series": "",
+ "subseries": "",
+ "unit": "",
+ "number": "",
+ "reference": "thermo-electric"
+ },
+ "length": 350.0,
+ "max_speed": 44.44444444444444,
+ "startup_time": 12.0,
+ "startup_acceleration": 0.06,
+ "comfort_acceleration": 0.54,
+ "gamma": {
+ "type": "CONST",
+ "value": 0.5
+ },
+ "inertia_coefficient": 1.05,
+ "base_power_class": "5",
+ "mass": 900000.0,
+ "rolling_resistance": {
+ "type": "davis",
+ "A": 4400.0,
+ "B": 195.67674,
+ "C": 12.00002688
+ },
+ "loading_gauge": "G1",
+ "power_restrictions": {
+ "C1": "3",
+ "C2": "1"
+ },
+ "energy_sources": [],
+ "locked": true,
+ "electrical_power_startup_time": 6.0,
+ "raise_pantograph_time": 16.0,
+ "version": 4,
+ "supported_signaling_systems": ["BAL", "BAPR", "TVM300", "TVM430"],
+ "liveries": []
+}
diff --git a/front/tests/assets/utils.ts b/front/tests/assets/utils.ts
index 5c325741792..532e72254d7 100644
--- a/front/tests/assets/utils.ts
+++ b/front/tests/assets/utils.ts
@@ -78,7 +78,13 @@ export const getRollingStock = async () => {
) as RollingStock;
return rollingStock;
};
-
+// Add a rolling Stock
+export async function addRollingStock(rollingStockName: string, rollingStockJson: JSON) {
+ await postApiRequest('/api/rolling_stock/', {
+ ...rollingStockJson,
+ name: rollingStockName,
+ });
+}
// Find and delete rolling stock with the given name
export async function findAndDeleteRollingStock(rollingStockName: string) {
const rollingStocks = await getApiRequest(`/api/light_rolling_stock/`, { page_size: 500 });
@@ -207,6 +213,9 @@ export async function allowancesManagement(
await scenarioPage.page.getByTestId('submit-edit-train-schedule').click();
await scenarioPage.page.waitForSelector('.scenario-details-name');
expect(await scenarioPage.isAllowanceWorking()).toEqual(true);
-
- // TODO: check if the allowances are taken into account in the scenario page (waiting for issue # 6695 to be fixed)
+}
+// Extracts the first sequence of digits found in the input string and returns it as a number or return 0 if no digits found
+export async function extractNumberFromString(input: string): Promise {
+ const match = input.match(/\d+/);
+ return match ? parseInt(match[0], 10) : 0;
}
diff --git a/front/tests/pages/rollingstock-editor-page-model.ts b/front/tests/pages/rollingstock-editor-page-model.ts
index e4c8521605c..6b7be2b9036 100644
--- a/front/tests/pages/rollingstock-editor-page-model.ts
+++ b/front/tests/pages/rollingstock-editor-page-model.ts
@@ -1,7 +1,7 @@
import { expect, type Locator, type Page } from '@playwright/test';
import PlaywrightCommonPage from './common-page-model';
-import { fillAndCheckInputById } from '../assets/utils';
+import { fillAndCheckInputById, extractNumberFromString } from '../assets/utils';
export default class PlaywrightRollingstockEditorPage extends PlaywrightCommonPage {
readonly getNewRollingstockButton: Locator;
@@ -18,8 +18,6 @@ export default class PlaywrightRollingstockEditorPage extends PlaywrightCommonPa
readonly getRollingStockEditorList: Locator;
- readonly getRollingStockEditorButtons: Locator;
-
readonly getPowerRestrictionSelector: Locator;
readonly getElectricalProfileSelector: Locator;
@@ -38,10 +36,30 @@ export default class PlaywrightRollingstockEditorPage extends PlaywrightCommonPa
readonly deleteSelectedElectricalProfileButton: Locator;
+ readonly getEditRollingStockButton: Locator;
+
readonly getDuplicateRollingStockButton: Locator;
readonly getDeleteRollingStockButton: Locator;
+ readonly getElectricRollingStockFilter: Locator;
+
+ readonly getThermalRollingStockFilter: Locator;
+
+ readonly getRollingStockSearchResult: Locator;
+
+ readonly getThermalRollingStockIcons: Locator;
+
+ readonly getElectricRollingStockIcons: Locator;
+
+ readonly getElectricRollingStockFirstIcon: Locator;
+
+ readonly getThermalRollingStockFirstIcon: Locator;
+
+ readonly getRollingStockList: Locator;
+
+ readonly getThermalElectricRollingStockIcons: Locator;
+
constructor(page: Page) {
super(page);
this.getNewRollingstockButton = page.getByTestId('new-rollingstock-button');
@@ -51,7 +69,6 @@ export default class PlaywrightRollingstockEditorPage extends PlaywrightCommonPa
this.getRollingStockSpreadsheet = page.locator('.dsg-container');
this.getRollingStockSearchInput = page.locator('#searchfilter');
this.getRollingStockEditorList = page.getByTestId('rollingstock-editor-list');
- this.getRollingStockEditorButtons = page.locator('.rollingstock-editor-buttons');
this.getPowerRestrictionSelector = page.getByTestId('power-restriction-selector');
this.getElectricalProfileSelector = page.getByTestId('electrical-profile-selector');
this.getLoadingGauge = page.locator('#loadingGauge');
@@ -64,15 +81,29 @@ export default class PlaywrightRollingstockEditorPage extends PlaywrightCommonPa
'button',
{ name: 'Delete item', exact: true }
);
- this.getDuplicateRollingStockButton = this.getRollingStockEditorButtons
- .locator('button')
- .nth(1);
- this.getDeleteRollingStockButton = this.getRollingStockEditorButtons.locator('button').nth(2);
+ this.getEditRollingStockButton = page.getByTestId('rollingstock-edit-button');
+ this.getDuplicateRollingStockButton = page.getByTestId('rollingstock-duplicate-button');
+ this.getDeleteRollingStockButton = page.getByTestId('rollingstock-delete-button');
+ this.getElectricRollingStockFilter = page.locator('label[for="elec"]');
+ this.getThermalRollingStockFilter = page.locator('label[for="thermal"]');
+ this.getRollingStockSearchResult = page.getByTestId('search-results-text');
+ this.getThermalRollingStockIcons = page.locator('.rollingstock-footer-specs .text-pink');
+ this.getElectricRollingStockIcons = page.locator('.rollingstock-footer-specs .text-primary');
+ this.getThermalElectricRollingStockIcons = page
+ .locator('.rollingstock-footer-specs .rollingstock-tractionmode:has(.text-pink)')
+ .filter({
+ has: page.locator('.text-primary'),
+ });
+ this.getElectricRollingStockFirstIcon = this.getElectricRollingStockIcons.first();
+ this.getThermalRollingStockFirstIcon = this.getThermalRollingStockIcons.first();
+ this.getRollingStockList = page.locator('.rollingstock-editor-list .rollingstock-title');
}
// Navigate to the Rolling Stock Editor Page
async navigateToPage() {
await this.page.goto('/rolling-stock-editor/');
+ // Wait for the page to reach the network idle state
+ await this.page.waitForLoadState('networkidle');
await this.removeViteOverlay();
}
@@ -100,7 +131,7 @@ export default class PlaywrightRollingstockEditorPage extends PlaywrightCommonPa
// Edit a rolling stock
async editRollingStock(rollingStockName: string) {
await this.selectRollingStock(rollingStockName);
- await this.getRollingStockEditorButtons.first().click();
+ await this.getEditRollingStockButton.click();
}
// Click the Submit Rolling Stock Button
@@ -295,4 +326,19 @@ export default class PlaywrightRollingstockEditorPage extends PlaywrightCommonPa
await this.getDeleteRollingStockButton.click();
await this.getConfirmModalButtonYes.click();
}
+
+ // Select Combustion engine RS filter
+ async themalRollingStockFilter() {
+ await this.getThermalRollingStockFilter.click();
+ }
+
+ // Select Electic RS filter
+ async electricRollingStockFilter() {
+ await this.getElectricRollingStockFilter.click();
+ }
+
+ // Get the number of RS from the search result text
+ async getRollingStockSearchNumber(): Promise {
+ return extractNumberFromString(await this.getRollingStockSearchResult.innerText());
+ }
}