Skip to content

Commit 3534f03

Browse files
Merge branch 'master' into patch-1
2 parents 8af1cf2 + 8fbcb15 commit 3534f03

16 files changed

Lines changed: 70 additions & 20 deletions

dist/cypress-commands.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import IServerInvoke from "./types/IServerInvoke";
22
export declare function setupCypressCommands(): void;
3-
export declare function hubPublish(hubName: string, messageType: string, payload: any): void;
3+
export declare function hubPublish(hubName: string, messageType: string, ...payload: any[]): void;
44
export declare function hubVerify(hubName: string, messageType: string, callback?: (invokes: IServerInvoke[]) => void): void;
55
export declare function hubPrintData(): void;
66
export declare function hubClear(): void;

dist/index.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { HubConnection } from "@microsoft/signalr";
22
import IMockData from "./types/IMockData";
33
import IServerInvoke from "./types/IServerInvoke";
4+
/**
5+
* Initializes a mock SignalR HubConnection when running in Cypress
6+
* or when enableForVitest is true and running in Vitest
7+
* @param name
8+
* @param debug
9+
* @param enableForVitest
10+
*/
411
export declare function useCypressSignalRMock(name: string, { debug, enableForVitest, }?: Partial<{
512
debug?: boolean;
613
enableForVitest?: boolean;
@@ -20,7 +27,7 @@ declare global {
2027
* @param messageType The name of the message type
2128
* @param payload The payload to send with the action
2229
*/
23-
hubPublish(hubName: string, messageType: string, payload: any): Chainable<Subject>;
30+
hubPublish(hubName: string, messageType: string, ...payload: any[]): Chainable<Subject>;
2431
/**
2532
* Verifies that a message was sent from the Client => Server
2633
* @param hubName The name of the hub

dist/index.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.umd.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/index.umd.cjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types/HubConnectionMock.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class HubConnectionMock {
99
private _serverInvokes;
1010
name: string;
1111
constructor(name: string);
12-
publish(messageType: string, value: any): void;
12+
publish(messageType: string, ...values: any[]): void;
1313
verify(messageType: string, callback?: (invokes: IServerInvoke[]) => void): void;
1414
/** Registers a handler that will be invoked when the hub method with the specified method name is invoked.
1515
*

dist/types/IPayload.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export default interface IPayload {
22
name: string;
3-
value: any;
3+
values: any[];
44
}

playground/cypress/e2e/hub-publish.cy.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,17 @@ describe("cy.hubPublish demo", () => {
1515
});
1616
});
1717
});
18+
19+
it("Should sending message whith multiple cy.hubPublish parameters", () => {
20+
cy.visit("http://localhost:3030/");
21+
cy.get('[data-cy="page-load-completed"]', { timeout: 10000 }).then(() => {
22+
cy.hubPublish("demo-hub", "message", "info", "Info", "This is an info message");
23+
cy.wait(500);
24+
cy.get(".p-toast-message-info").should("exist").and("contain.text", "This is an info message").then(() => {
25+
cy.hubPublish("demo-hub", "message", "error", "Error", "This is an error message");
26+
cy.wait(500);
27+
cy.get(".p-toast-message-error").should("exist").and("contain.text", "This is an error message")
28+
});
29+
});
30+
});
1831
});

playground/src/pages/index.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<div>
3+
<Toast/>
34
<h2>Loading something from the back-end</h2>
45
<ProgressBar data-cy="progress-bar" :value="progressValue" />
56
</div>
@@ -10,8 +11,11 @@ import { useCypressSignalRMock } from "../../../src";
1011
import { HubConnectionBuilder } from "@microsoft/signalr";
1112
import { onMounted, ref } from "vue";
1213
import Log from "consola";
14+
import { useToast } from "primevue/usetoast";
1315
16+
const toast = useToast();
1417
const progressValue = ref(0);
18+
1519
onMounted(() => {
1620
const connection =
1721
useCypressSignalRMock("demo-hub") ??
@@ -29,6 +33,10 @@ onMounted(() => {
2933
connection.on("progress", (value) => {
3034
progressValue.value = value;
3135
});
36+
37+
connection.on("message", (severity, summary, detail) => {
38+
toast.add({severity: severity, summary: summary, detail: detail});
39+
});
3240
});
3341
3442
console.log("demo-hub signalR has been set-up!");

0 commit comments

Comments
 (0)