-
-
Notifications
You must be signed in to change notification settings - Fork 801
Adding support for protocol handler #3870
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
Open
marcellintacite
wants to merge
17
commits into
conversejs:master
Choose a base branch
from
marcellintacite:add-protocol-handler
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+311
−3
Open
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2ba6ada
Adding support for protocol handler
marcellintacite 9c5f20d
Move protocol handler into chatView and update the route to chat func…
marcellintacite 5b41936
Adding support for the XEP-0147 (Protocol handler)
marcellintacite be0d75c
Update src/plugins/chatview/utils.js
marcellintacite a32cec0
Update src/plugins/chatview/utils.js
marcellintacite 956b471
Update src/plugins/chatview/utils.js
marcellintacite 40f8f7f
Updating the DOAP, updating url
marcellintacite 29af0c9
Adding test for the routeToQuestionAction function
marcellintacite 80114ef
Merge branch 'conversejs:master' into add-protocol-handler
marcellintacite 40538e3
Update CHANGES.md
marcellintacite 71e9037
Updating the doap file
marcellintacite baaced6
Update manifest.json
marcellintacite ff769df
Removing the protocol handler (?uri=...)
marcellintacite 0e3175b
Fix: Adding routeToQuery in the u object
marcellintacite a22c1a0
Fix: Adding routeToQuery in the u object
marcellintacite 8c91e48
Fixing tests
marcellintacite cd88326
chore: remove genkit metadata
marcellintacite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| /*global mock, converse */ | ||
|
|
||
| const { u } = converse.env; | ||
|
|
||
| describe("XMPP URI Query Actions (XEP-0147)", function () { | ||
|
|
||
| /** | ||
| * Test the core functionality: opening a chat when no action is specified | ||
| * This tests the basic URI parsing and chat opening behavior | ||
| */ | ||
| fit("opens a chat when URI has no action parameter", | ||
| mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) { | ||
|
|
||
| const { api } = _converse; | ||
| // Wait for roster to be initialized so we can open chats | ||
| await mock.waitForRoster(_converse, 'current', 1); | ||
|
|
||
| // Save original globals to restore them later | ||
| const originalLocationDescriptor = Object.getOwnPropertyDescriptor(window, 'location'); | ||
| const originalReplaceState = window.history.replaceState; | ||
|
|
||
| // Mock window.location to simulate a protocol handler URI | ||
| // This simulates: ?uri=xmpp:romeo@montague.lit | ||
| Object.defineProperty(window, "location", { | ||
| value: { | ||
| search: '?uri=xmpp%3Aromeo%40montague.lit', // URL-encoded: xmpp:romeo@montague.lit | ||
| hash: '', | ||
| origin: 'http://localhost', | ||
| pathname: '/', | ||
| }, | ||
| configurable: true, | ||
| }); | ||
|
|
||
| // Spy on history.replaceState to verify URL cleanup | ||
| const replaceStateSpy = jasmine.createSpy('replaceState'); | ||
| window.history.replaceState = replaceStateSpy; | ||
|
|
||
| try { | ||
| // Call the function - this should parse URI and open chat | ||
| await u.routeToQueryAction(); | ||
|
|
||
| // Verify that the URL was cleaned up (protocol handler removes ?uri=...) | ||
| expect(replaceStateSpy).toHaveBeenCalledWith( | ||
| {}, | ||
| document.title, | ||
| 'http://localhost/' | ||
| ); | ||
|
|
||
| // Wait for and verify that a chatbox was created | ||
| await u.waitUntil(() => _converse.chatboxes.get('romeo@montague.lit')); | ||
| const chatbox = _converse.chatboxes.get('romeo@montague.lit'); | ||
| expect(chatbox).toBeDefined(); | ||
| expect(chatbox.get('jid')).toBe('romeo@montague.lit'); | ||
| } finally { | ||
| // Restore original globals to avoid test pollution | ||
| if (originalLocationDescriptor) { | ||
| Object.defineProperty(window, 'location', originalLocationDescriptor); | ||
| } else { | ||
| delete window.location; | ||
| } | ||
| window.history.replaceState = originalReplaceState; | ||
| } | ||
| })); | ||
|
|
||
| /** | ||
| * Test message sending functionality when action=message | ||
| * This tests URI parsing, chat opening, and message sending | ||
| */ | ||
| it("sends a message when action=message with body", | ||
| mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) { | ||
|
|
||
| const { api } = _converse; | ||
| await mock.waitForRoster(_converse, 'current', 1); | ||
|
|
||
| const originalLocationDescriptor = Object.getOwnPropertyDescriptor(window, 'location'); | ||
| const originalReplaceState = window.history.replaceState; | ||
|
|
||
| // Mock URI with message action: ?uri=xmpp:romeo@montague.lit?action=message&body=Hello | ||
| Object.defineProperty(window, "location", { | ||
| value: { | ||
| search: '?uri=xmpp%3Aromeo%40montague.lit%3Faction%3Dmessage%26body%3DHello', | ||
| hash: '', | ||
| origin: 'http://localhost', | ||
| pathname: '/', | ||
| }, | ||
| configurable: true, | ||
| }); | ||
|
|
||
| window.history.replaceState = jasmine.createSpy('replaceState'); | ||
|
|
||
| try { | ||
| const { routeToQueryAction } = await import('../utils.js'); | ||
|
|
||
| // Spy on the connection send method to verify XMPP stanza sending | ||
| spyOn(api.connection.get(), 'send'); | ||
|
|
||
| // Execute the function | ||
| await routeToQueryAction(); | ||
|
|
||
| // Verify chat was opened | ||
| await u.waitUntil(() => _converse.chatboxes.get('romeo@montague.lit')); | ||
| const chatbox = _converse.chatboxes.get('romeo@montague.lit'); | ||
| expect(chatbox).toBeDefined(); | ||
|
|
||
| // Verify message was sent and stored in chat | ||
| await u.waitUntil(() => chatbox.messages.length > 0); | ||
| const message = chatbox.messages.at(0); | ||
| expect(message.get('message')).toBe('Hello'); | ||
| expect(message.get('type')).toBe('chat'); | ||
| } finally { | ||
| if (originalLocationDescriptor) { | ||
| Object.defineProperty(window, 'location', originalLocationDescriptor); | ||
| } else { | ||
| delete window.location; | ||
| } | ||
| window.history.replaceState = originalReplaceState; | ||
| } | ||
| })); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.