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

fix(i-data): componentStatus updating after component destroying #1445

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Changelog

_Note: Gaps between patch versions are faulty, broken or test releases._

## v4.0.0-beta.?? (2024-10-??)

#### :bug: Bug Fix

* Fixed an issue with updating the `componentStatus` after destroying the component `components/super/i-data`
shining-mind marked this conversation as resolved.
Show resolved Hide resolved

## v4.0.0-beta.142 (2024-10-04)

#### :bug: Bug Fix
Expand Down
6 changes: 6 additions & 0 deletions src/components/super/i-data/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Changelog
> - :house: [Internal]
> - :nail_care: [Polish]

## v4.0.0-beta.?? (2024-10-??)

#### :bug: Bug Fix

* Fixed an issue with updating the `componentStatus` after destroying the component

## v4.0.0-beta.30 (2023-10-11)

#### :bug: Bug Fix
Expand Down
2 changes: 1 addition & 1 deletion src/components/super/i-data/i-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default abstract class iData extends iDataHandlers {
join: 'replace'
};

const callSuper = () => super.initLoad(() => this.db, opts);
const callSuper = $a.proxy(() => super.initLoad(() => this.db, opts));

try {
if (opts.emitStartEvent !== false) {
Expand Down
39 changes: 39 additions & 0 deletions src/components/super/i-data/test/unit/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*!
* V4Fire Client Core
* https://github.com/V4Fire/Client
*
* Released under the MIT license
* https://github.com/V4Fire/Client/blob/master/LICENSE
*/

import test from 'tests/config/unit/test';
import { Component, RequestInterceptor } from 'tests/helpers';

test.describe('<i-data> component', () => {
test.beforeEach(async ({demoPage}) => {
await demoPage.goto();
});

test('should not update the `componentStatus` if the component was destroyed during the loading', async ({page}) => {
const interceptor = new RequestInterceptor(page, /api/);
await interceptor
.response(200, {root: true}, {delay: 100})
.start();

const target = await Component.createComponent(page, 'b-dummy', {
attrs: {
dataProvider: 'Provider'
}
});

const mockStatusChange = await target.evaluateHandle(() => jestMock.mock());
shining-mind marked this conversation as resolved.
Show resolved Hide resolved

await target.evaluate((ctx, mockStatusChange) => {
ctx.on('onComponentStatusChange', mockStatusChange);

ctx.unsafe.$destroy();
}, mockStatusChange);

test.expect(await mockStatusChange.evaluate((fn) => fn.mock.calls)).toEqual([['destroyed', 'loading']]);
});
});
Loading