From d478df0294ebea6fcfb32b24c595f151e34cc5a7 Mon Sep 17 00:00:00 2001 From: Joosa Kurvinen Date: Mon, 2 Dec 2024 11:45:07 +0200 Subject: [PATCH] use the new option --- frontend/src/e2e-test/dev-api/index.ts | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/frontend/src/e2e-test/dev-api/index.ts b/frontend/src/e2e-test/dev-api/index.ts index 38b563a5cc3..12a02c9dd8b 100644 --- a/frontend/src/e2e-test/dev-api/index.ts +++ b/frontend/src/e2e-test/dev-api/index.ts @@ -4,17 +4,14 @@ import * as fs from 'fs/promises' -import axios, { - AxiosHeaders, - AxiosResponse, - InternalAxiosRequestConfig -} from 'axios' +import axios, { AxiosResponse, InternalAxiosRequestConfig } from 'axios' import FormData from 'form-data' import { BaseError } from 'make-error-cause' import HelsinkiDateTime from 'lib-common/helsinki-date-time' import config from '../config' +import { runJobs, simpleAction } from '../generated/api-clients' import { DevPerson, MockVtjDataset } from '../generated/api-types' export class DevApiError extends BaseError { @@ -32,12 +29,6 @@ export class DevApiError extends BaseError { } } -function clockHeader(now: HelsinkiDateTime): AxiosHeaders { - return new AxiosHeaders({ - EvakaMockedTime: now.formatIso() - }) -} - function formatRequest(config: InternalAxiosRequestConfig | undefined): string { if (!config || !config.url) return '' const url = new URL(config.url, config.baseURL) @@ -72,13 +63,7 @@ export async function execSimpleApplicationAction( mockedTime: HelsinkiDateTime ): Promise { try { - await devClient.post( - `/applications/${applicationId}/actions/${action}`, - null, - { - headers: clockHeader(mockedTime) - } - ) + await simpleAction({ applicationId, action }, { mockedTime }) } catch (e) { throw new DevApiError(e) } @@ -91,7 +76,6 @@ export async function execSimpleApplicationActions( ): Promise { for (const action of actions) { await execSimpleApplicationAction(applicationId, action, mockedTime) - await runPendingAsyncJobs(mockedTime) } } @@ -99,9 +83,7 @@ export async function runPendingAsyncJobs( mockedTime: HelsinkiDateTime ): Promise { try { - await devClient.post(`/run-jobs`, null, { - headers: clockHeader(mockedTime) - }) + await runJobs({ mockedTime }) } catch (e) { throw new DevApiError(e) }