Skip to content

Commit

Permalink
🚀 3.8.1, #194
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail authored Aug 23, 2023
2 parents 50370f6 + 7f4bfa7 commit 1f04e4f
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 191 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Version 3

### 3.8.1

- A couple fixes for the upcoming switch popover:
- The outside clicks handler is removed, so dismissing the popover is now only possible by clicking the Close button.
- Restoring the regular tooltip after dismissing the popover.

### 3.8.0

- Improved logging:
Expand Down
2 changes: 1 addition & 1 deletion octoprint_octorelay/templates/octorelay_navbar.jinja2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% for n in range(1,9) %}
<a id="relaisr{{n}}" title="relay {{n}}" role="button" style="display: none">
<a id="relaisr{{n}}" role="button" style="display: none">
R{{n}}
</a>
{% endfor %}
Expand Down
16 changes: 8 additions & 8 deletions tests/snapshots/snap_test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@
snapshots = Snapshot()

snapshots['TestTemplates::test_templates octorelay_navbar.jinja2'] = '''
<a id="relaisr1" title="relay 1" role="button" style="display: none">
<a id="relaisr1" role="button" style="display: none">
R1
</a>
<a id="relaisr2" title="relay 2" role="button" style="display: none">
<a id="relaisr2" role="button" style="display: none">
R2
</a>
<a id="relaisr3" title="relay 3" role="button" style="display: none">
<a id="relaisr3" role="button" style="display: none">
R3
</a>
<a id="relaisr4" title="relay 4" role="button" style="display: none">
<a id="relaisr4" role="button" style="display: none">
R4
</a>
<a id="relaisr5" title="relay 5" role="button" style="display: none">
<a id="relaisr5" role="button" style="display: none">
R5
</a>
<a id="relaisr6" title="relay 6" role="button" style="display: none">
<a id="relaisr6" role="button" style="display: none">
R6
</a>
<a id="relaisr7" title="relay 7" role="button" style="display: none">
<a id="relaisr7" role="button" style="display: none">
R7
</a>
<a id="relaisr8" title="relay 8" role="button" style="display: none">
<a id="relaisr8" role="button" style="display: none">
R8
</a>
Expand Down
9 changes: 6 additions & 3 deletions ts/OctoPrint.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ interface JQuery {
| "toggle"
| "hide"
| "show"
| { placement?: "top" | "bottom" | "left" | "right" }
);
| {
placement?: "top" | "bottom" | "left" | "right";
title?: string;
}
): JQuery;
popover(
option:
| "destroy"
Expand All @@ -24,7 +27,7 @@ interface JQuery {
title?: string;
content?: string;
}
);
): JQuery;
}

interface ViewModel {
Expand Down
85 changes: 5 additions & 80 deletions ts/__snapshots__/octorelay.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,6 @@ exports[`OctoRelayViewModel Message handler should process the supplied configur
]
`;

exports[`OctoRelayViewModel Message handler should process the supplied configuration: .attr() 1`] = `
[
[
"title",
"Nozzle Light",
],
[
"title",
"Printer",
],
[
"title",
"Fan",
],
[
"title",
"Chassis Light",
],
[
"title",
"R5",
],
]
`;

exports[`OctoRelayViewModel Message handler should process the supplied configuration: .find() 1`] = `
[
[
Expand Down Expand Up @@ -123,61 +98,6 @@ exports[`OctoRelayViewModel Message handler should process the supplied configur
]
`;
exports[`OctoRelayViewModel Message handler should process the supplied configuration: .removeAttr() 1`] = `
[
[
"data-original-title",
],
[
"title",
],
[
"data-original-title",
],
[
"title",
],
[
"data-original-title",
],
[
"title",
],
[
"data-original-title",
],
[
"title",
],
[
"data-original-title",
],
[
"title",
],
]
`;
exports[`OctoRelayViewModel Message handler should process the supplied configuration: .removeData() 1`] = `
[
[
"original-title",
],
[
"original-title",
],
[
"original-title",
],
[
"original-title",
],
[
"original-title",
],
]
`;
exports[`OctoRelayViewModel Message handler should process the supplied configuration: .text() 1`] = `
[
[
Expand Down Expand Up @@ -217,6 +137,7 @@ exports[`OctoRelayViewModel Message handler should process the supplied configur
[
{
"placement": "bottom",
"title": "Nozzle Light",
},
],
[
Expand All @@ -225,6 +146,7 @@ exports[`OctoRelayViewModel Message handler should process the supplied configur
[
{
"placement": "bottom",
"title": "Printer",
},
],
[
Expand All @@ -233,6 +155,7 @@ exports[`OctoRelayViewModel Message handler should process the supplied configur
[
{
"placement": "bottom",
"title": "Fan",
},
],
[
Expand All @@ -241,6 +164,7 @@ exports[`OctoRelayViewModel Message handler should process the supplied configur
[
{
"placement": "bottom",
"title": "Chassis Light",
},
],
[
Expand All @@ -249,6 +173,7 @@ exports[`OctoRelayViewModel Message handler should process the supplied configur
[
{
"placement": "bottom",
"title": "R5",
},
],
]
Expand Down
47 changes: 7 additions & 40 deletions ts/octorelay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ describe("OctoRelayViewModel", () => {
const elementMock: Record<
| "toggle"
| "html"
| "attr"
| "removeAttr"
| "removeData"
| "off"
| "on"
| "find"
Expand All @@ -21,9 +18,6 @@ describe("OctoRelayViewModel", () => {
> = {
toggle: jest.fn(() => elementMock),
html: jest.fn(() => elementMock),
attr: jest.fn(() => elementMock),
removeAttr: jest.fn(() => elementMock),
removeData: jest.fn(() => elementMock),
off: jest.fn(() => elementMock),
on: jest.fn(() => elementMock),
find: jest.fn(() => elementMock),
Expand Down Expand Up @@ -78,6 +72,7 @@ describe("OctoRelayViewModel", () => {
afterEach(() => {
MockDate.set("2023-08-13T22:30:00");
jQueryMock.mockClear();
elementMock.tooltip.mockClear();
elementMock.popover.mockClear();
elementMock.on.mockClear();
elementMock.text.mockClear();
Expand Down Expand Up @@ -170,9 +165,6 @@ describe("OctoRelayViewModel", () => {
expect(jQueryMock.mock.calls).toMatchSnapshot("$()");
expect(elementMock.toggle.mock.calls).toMatchSnapshot(".toggle()");
expect(elementMock.html.mock.calls).toMatchSnapshot(".html()");
expect(elementMock.removeAttr.mock.calls).toMatchSnapshot(".removeAttr()");
expect(elementMock.removeData.mock.calls).toMatchSnapshot(".removeData()");
expect(elementMock.attr.mock.calls).toMatchSnapshot(".attr()");
expect(elementMock.tooltip.mock.calls).toMatchSnapshot(".tooltip()");
expect(elementMock.popover.mock.calls).toMatchSnapshot(".popover()");
expect(elementMock.off).toHaveBeenCalledTimes(5);
Expand Down Expand Up @@ -246,35 +238,6 @@ describe("OctoRelayViewModel", () => {
}
);

test("Should display upcoming state popover (%s sec delay)", () => {
const handler = (registry[0].construct as OwnModel & OwnProperties)
.onDataUpdaterPluginMessage;
handler("octorelay", {
r1: {
relay_pin: 16,
inverted_output: false,
relay_state: true,
label_text: "Nozzle Light",
active: true,
icon_html: "<div>&#128161;</div>",
confirm_off: false,
upcoming: {
target: false,
owner: "PRINTING_STOPPED",
deadline: Date.now() + 20 * 1000,
},
},
});
expect(addEventListenerMock).toHaveBeenCalledWith(
"click",
expect.any(Function)
);
const listener = addEventListenerMock.mock.calls[0][1];
listener({ target: "targetMock" });
expect(elementMock.popover).toHaveBeenCalledWith("hide");
expect(removeEventListenerMock).toHaveBeenCalledWith("click", listener);
});

test.each([true, false])("Should set countdown %#", (isVisible) => {
const handler = (registry[0].construct as OwnModel & OwnProperties)
.onDataUpdaterPluginMessage;
Expand Down Expand Up @@ -338,7 +301,7 @@ describe("OctoRelayViewModel", () => {
});
});

test("Clicking on Cancel button should send the command", () => {
test("Clicking on Close button should close the popover", () => {
const handler = (registry[0].construct as OwnModel & OwnProperties)
.onDataUpdaterPluginMessage;
handler("octorelay", {
Expand All @@ -360,8 +323,12 @@ describe("OctoRelayViewModel", () => {
expect(elementMock.on).toHaveBeenCalledTimes(3); // controlBtn, closeBtn, cancelBtn
const closeHandler = elementMock.on.mock.calls[1][1];
closeHandler();
expect(elementMock.popover).toHaveBeenCalledWith("hide");
expect(elementMock.popover).toHaveBeenCalledWith("destroy");
expect(clearIntervalMock).toHaveBeenCalledWith("mockedInterval");
expect(elementMock.tooltip).toHaveBeenCalledWith({
placement: "bottom",
title: "Nozzle Light",
});
});

test.each([
Expand Down
Loading

0 comments on commit 1f04e4f

Please sign in to comment.