Skip to content

Commit

Permalink
use the new option
Browse files Browse the repository at this point in the history
  • Loading branch information
Joosakur committed Dec 2, 2024
1 parent 67ea5f6 commit d478df0
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions frontend/src/e2e-test/dev-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -72,13 +63,7 @@ export async function execSimpleApplicationAction(
mockedTime: HelsinkiDateTime
): Promise<void> {
try {
await devClient.post(
`/applications/${applicationId}/actions/${action}`,
null,
{
headers: clockHeader(mockedTime)
}
)
await simpleAction({ applicationId, action }, { mockedTime })
} catch (e) {
throw new DevApiError(e)
}
Expand All @@ -91,17 +76,14 @@ export async function execSimpleApplicationActions(
): Promise<void> {
for (const action of actions) {
await execSimpleApplicationAction(applicationId, action, mockedTime)
await runPendingAsyncJobs(mockedTime)
}
}

export async function runPendingAsyncJobs(
mockedTime: HelsinkiDateTime
): Promise<void> {
try {
await devClient.post(`/run-jobs`, null, {
headers: clockHeader(mockedTime)
})
await runJobs({ mockedTime })
} catch (e) {
throw new DevApiError(e)
}
Expand Down

0 comments on commit d478df0

Please sign in to comment.