TicTacMan
TicTacMan
SSolidJS
Created by TicTacMan on 10/27/2023 in #support
Testing conditional rendering in child component
No worries, do you know if there is some kind of playground environment where I can try to mimic this setup for you?
8 replies
SSolidJS
Created by TicTacMan on 10/27/2023 in #support
Testing conditional rendering in child component
Replaced the expect with this:
expect(await screen.findByText(/"TOAST SHOWING"/i)).toBeInTheDocument();
expect(await screen.findByText(/"TOAST SHOWING"/i)).toBeInTheDocument();
Still fails...
8 replies
SSolidJS
Created by TicTacMan on 10/27/2023 in #support
Testing conditional rendering in child component
No description
8 replies
SSolidJS
Created by TicTacMan on 10/27/2023 in #support
Testing conditional rendering in child component
This is my test:
it("if saving is not successful, the user should be notified", async () => {
mocks.fireApiCall.mockImplementation(
(
division: string,
dataEndpoint: string,
action: BcAction,
entityId?: string,
getProperties?: string[],
body?: Record<string, any>
) => {
console.log("dataendpoint: " + dataEndpoint);

if (dataEndpoint === "/dummy/api") {
console.log("throwing error now");
throw new Error("Error!");
}
console.log("Not throwing error");
return data;
}
);

const { container, unmount } = await renderComponent({});

const saveButton = screen.getByRole("button", {
name: /save/i,
});

// User event
await userEvent.click(saveButton);

// Assert
expect(screen.queryByText("not showing toast")).not.toBeInTheDocument();
});
it("if saving is not successful, the user should be notified", async () => {
mocks.fireApiCall.mockImplementation(
(
division: string,
dataEndpoint: string,
action: BcAction,
entityId?: string,
getProperties?: string[],
body?: Record<string, any>
) => {
console.log("dataendpoint: " + dataEndpoint);

if (dataEndpoint === "/dummy/api") {
console.log("throwing error now");
throw new Error("Error!");
}
console.log("Not throwing error");
return data;
}
);

const { container, unmount } = await renderComponent({});

const saveButton = screen.getByRole("button", {
name: /save/i,
});

// User event
await userEvent.click(saveButton);

// Assert
expect(screen.queryByText("not showing toast")).not.toBeInTheDocument();
});
8 replies
SSolidJS
Created by TicTacMan on 9/6/2023 in #support
Detect which dependency changed when using "on" utility with createEffect
Extra question, is there any better way for me to track only particular properties of a store? I feel like what im doing here:
triggerFields.forEach((_trigger) => dataStore[_trigger]);
triggerFields.forEach((_trigger) => dataStore[_trigger]);
Might not be the best way to do it
3 replies
SSolidJS
Created by TicTacMan on 9/5/2023 in #support
Is it possible to subscribe to particular properties in a object wrapped by a store?
The issue with my current example is that I need to maintain a separate array called "changedFields". Because on initial render, I would like field 3 to be empty since none of its dependencies have changed. the If I had access to the old value of the store, I would not need changedFields
10 replies
SSolidJS
Created by TicTacMan on 9/5/2023 in #support
Is it possible to subscribe to particular properties in a object wrapped by a store?
In this case, input field 3 depends on data properties 50-55. Input field 1 changes property value 51 (so a change in field 1 should trigger an API call) and input field 2 changes property value 66 (a change in field 2 should not trigger an API call)
10 replies
SSolidJS
Created by TicTacMan on 9/5/2023 in #support
Is it possible to subscribe to particular properties in a object wrapped by a store?
Just a short description of what im trying to do: The third input field is a calculated field whose dependencies are supplied via an array called dependencies. Now I want to trigger an API call whenever any of the dependencies of the third field change
10 replies
SSolidJS
Created by TicTacMan on 9/5/2023 in #support
Is it possible to subscribe to particular properties in a object wrapped by a store?
10 replies
SSolidJS
Created by TicTacMan on 9/5/2023 in #support
Is it possible to subscribe to particular properties in a object wrapped by a store?
Do you know if there is a way to access the old value of store?
10 replies
SSolidJS
Created by TicTacMan on 9/5/2023 in #support
Is it possible to subscribe to particular properties in a object wrapped by a store?
Hi, thanks for the explanation!
10 replies
SSolidJS
Created by TicTacMan on 8/31/2023 in #support
Is it possible to untrack writes to a signal?
Just an update, works perfectly for my use case
12 replies
SSolidJS
Created by TicTacMan on 8/31/2023 in #support
Is it possible to untrack writes to a signal?
This might actually work really well for my use case, ill give it a shot
12 replies
SSolidJS
Created by TicTacMan on 8/31/2023 in #support
Is it possible to untrack writes to a signal?
Yeah Ideally I would have just created a signal for the value attribute of my input field, and in my function, directly manipulated that signal. However, my page is pretty dynamic and sometimes the page could have upwards of 100+ input fields (think of an accountancy sales order entry page). So I wanted to stay away from any solution in which each field has its own signal, because im not sure about the performance implications of having 100+ signals on my page
12 replies
SSolidJS
Created by TicTacMan on 8/31/2023 in #support
Is it possible to untrack writes to a signal?
Yeah I was looking into that, but the docs state that untrack only untracks the reads and not writes. https://www.solidjs.com/tutorial/reactivity_untrack The problem for me is that since I set (write) the signal back to false in my function, it triggers a re-render
12 replies