Skip to content
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
2 changes: 1 addition & 1 deletion src/Autocomplete/assets/test/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Application } from '@hotwired/stimulus';
import { getByTestId, waitFor } from '@testing-library/dom';
import userEvent from '@testing-library/user-event';
import type TomSelect from 'tom-select';
import { vi } from 'vitest';
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import createFetchMock from 'vitest-fetch-mock';
import AutocompleteController, {
type AutocompleteConnectOptions,
Expand Down
1 change: 1 addition & 0 deletions src/Chartjs/assets/test/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { Application } from '@hotwired/stimulus';
import { waitFor } from '@testing-library/dom';
import { afterEach, beforeAll, describe, expect, it } from 'vitest';
import ChartjsController from '../src/controller';

// Kept track of globally, but just used in one test.
Expand Down
1 change: 1 addition & 0 deletions src/Cropperjs/assets/test/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { Application, Controller } from '@hotwired/stimulus';
import { getByTestId, waitFor } from '@testing-library/dom';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { clearDOM, mountDOM } from '../../../../test/stimulus-helpers';
import CropperjsController from '../src/controller';

Expand Down
1 change: 1 addition & 0 deletions src/Dropzone/assets/test/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { Application, Controller } from '@hotwired/stimulus';
import { getByTestId, waitFor } from '@testing-library/dom';
import user from '@testing-library/user-event';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { clearDOM, mountDOM } from '../../../../test/stimulus-helpers';
import DropzoneController from '../src/controller';

Expand Down
1 change: 1 addition & 0 deletions src/LazyImage/assets/test/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { Application, Controller } from '@hotwired/stimulus';
import { getByTestId, waitFor } from '@testing-library/dom';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { clearDOM, mountDOM } from '../../../../test/stimulus-helpers';
import LazyImageController from '../src/controller';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import RequestBuilder from '../../src/Backend/RequestBuilder';

describe('buildRequest', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/LiveComponent/assets/test/Component/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { waitFor } from '@testing-library/dom';
import { Response } from 'node-fetch';
import { describe, expect, it } from 'vitest';
import type { BackendAction, BackendInterface } from '../../src/Backend/Backend';
import BackendRequest from '../../src/Backend/BackendRequest';
import type BackendResponse from '../../src/Backend/BackendResponse';
Expand All @@ -13,7 +14,7 @@ interface MockBackend extends BackendInterface {
const makeTestComponent = (): { component: Component; backend: MockBackend } => {
const backend: MockBackend = {
actions: [],
makeRequest(data: any, actions: BackendAction[]): BackendRequest {
makeRequest(_data: any, actions: BackendAction[]): BackendRequest {
this.actions = actions;

return new BackendRequest(
Expand Down
1 change: 1 addition & 0 deletions src/LiveComponent/assets/test/ComponentRegistry.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Response } from 'node-fetch';
import { beforeEach, describe, expect, it } from 'vitest';
import type { BackendInterface } from '../src/Backend/Backend';
import BackendRequest from '../src/Backend/BackendRequest';
import Component from '../src/Component';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import { type Directive, parseDirectives } from '../../src/Directive/directives_parser';

const assertDirectiveEquals = (actual: Directive, expected: any) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import { parseDirectives } from '../../src/Directive/directives_parser';
import getModelBinding from '../../src/Directive/get_model_binding';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import ChangingItemsTracker from '../../src/Rendering/ChangingItemsTracker';

describe('ChangingItemsTracker', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import ElementChanges from '../../src/Rendering/ElementChanges';

describe('ElementChanges', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import { htmlToElement } from '../../src/dom_utils';
import ExternalMutationTracker from '../../src/Rendering/ExternalMutationTracker';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import { UnsyncedInputContainer } from '../src/Component/UnsyncedInputsTracker';
import { htmlToElement } from '../src/dom_utils';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import { htmlToElement } from '../../src/dom_utils';
import getElementAsTagText from '../../src/Util/getElementAsTagText';

Expand Down
1 change: 1 addition & 0 deletions src/LiveComponent/assets/test/ValueStore.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import ValueStore from '../src/Component/ValueStore';

describe('ValueStore', () => {
Expand Down
1 change: 1 addition & 0 deletions src/LiveComponent/assets/test/controller/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { getByText, waitFor } from '@testing-library/dom';
import userEvent from '@testing-library/user-event';
import { afterEach, describe, expect, it } from 'vitest';
import { createTest, initComponent, shutdownTests } from '../tools';

describe('LiveController Action Tests', () => {
Expand Down
1 change: 1 addition & 0 deletions src/LiveComponent/assets/test/controller/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* file that was distributed with this source code.
*/

import { afterEach, describe, expect, it } from 'vitest';
import Component from '../../src/Component';
import { findComponents } from '../../src/ComponentRegistry';
import { htmlToElement } from '../../src/dom_utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { getByTestId, waitFor } from '@testing-library/dom';
import userEvent from '@testing-library/user-event';
import { afterEach, describe, expect, it } from 'vitest';
import { createTest, initComponent, shutdownTests } from '../tools';

describe('Component parent -> child data-model binding tests', () => {
Expand Down
1 change: 1 addition & 0 deletions src/LiveComponent/assets/test/controller/child.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { Controller } from '@hotwired/stimulus';
import { getByTestId, waitFor } from '@testing-library/dom';
import userEvent from '@testing-library/user-event';
import { afterEach, describe, expect, it } from 'vitest';
import { findChildren } from '../../src/ComponentRegistry';
import {
createTest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* file that was distributed with this source code.
*/

import { afterEach, describe, expect, it } from 'vitest';
import { createTest, initComponent, shutdownTests } from '../tools';

describe('LiveController Event Dispatching Tests', () => {
Expand Down
1 change: 1 addition & 0 deletions src/LiveComponent/assets/test/controller/emit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import { getByText, waitFor } from '@testing-library/dom';
import { afterEach, describe, expect, it } from 'vitest';
import { createTest, initComponent, shutdownTests } from '../tools';

describe('LiveController Emit Tests', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/LiveComponent/assets/test/controller/error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import { getByText, waitFor } from '@testing-library/dom';
import { afterEach, describe, expect, it } from 'vitest';
import type BackendResponse from '../../src/Backend/BackendResponse';
import { createTest, initComponent, shutdownTests } from '../tools';

Expand Down Expand Up @@ -108,7 +109,7 @@ describe('LiveController Error Handling', () => {
.expectActionCalled('save');

let isHookCalled = false;
test.component.on('response:error', (backendResponse: BackendResponse, controls) => {
test.component.on('response:error', (_backendResponse: BackendResponse, controls) => {
isHookCalled = true;
controls.displayError = false;
});
Expand Down
13 changes: 7 additions & 6 deletions src/LiveComponent/assets/test/controller/loading.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { getByTestId, getByText, waitFor } from '@testing-library/dom';
import userEvent from '@testing-library/user-event';
import { afterEach, describe, expect, it } from 'vitest';
import { createTest, initComponent, shutdownTests } from '../tools';

describe('LiveController data-loading Tests', () => {
Expand All @@ -21,7 +22,7 @@ describe('LiveController data-loading Tests', () => {
{ food: 'pizza' },
(data: any) => `
<div ${initComponent(data)}>
<span>I like: ${data.food}</span>
<span>I like: ${data.food}</span>
<span data-loading="show" data-testid="loading-element">Loading...</span>
</div>
`
Expand Down Expand Up @@ -53,7 +54,7 @@ describe('LiveController data-loading Tests', () => {
{ food: 'pizza' },
(data: any) => `
<div ${initComponent(data)} data-loading="addClass(opacity-20)">
<span>I like: ${data.food}</span>
<span>I like: ${data.food}</span>
<button data-action="live#$render">Re-Render</button>
</div>
`
Expand Down Expand Up @@ -84,7 +85,7 @@ describe('LiveController data-loading Tests', () => {
const test = await createTest(
{},
(data: any) => `
<div ${initComponent(data)}>
<div ${initComponent(data)}>
<span data-loading="action(save)|show" data-testid="loading-element">Loading...</span>
<button data-action="live#action" data-live-action-param="save">Save</button>
Expand Down Expand Up @@ -131,7 +132,7 @@ describe('LiveController data-loading Tests', () => {
const test = await createTest(
{ comments: '', user: { email: '' } },
(data: any) => `
<div ${initComponent(data)}>
<div ${initComponent(data)}>
<textarea data-model="comments"></textarea>
<span data-loading="model(comments)|show" data-testid="comments-loading">Comments change loading...</span>
Expand Down Expand Up @@ -185,7 +186,7 @@ describe('LiveController data-loading Tests', () => {
const test = await createTest(
{},
(data: any) => `
<div ${initComponent(data)}>
<div ${initComponent(data)}>
<span data-loading="action(otherAction)|show" data-testid="loading-element">Loading...</span>
<button data-action="live#action" data-live-action-param="debounce(50)|save">Save</button>
Expand Down Expand Up @@ -215,7 +216,7 @@ describe('LiveController data-loading Tests', () => {
const test = await createTest(
{},
(data: any) => `
<div ${initComponent(data)}>
<div ${initComponent(data)}>
<span data-loading="action(save)|delay(50)|show" data-testid="loading-element">Loading...</span>
<button data-action="live#action" data-live-action-param="save">Save</button>
Expand Down
1 change: 1 addition & 0 deletions src/LiveComponent/assets/test/controller/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { getByLabelText, getByTestId, getByText, waitFor } from '@testing-library/dom';
import userEvent from '@testing-library/user-event';
import { afterEach, describe, expect, it } from 'vitest';
import { createTest, initComponent, shutdownTests } from '../tools';

describe('LiveController data-model Tests', () => {
Expand Down
1 change: 1 addition & 0 deletions src/LiveComponent/assets/test/controller/poll.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { waitFor } from '@testing-library/dom';
import userEvent from '@testing-library/user-event';
import { afterEach, describe, expect, it } from 'vitest';
import { createTest, initComponent, shutdownTests } from '../tools';

describe('LiveController polling Tests', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import { getByText, waitFor } from '@testing-library/dom';
import { afterEach, describe, expect, it } from 'vitest';
import { createTest, expectCurrentSearch, initComponent, setCurrentSearch, shutdownTests } from '../tools';

describe('LiveController query string binding', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import { getByTestId } from '@testing-library/dom';
import { afterEach, describe, expect, it } from 'vitest';
import { htmlToElement } from '../../src/dom_utils';
import { createTest, initComponent, shutdownTests } from '../tools';

Expand Down
15 changes: 8 additions & 7 deletions src/LiveComponent/assets/test/controller/render.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { getByTestId, getByText, waitFor } from '@testing-library/dom';
import userEvent from '@testing-library/user-event';
import { afterEach, describe, expect, it } from 'vitest';
import { htmlToElement } from '../../src/dom_utils';
import { createTest, initComponent, shutdownTests } from '../tools';

Expand Down Expand Up @@ -51,7 +52,7 @@
We want the first to finish, to see if it overwrites our value
-->
<textarea data-model="norender|comment">${data.comment}</textarea>

Title: "${data.title}"
Comment: "${data.comment}"

Expand All @@ -74,7 +75,7 @@
}, 10);

// title model updated like normal
await waitFor(() => expect(test.element).toHaveTextContent('Title: "greetings!!"'));

Check failure on line 78 in src/LiveComponent/assets/test/controller/render.test.ts

View workflow job for this annotation

GitHub Actions / js (22.x)

test/controller/render.test.ts > LiveController rendering Tests > conserves the value of model field that was modified after a render request

Error: expect(element).toHaveTextContent() Expected element to have text content: Title: "greetings!!" Received: Title: "greetings" Comment: "" Reload <html> <head /> <body> <div data-controller="live" data-live-debounce-value="1" data-live-name-value="testing-component" data-live-props-value="{\"title\":\"greetings\",\"comment\":\"\"}" data-live-url-value="http://localhost/components/_test_component_614" > <input data-model="title" value="greetings" /> <!-- norender for comment to avoid triggering a 2nd Ajax call. We want the first to finish, to see if it overwrites our value --> <textarea data-model="norender|comment" /> Title: "greetings" Comment: "" <button data-action="live#$render" > Reload </button> </div> </body> </html> ❯ test/controller/render.test.ts:78:50 ❯ runWithExpensiveErrorDiagnosticsDisabled node_modules/@testing-library/dom/dist/config.js:51:12 ❯ checkCallback node_modules/@testing-library/dom/dist/wait-for.js:127:77 ❯ Timeout.checkRealTimersCallback node_modules/@testing-library/dom/dist/wait-for.js:119:16

// no re-render yet since "comment" was modified
expect(test.element).toHaveTextContent('Comment: ""');
Expand Down Expand Up @@ -213,7 +214,7 @@
(data: any) => `
<div ${initComponent(data)}>
<div data-live-ignore>Inside Ignore Name: <span>${data.firstName}</span></div>

Outside Ignore Name: ${data.firstName}

<button data-action="live#$render">Reload</button>
Expand Down Expand Up @@ -249,7 +250,7 @@
<div id="${data.containerId}">
<div data-live-ignore>Inside Ignore Name: <span>${data.firstName}</span></div>
</div>

Outside Ignore Name: ${data.firstName}

<button data-action="live#$render">Reload</button>
Expand Down Expand Up @@ -491,8 +492,8 @@
// correctly delayed, the "first render finish" and "second render
// start" times could be the same, because no time has passed.
const sleep = (milliseconds: number) => {
const startTime = new Date().getTime();
while (new Date().getTime() < startTime + milliseconds);
const startTime = Date.now();
while (Date.now() < startTime + milliseconds);
};
sleep(10);
});
Expand Down Expand Up @@ -585,7 +586,7 @@
<option value="2">Two</option>
<option value="3">Three</option>
</select>

<select id="select_option_2">
<option value="">Choose option 2</option>
<option value="1_1">One - One</option>
Expand All @@ -610,7 +611,7 @@
<option value="2" selected>Two</option>
<option value="3">Three</option>
</select>

<select id="select_option_2">
<option value="">Choose option 2</option>
<option value="2_1">Two - One</option>
Expand Down
1 change: 1 addition & 0 deletions src/LiveComponent/assets/test/dom_utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import Backend from '../src/Backend/Backend';
import Component from '../src/Component';
import ValueStore from '../src/Component/ValueStore';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import { htmlToElement } from '../src/dom_utils';
import { normalizeAttributesForComparison } from '../src/normalize_attributes_for_comparison';

Expand Down
1 change: 1 addition & 0 deletions src/LiveComponent/assets/test/string_utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import { combineSpacedArray, normalizeModelName } from '../src/string_utils';

describe('combinedSpacedArray', () => {
Expand Down
1 change: 1 addition & 0 deletions src/LiveComponent/assets/test/tools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Application } from '@hotwired/stimulus';
import { waitFor } from '@testing-library/dom';
import { Response } from 'node-fetch';
import { expect } from 'vitest';
import type { BackendAction, BackendInterface, ChildrenFingerprints } from '../src/Backend/Backend';
import BackendRequest from '../src/Backend/BackendRequest';
import Component from '../src/Component';
Expand Down Expand Up @@ -34,7 +35,7 @@
const shutdownTest = (test: FunctionalTest) => {
test.pendingAjaxCallsThatAreStillExpected().forEach((mock) => {
const requestInfo = mock.getVisualSummary();
throw new Error(`EXPECTED request was never made matching the following info: \n${requestInfo.join('\n')}`);

Check failure on line 38 in src/LiveComponent/assets/test/tools.ts

View workflow job for this annotation

GitHub Actions / js (22.x)

test/controller/render.test.ts > LiveController rendering Tests > cancels a re-render if the page is navigating away

Error: EXPECTED request was never made matching the following info: PROPS: {"title":"greetings","comment":""} ACTIONS: [] UPDATED: {"title":"greetings!!"} CHILDREN: null UPDATED PROPS FROM PARENT: null ❯ test/tools.ts:38:15 ❯ shutdownTest test/tools.ts:36:49 ❯ test/tools.ts:31:9 ❯ Module.shutdownTests test/tools.ts:30:11 ❯ test/controller/render.test.ts:18:9

Check failure on line 38 in src/LiveComponent/assets/test/tools.ts

View workflow job for this annotation

GitHub Actions / js (22.x)

test/controller/render.test.ts > LiveController rendering Tests > overwrites HTML instead of morph with data-skip-morph

Error: EXPECTED request was never made matching the following info: PROPS: {"title":"greetings","comment":""} ACTIONS: [] UPDATED: {"title":"greetings!!"} CHILDREN: null UPDATED PROPS FROM PARENT: null ❯ test/tools.ts:38:15 ❯ shutdownTest test/tools.ts:36:49 ❯ test/tools.ts:31:9 ❯ Module.shutdownTests test/tools.ts:30:11 ❯ test/controller/render.test.ts:18:9

Check failure on line 38 in src/LiveComponent/assets/test/tools.ts

View workflow job for this annotation

GitHub Actions / js (22.x)

test/controller/render.test.ts > LiveController rendering Tests > if id changes, data-live-ignore elements ARE re-rendered

Error: EXPECTED request was never made matching the following info: PROPS: {"title":"greetings","comment":""} ACTIONS: [] UPDATED: {"title":"greetings!!"} CHILDREN: null UPDATED PROPS FROM PARENT: null ❯ test/tools.ts:38:15 ❯ shutdownTest test/tools.ts:36:49 ❯ test/tools.ts:31:9 ❯ Module.shutdownTests test/tools.ts:30:11 ❯ test/controller/render.test.ts:18:9

Check failure on line 38 in src/LiveComponent/assets/test/tools.ts

View workflow job for this annotation

GitHub Actions / js (22.x)

test/controller/render.test.ts > LiveController rendering Tests > does not render over elements with data-live-ignore

Error: EXPECTED request was never made matching the following info: PROPS: {"title":"greetings","comment":""} ACTIONS: [] UPDATED: {"title":"greetings!!"} CHILDREN: null UPDATED PROPS FROM PARENT: null ❯ test/tools.ts:38:15 ❯ shutdownTest test/tools.ts:36:49 ❯ test/tools.ts:31:9 ❯ Module.shutdownTests test/tools.ts:30:11 ❯ test/controller/render.test.ts:18:9

Check failure on line 38 in src/LiveComponent/assets/test/tools.ts

View workflow job for this annotation

GitHub Actions / js (22.x)

test/controller/render.test.ts > LiveController rendering Tests > uses the new value of an unmapped field that was NOT modified even if active

Error: EXPECTED request was never made matching the following info: PROPS: {"title":"greetings","comment":""} ACTIONS: [] UPDATED: {"title":"greetings!!"} CHILDREN: null UPDATED PROPS FROM PARENT: null ❯ test/tools.ts:38:15 ❯ shutdownTest test/tools.ts:36:49 ❯ test/tools.ts:31:9 ❯ Module.shutdownTests test/tools.ts:30:11 ❯ test/controller/render.test.ts:18:9

Check failure on line 38 in src/LiveComponent/assets/test/tools.ts

View workflow job for this annotation

GitHub Actions / js (22.x)

test/controller/render.test.ts > LiveController rendering Tests > conserves cursor position of active model element

Error: EXPECTED request was never made matching the following info: PROPS: {"title":"greetings","comment":""} ACTIONS: [] UPDATED: {"title":"greetings!!"} CHILDREN: null UPDATED PROPS FROM PARENT: null ❯ test/tools.ts:38:15 ❯ shutdownTest test/tools.ts:36:49 ❯ test/tools.ts:31:9 ❯ Module.shutdownTests test/tools.ts:30:11 ❯ test/controller/render.test.ts:18:9

Check failure on line 38 in src/LiveComponent/assets/test/tools.ts

View workflow job for this annotation

GitHub Actions / js (22.x)

test/controller/render.test.ts > LiveController rendering Tests > conserves the value of an unmapped field that was modified after a render request

Error: EXPECTED request was never made matching the following info: PROPS: {"title":"greetings","comment":""} ACTIONS: [] UPDATED: {"title":"greetings!!"} CHILDREN: null UPDATED PROPS FROM PARENT: null ❯ test/tools.ts:38:15 ❯ shutdownTest test/tools.ts:36:49 ❯ test/tools.ts:31:9 ❯ Module.shutdownTests test/tools.ts:30:11 ❯ test/controller/render.test.ts:18:9

Check failure on line 38 in src/LiveComponent/assets/test/tools.ts

View workflow job for this annotation

GitHub Actions / js (22.x)

test/controller/render.test.ts > LiveController rendering Tests > conserves the value of model field that was modified after a render request

Error: EXPECTED request was never made matching the following info: PROPS: {"title":"greetings","comment":""} ACTIONS: [] UPDATED: {"title":"greetings!!"} CHILDREN: null UPDATED PROPS FROM PARENT: null ❯ test/tools.ts:38:15 ❯ shutdownTest test/tools.ts:36:49 ❯ test/tools.ts:31:9 ❯ Module.shutdownTests test/tools.ts:30:11 ❯ test/controller/render.test.ts:18:9
});
};

Expand Down Expand Up @@ -130,7 +131,7 @@
});
}

throw new Error(`An AJAX call was made that was not expected: \n${requestInfo.join('\n')}`);

Check failure on line 134 in src/LiveComponent/assets/test/tools.ts

View workflow job for this annotation

GitHub Actions / js (22.x)

Unhandled error

Error: An AJAX call was made that was not expected: ACTUAL REQUEST INFO: PROPS: {"title":"greetings","comment":""} ACTIONS: [] UPDATED: {"title":"greetings!!","comment":"I had a great time"} CHILDREN: {} UPDATED PROPS FROM PARENT: {} EXPECTED REQUEST #1: PROPS: {"title":"greetings","comment":""} ACTIONS: [] UPDATED: {"title":"greetings!!"} CHILDREN: null UPDATED PROPS FROM PARENT: null ❯ MockedBackend.makeRequest test/tools.ts:134:19 ❯ Component.performRequest src/Component/index.ts:287:44 ❯ Component.tryStartingRequest src/Component/index.ts:252:18 ❯ Component.render src/Component/index.ts:201:14 ❯ Timeout._onTimeout src/Component/index.ts:467:18 ❯ listOnTimeout node:internal/timers:588:17 ❯ processTimers node:internal/timers:523:7 This error originated in "test/controller/render.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "conserves the value of model field that was modified after a render request". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
}

// remove the matched mock from the list of expected calls
Expand Down
1 change: 1 addition & 0 deletions src/LiveComponent/assets/test/url_utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* file that was distributed with this source code.
*/

import { afterEach, beforeAll, beforeEach, describe, expect, it } from 'vitest';
import { HistoryStrategy, UrlUtils } from '../src/url_utils';

describe('url_utils', () => {
Expand Down
1 change: 1 addition & 0 deletions src/Map/assets/test/abstract_map_controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Application } from '@hotwired/stimulus';
import { getByTestId, waitFor } from '@testing-library/dom';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { clearDOM, mountDOM } from '../../../../test/stimulus-helpers';
import AbstractMapController from '../src/abstract_map_controller.ts';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@

import { Application, Controller } from '@hotwired/stimulus';
import { getByTestId, waitFor } from '@testing-library/dom';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { clearDOM, mountDOM } from '../../../../../../../test/stimulus-helpers';
import GoogleController from '../src/map_controller';

// Controller used to check the actual controller was properly booted
class CheckController extends Controller {
connect() {
this.element.addEventListener('ux:map:pre-connect', (event) => {
this.element.addEventListener('ux:map:pre-connect', (_event) => {
this.element.classList.add('pre-connected');
});

this.element.addEventListener('ux:map:connect', (event) => {
this.element.addEventListener('ux:map:connect', (_event) => {
this.element.classList.add('connected');
});
}
Expand Down
Loading
Loading