mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-21 16:16:11 +00:00
test: run cloud sketches tests on the CI (#2092)
- fix(test): integration tests are more resilient. - run the Create integration tests with other slow tests, - queued `PUT`/`DELETE` requests to make the test timeout happy, - reduced the `/sketches/search` offset to 1/5th and - remove Create API logging. - fix(linter): ignore `lib` folder. Remove obsolete `.node_modules` pattern. - feat(ci): enable Create API integration tests. Signed-off-by: Akos Kitta <a.kitta@arduino.cc> Co-authored-by: per1234 <accounts@perglass.com>
This commit is contained in:
@@ -179,7 +179,8 @@ export class CreateApi {
|
||||
);
|
||||
})
|
||||
.catch((reason) => {
|
||||
if (reason?.status === 404) return [] as Create.Resource[];
|
||||
if (reason?.status === 404)
|
||||
return [] as Create.Resource[]; // TODO: must not swallow 404
|
||||
else throw reason;
|
||||
});
|
||||
}
|
||||
@@ -486,18 +487,12 @@ export class CreateApi {
|
||||
await this.run(url, init, ResponseResultProvider.NOOP);
|
||||
}
|
||||
|
||||
private fetchCounter = 0;
|
||||
private async run<T>(
|
||||
requestInfo: URL,
|
||||
init: RequestInit | undefined,
|
||||
resultProvider: ResponseResultProvider = ResponseResultProvider.JSON
|
||||
): Promise<T> {
|
||||
const fetchCount = `[${++this.fetchCounter}]`;
|
||||
const fetchStart = performance.now();
|
||||
const method = init?.method ? `${init.method}: ` : '';
|
||||
const url = requestInfo.toString();
|
||||
const response = await fetch(requestInfo.toString(), init);
|
||||
const fetchEnd = performance.now();
|
||||
if (!response.ok) {
|
||||
let details: string | undefined = undefined;
|
||||
try {
|
||||
@@ -508,18 +503,7 @@ export class CreateApi {
|
||||
const { statusText, status } = response;
|
||||
throw new CreateError(statusText, status, details);
|
||||
}
|
||||
const parseStart = performance.now();
|
||||
const result = await resultProvider(response);
|
||||
const parseEnd = performance.now();
|
||||
console.debug(
|
||||
`HTTP ${fetchCount} ${method}${url} [fetch: ${(
|
||||
fetchEnd - fetchStart
|
||||
).toFixed(2)} ms, parse: ${(parseEnd - parseStart).toFixed(
|
||||
2
|
||||
)} ms] body: ${
|
||||
typeof result === 'string' ? result : JSON.stringify(result)
|
||||
}`
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,13 @@ export function isNotFound(err: unknown): err is NotFoundError {
|
||||
return isErrorWithStatusOf(err, 404);
|
||||
}
|
||||
|
||||
export type UnprocessableContentError = CreateError & { status: 422 };
|
||||
export function isUnprocessableContent(
|
||||
err: unknown
|
||||
): err is UnprocessableContentError {
|
||||
return isErrorWithStatusOf(err, 422);
|
||||
}
|
||||
|
||||
function isErrorWithStatusOf(
|
||||
err: unknown,
|
||||
status: number
|
||||
|
||||
Reference in New Issue
Block a user