Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issues with reexports and bad import async #1127

Merged
merged 4 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@ _Note: Gaps between patch versions are faulty, broken or test releases._
#### :boom: Breaking Change

* Removed `shouldPerformDataRequest` prop in `b-virtual-scroll-new` `base/b-virtual-scroll-new`
* `tests/helpers/network/interceptor` no longer has a named export, the `RequestInterceptor` class is now exported as the default export `tests/helpers/network/interceptor`

#### :rocket: New Feature

* Added `preloadAmount` prop in b`-virtual-scroll-new` `base/b-virtual-scroll-new`

#### :house: Internal

* Added re-export of modules from `tests/helpers`:
- Request
- RequestInterceptor
- Mock

* Removed bad import of async module from `tests/helpers/network/interceptor`

## v3.65.1 (2024-02-13)

#### :bug: Bug Fix
Expand Down
2 changes: 1 addition & 1 deletion src/base/b-virtual-scroll-new/test/api/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { MountedChild, ComponentItem, VirtualScrollState, MountedItem } fro
import { componentEvents, componentObserverLocalEvents } from 'base/b-virtual-scroll-new/const';

import { paginationHandler } from 'tests/network-interceptors/pagination';
import { RequestInterceptor } from 'tests/helpers/network/interceptor';
import { RequestInterceptor } from 'tests/helpers';

import { VirtualScrollComponentObject } from 'base/b-virtual-scroll-new/test/api/component-object';
import type { DataConveyor, DataItemCtor, MountedItemCtor, StateApi, VirtualScrollTestHelpers, MountedSeparatorCtor, IndexedObj } from 'base/b-virtual-scroll-new/test/api/helpers/interface';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import type { ComponentItem, VirtualScrollState, MountedChild, MountedItem } from 'base/b-virtual-scroll-new/interface';

import type { SpyObject } from 'tests/helpers/mock/interface';
import type { RequestInterceptor } from 'tests/helpers/network/interceptor';
import type { RequestInterceptor } from 'tests/helpers';
import type { VirtualScrollComponentObject } from 'base/b-virtual-scroll-new/test/api/component-object';

/**
Expand Down
7 changes: 6 additions & 1 deletion tests/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,22 @@ import Scroll from 'tests/helpers/scroll';
import Router from 'tests/helpers/router';
import Request from 'tests/helpers/request';
import Gestures from 'tests/helpers/gestures';
import RequestInterceptor from 'tests/helpers/network/interceptor';
import * as Mock from 'tests/helpers/mock';

export {

BOM,
DOM,
Utils,
Component,
Request,
ComponentObject,
Scroll,
Router,
Gestures
Gestures,
RequestInterceptor,
Mock

};

Expand Down
15 changes: 5 additions & 10 deletions tests/helpers/network/interceptor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* https://github.com/V4Fire/Client/blob/master/LICENSE
*/

import Async from '@v4fire/core/core/async';
import type { BrowserContext, Page, Request, Route } from 'playwright';
import delay from 'delay';
import { ModuleMocker } from 'jest-mock';
Expand All @@ -18,7 +17,7 @@ import type { InterceptedRequest, ResponseHandler, ResponseOptions, ResponsePayl
/**
* API that provides a simple way to intercept and respond to any request.
*/
export class RequestInterceptor {
export default class RequestInterceptor {
/**
* The route context.
*/
Expand All @@ -39,11 +38,6 @@ export class RequestInterceptor {
*/
readonly mock: ReturnType<ModuleMocker['fn']>;

/**
* {@link Async}
*/
protected readonly async: Async = new Async();

/**
* If true, intercepted requests are not automatically responded to, instead use the
* {@link RequestInterceptor.respond} method.
Expand Down Expand Up @@ -125,9 +119,10 @@ export class RequestInterceptor {
throw new Error('Failed to call respond on an instance that is not a responder');
}

if (this.requestQueueLength === 0) {
await this.async.wait(() => this.requestQueueLength > 0);
}
do {
await delay(16);

} while (this.requestQueueLength === 0)

return this.respondQueue.shift()?.();
}
Expand Down
Loading