-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
front: update e2e tests to handle paced trains
Signed-off-by: SharglutDev <[email protected]>
- Loading branch information
1 parent
a8611cb
commit 77ebbd0
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { APIRequestContext, APIResponse } from '@playwright/test'; | ||
|
||
import type { PacedTrainResult } from 'common/api/osrdEditoastApi'; | ||
|
||
import { getApiContext, handleErrorResponse } from './api-utils'; | ||
|
||
/** | ||
* Send paced trains to the API for a specific timetable and returns the result. | ||
* | ||
* @param timetableId - The ID of the timetable for which the paced trains are being sent. | ||
* @param body - The request payload containing paced train data. | ||
* @returns {Promise<PacedTrainResult[]>} - The API response containing the train schedule results. | ||
*/ | ||
async function sendPacedTrains(timetableId: number, body: JSON): Promise<PacedTrainResult[]> { | ||
const apiContext: APIRequestContext = await getApiContext(); | ||
const pacedTrainsResponse: APIResponse = await apiContext.post( | ||
`/api/timetable/${timetableId}/paced_trains/`, | ||
{ | ||
data: JSON.stringify(body), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
} | ||
); | ||
handleErrorResponse(pacedTrainsResponse, 'Failed to send paced train'); | ||
const responseData = (await pacedTrainsResponse.json()) as PacedTrainResult[]; | ||
|
||
return responseData; | ||
} | ||
export default sendPacedTrains; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters