live: drop events for channels already hung up; e2e waits for the page
Asterisk sends NewCallerid after a Local;1 channel's Hangup, which re-created the channel and left a ghost ringing call on the dashboard. Only Newchannel creates a channel now. The e2e waits that matched text also shown on the previous page (now that the dashboard lists calls) wait for the route. Task: M7-T4
This commit is contained in:
1 parent
f7fc4ed70e
commit
04ec3761c1
5 files changed
+17
-2
No files matched your search
@@ -36,6 +36,15 @@ describe('CallTracker', () => {
|
||||
expect(seen.at(-1)).toBeNull();
|
||||
});
|
||||
|
||||
it('an event after Hangup does not bring the channel back', () => {
|
||||
const t = new CallTracker(() => undefined);
|
||||
const ch = { Channel: 'Local/600@sp-from-ext-00000005;1', Linkedid: '2.0', Uniqueid: '2.0' };
|
||||
t.handle({ Event: 'Newchannel', ChannelStateDesc: 'Down', ...ch });
|
||||
t.handle({ Event: 'Hangup', ...ch });
|
||||
t.handle({ Event: 'NewCallerid', ChannelStateDesc: 'Up', CallerIDNum: '193', ...ch });
|
||||
expect(t.list()).toEqual([]);
|
||||
});
|
||||
|
||||
it('loads calls already up from CoreShowChannels', () => {
|
||||
const t = new CallTracker(() => undefined);
|
||||
const ch = (Channel: string, extra: Record<string, string>) => ({
|
||||
|
||||
@@ -84,6 +84,8 @@ export class CallTracker {
|
||||
case 'Newstate':
|
||||
case 'NewCallerid':
|
||||
case 'NewConnectedLine':
|
||||
// Only Newchannel creates: Asterisk can send a NewCallerid after a channel's Hangup.
|
||||
if (!this.channels.has(name)) return;
|
||||
this.upsert(m);
|
||||
break;
|
||||
case 'Newexten': {
|
||||
@@ -116,7 +118,7 @@ export class CallTracker {
|
||||
case 'VarSet': {
|
||||
const v = field(m, 'Variable') ?? '';
|
||||
const value = field(m, 'Value') ?? '';
|
||||
if (!/^(?:__)?SP_(?:DID|DIRECTION|REC)$/.test(v) || !linkedid) return;
|
||||
if (!/^(?:__)?SP_(?:DID|DIRECTION|REC)$/.test(v) || !this.byLinkedid(linkedid).length) return;
|
||||
const x = this.extraOf(linkedid);
|
||||
if (v.endsWith('DID')) x.did = value || x.did;
|
||||
else if (v.endsWith('DIRECTION'))
|
||||
|
||||
@@ -211,6 +211,7 @@ try {
|
||||
await p.click('Sign in');
|
||||
await p.waitFor(`location.pathname === '/admin'`);
|
||||
await p.click('Blocked numbers');
|
||||
await p.waitFor(`document.body.innerText.includes('Number to block')`);
|
||||
await p.fill('Number to block', '(312) 555-0111');
|
||||
await p.fill('Note (optional)', 'Test spammer');
|
||||
await p.click('Block');
|
||||
|
||||
@@ -105,6 +105,7 @@ try {
|
||||
await p.click('Sign in');
|
||||
await p.waitFor(`location.pathname === '/admin'`);
|
||||
await p.click('Call history');
|
||||
await p.waitFor(`location.pathname === '/admin/calls'`);
|
||||
await p.waitFor(`document.body.innerText.includes('Cy Caller')`, 'calls listed');
|
||||
await p.evaluate(
|
||||
`(() => { const s = [...document.querySelectorAll('select')].find(s => s.labels[0]?.textContent === 'Status'); Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, 'value').set.call(s, 'voicemail'); s.dispatchEvent(new Event('change', { bubbles: true })); return true; })()`,
|
||||
|
||||
@@ -164,7 +164,9 @@ try {
|
||||
|
||||
// Call history: expand, the player's audio is a real recording.
|
||||
await p.click('Call history');
|
||||
await p.waitFor(`document.body.innerText.includes('(312) 555-8888')`);
|
||||
await p.waitFor(
|
||||
`[...document.querySelectorAll('ul[aria-label=Calls] > li')].some(li => li.innerText.includes('(312) 555-8888'))`,
|
||||
);
|
||||
await p.evaluate(
|
||||
`[...document.querySelectorAll('ul[aria-label=Calls] > li')].find(li => li.innerText.includes('(312) 555-8888')).querySelector('button[aria-expanded]').click(), true`,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user