Skip to content
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

[BDGR-180] Consider replacing vMix in-process mocks with mock server #567

Open
markspolakovs opened this issue Aug 2, 2024 · 1 comment
Assignees
Labels
Desktop Created by Linear-GitHub Sync Testing Created by Linear-GitHub Sync

Comments

@markspolakovs
Copy link
Member

markspolakovs commented Aug 2, 2024

Some of Desktop's vMix tests use MOCK_VMIX which uses strong-mock to mock the vMix client. This isn't great for a few reasons:

  1. The user experience from Playwright tests isn't great, as you need to app.evaluate (and we need to copy the TypeScript definitions on both sides to get the experience nice)
  2. The mocks are brittle as they're tied to the exact sequence of vMix client operations the code-under-test performs
  3. It means that the vMix client needs to be tested separately (though those tests wouldn't go anywhere as they're specific and useful)
  4. We've been moving towards having less and less test-only code in the main bundle, first with MockOBSWebSocket, then with MicroServer in BGDR-161

The potential complication with these is that the vMix API is very different to Server's and OBS's. Rather than having a number of small functions that return chunks of the state, it primarily returns the state of the entire vMix application as one XML document using the XML function, or a slice of it using XMLTEXT, and then manipulates it using FUNCTION. This would mean that, in order to properly mock its behaviour, we would need to reply with XML documents that match (as far as possible) those returned by vMix.

Arguably we should move towards using XMLTEXT rather than than XML where possible, which would make testing this easier (and reduce the amount of data transferred on the wire). But this makes typesafe vMix operations more difficult, may not always be possible, and the data transfer is less of an issue since (currently) it's always on localhost. See BDGR-181.

From SyncLinear.com | BDGR-180

@markspolakovs markspolakovs added Desktop Created by Linear-GitHub Sync Testing Created by Linear-GitHub Sync labels Aug 2, 2024
@markspolakovs
Copy link
Member Author

One idea I've had is to design the API slightly differently that MockOBS's. Rather than specifying the full returned state in the mock handler, we provide an initial state (likely as JSON, which then gets serialised to XML) which MockVMixAPI stores internally and always returns on a call to XML/XMLTEXT. The user then defines handlers for FUNCTIONs which can manipulate that state.

@markspolakovs markspolakovs self-assigned this Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Desktop Created by Linear-GitHub Sync Testing Created by Linear-GitHub Sync
Projects
None yet
Development

No branches or pull requests

1 participant