|
| 1 | +--- |
| 2 | +id: App-Channel-Tests |
| 3 | +sidebar_label: App Channel Tests |
| 4 | +title: App Channel Tests |
| 5 | +hide_title: true |
| 6 | +--- |
| 7 | + |
| 8 | +# App Channel Tests |
| 9 | +<!-- markdownlint-disable MD033 --> |
| 10 | + |
| 11 | +## Basic Broadcast |
| 12 | + |
| 13 | +| App | Step | Details | |
| 14 | +|-----|-------------------------|----------------------------------------------------------------------------| |
| 15 | +| A | 1. Retrieve `Channel` | Retrieve a `Channel` object representing an 'App' channel called `test-channel` using: <br />`const testChannel = await fdc3.getOrCreateChannel("test-channel")` | |
| 16 | +| A | 2. Add Context Listener | Add an _untyped_ context listener to the channel, using: <br /> !`await testChannel.addContextListener(null,handler)` | |
| 17 | +| B | 3. Retrieve `Channel` | Retrieve a `Channel` object representing the same 'App' channel A did (`test-channel`)| |
| 18 | +| B | 4. Broadcast | Broadcast an `fdc3.instrument` Context to the channel with: <br />`testChannel.broadcast(<fdc3.instrument>)`| |
| 19 | +| A | 5. Receive Context | The handler added in step 2 will receive the instrument context. Ensure that the instrument received by A is identical to that sent by B. | |
| 20 | + |
| 21 | +- `ACBasicUsage1` Perform above test. |
| 22 | + |
| 23 | +## Current Context |
| 24 | + |
| 25 | +| App | Step | Details | |
| 26 | +|-----|-----------------------------|----------------------------------------------------------------------------| |
| 27 | +| B | 1. Retrieve `Channel` |Retrieve a `Channel` object representing an 'App' channel called `test-channel` using: <br />`const testChannel = await fdc3.getOrCreateChannel("test-channel")` | |
| 28 | +| B | 2. Broadcast | Broadcast an `fdc3.instrument` to the channel using: <br />`testChannel.broadcast(<fdc3.instrument>)`| |
| 29 | +| A | 3. Retrieve `Channel` |Retrieve a `Channel` object representing the same 'App' channel B did (`test-channel`)| |
| 30 | +| A | 4. Retrieve Current Context | A gets the _current context_ of the user channel. via: `await testChannel.getCurrentContext()` <br />Ensure that the instrument received by A is identical to that sent by B | |
| 31 | + |
| 32 | +- `ACBasicUsage2` Perform above test |
| 33 | + |
| 34 | +## Filtered Context |
| 35 | + |
| 36 | +| App | Step | Details | |
| 37 | +|-----|-------------------------|-----------------------------------------------------------------| |
| 38 | +| A | 1. Retrieve `Channel` | Retrieve a `Channel` object representing an 'App' channel called `test-channel` using: <br />`const testChannel = await fdc3.getOrCreateChannel("test-channel")` | |
| 39 | +| A | 2. Add Context Listener | Add an _typed_ context listener for `fdc3.instrument`, using: <br />`await testChannel.addContextListener("fdc3.instrument",handler)`| |
| 40 | +| B | 3. Retrieve `Channel` | Retrieve a `Channel` object representing the same 'App' channel A did (`test-channel`)| |
| 41 | +| B | 4. Broadcast | B broadcasts both an `fdc3.instrument` context and an `fdc3.contact` context, using: <br /> `testChannel.broadcast(<fdc3.instrument>)` <br /> `testChannel.broadcast(<fdc3.contact>)`| |
| 42 | +| A | 5. Receive Context | An fdc3.instrument context is received by the handler added in step 2.<br />Ensure that the fdc3.instrument received by A is identical to that sent by B<br />Ensure that the fdc3.contact context is NOT received. | |
| 43 | + |
| 44 | +- `ACFilteredContext1`: Perform above test. |
| 45 | +- `ACFilteredContext2`: Perform above test, but add listeners for both `fdc3.instrument` and `fdc3.contact` in step2. Ensure that both context objects are received. |
| 46 | +- `ACFilteredContext3`: Perform above test, except creating a _different_ channel in app B. Check that you _don't_ receive anything (as the channels don't match). |
| 47 | +- `ACFilteredContext4`: Perform above test, except that after creating the channel **A** creates another channel with a further _different_ channel id and adds a further context listener to it. Ensure that **A** is still able to receive context on the first channel (i.e. it is unaffected by the additional channel) and does NOT receive anything on the second channel. |
| 48 | +- `ACUnsubscribe`: Perform above test, except that after creating the channel **A** then `unsubscribe()`s the listener it added to the channel. Check that **A** does NOT receive anything. |
| 49 | + |
| 50 | +### App Channel History |
| 51 | + |
| 52 | +| App | Step | Details | |
| 53 | +|-----|-----------------------------|---------------------------------------------------------| |
| 54 | +| A | 1. Retrieve `Channel` | Retrieve a `Channel` object representing an 'App' channel called `test-channel` using: <br />`const testChannel = await fdc3.getOrCreateChannel("test-channel")` | |
| 55 | +| B | 2. Retrieve `Channel` | Retrieve a `Channel` object representing the same 'App' channel A did (`test-channel`)| |
| 56 | +| B | 3. Broadcast | B broadcasts both the instrument context and a contact context, using: <br /> `testChannel.broadcast(<fdc3.instrument>)` <br /> `testChannel.broadcast(<fdc3.contact>)` | |
| 57 | +| A | 4. Add Context Listener | A adds a context listener to the channel _after_ B has completed all its broadcasts, via: <br />`await testChannel.addContextListener("fdc3.instrument", handler)` <br /> Ensure that A does NOT receive any context via these listeners (past context is only retrieved via a `getCurrentContext()` call on App channels). | |
| 58 | +| A | 5. Retrieve Current Context | A is able to retrieve the most recent context of each context type from the `Channel` via: <br />`const instrument = await testChannel.getCurrentContext('fdc3.instrument')`<br />`const contact = await testChannel.getCurrentContext('fdc3.contact')`<br />Ensure that both contexts retrieved by A are identical to those sent by B| |
| 59 | + |
| 60 | +- `ACContextHistoryTyped`: Perform above test. |
| 61 | +- `ACContextHistoryMultiple`: **B** Broadcasts multiple history items of both types. Ensure that only the last version of each type is received by **A**. |
| 62 | +- `ACContextHistoryLast`: In step 5. **A** retrieves the _untyped_ current context of the channel via `const currentContext = await testChannel.getCurrentContext()`. Ensure that A receives only the very last broadcast context item _of any type_. |
0 commit comments