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

Adds custom middleware for rendering attachment in live region for screen reader #3548

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed

- Fixes [#3489](https://github.com/microsoft/BotFramework-WebChat/issues/3489). Fix AT saying 'Bot undefined said', by [@corinagum](https://github.com/corinagum) in PR [#3524](https://github.com/microsoft/BotFramework-WebChat/pull/3524)
- Fixes [#3547](https://github.com/microsoft/BotFramework-WebChat/issues/3547). Add attachment middleware for screen reader, by [@compulim](https://github.com/compulim) in PR [#3548](https://github.com/microsoft/BotFramework-WebChat/pull/3548)
compulim marked this conversation as resolved.
Show resolved Hide resolved

### Changed

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
compulim marked this conversation as resolved.
Show resolved Hide resolved
<html lang="en-US">
<head>
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<link href="assets/accessibility.liveRegionAttachment.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="webchat"></div>
<script type="text/babel" data-presets="env,stage-3,react">
const {
React: { useEffect },
ReactDOM: { render },
WebChat: {
Components: { BasicWebChat, Composer },
createDirectLine,
hooks: { useConnectivityStatus, useSendMessage }
},
WebChatTest: { conditions, createStore, host, pageObjects, timeouts, token }
} = window;

(async function () {
const SendOnConnect = () => {
const [connectivityStatus] = useConnectivityStatus();
const sendMessage = useSendMessage();

useEffect(() => {
connectivityStatus === 'connected' && sendMessage('card inputs');
}, [connectivityStatus, sendMessage]);

return false;
};

render(
<Composer
directLine={window.WebChat.createDirectLine({ token: await token.fetchDirectLineToken() })}
store={createStore()}
>
<BasicWebChat />
<SendOnConnect />
</Composer>,
document.getElementById('webchat')
);

await pageObjects.wait(conditions.uiConnected(), timeouts.directLine);
await pageObjects.wait(conditions.minNumActivitiesShown(2), timeouts.directLine);
await pageObjects.wait(conditions.scrollToBottomCompleted(), timeouts.directLine);

await host.snapshot();
await host.done();
})().catch(async err => {
console.error(err);

await host.error(err);
});
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js
*/

describe('accessibility requirement', () => {
describe('attachments in live region', () => {
test('Adaptive Card', () => runHTMLTest('accessibility.liveRegionAttachment.adaptiveCard.html'));
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<link href="assets/accessibility.liveRegionAttachment.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="webchat"></div>
<script type="text/babel" data-presets="env,stage-3,react">
const {
React: { useEffect },
ReactDOM: { render },
WebChat: {
Components: { BasicWebChat, Composer },
createDirectLine,
hooks: { useConnectivityStatus, useSendMessage }
},
WebChatTest: { conditions, createStore, host, pageObjects, timeouts, token }
} = window;

(async function () {
const SendOnConnect = () => {
const [connectivityStatus] = useConnectivityStatus();
const sendMessage = useSendMessage();

useEffect(() => {
connectivityStatus === 'connected' && sendMessage('animationcard');
}, [connectivityStatus, sendMessage]);

return false;
};

render(
<Composer
directLine={window.WebChat.createDirectLine({ token: await token.fetchDirectLineToken() })}
store={createStore()}
>
<BasicWebChat />
<SendOnConnect />
</Composer>,
document.getElementById('webchat')
);

await pageObjects.wait(conditions.uiConnected(), timeouts.directLine);
await pageObjects.wait(conditions.minNumActivitiesShown(2), timeouts.directLine);

// Replace the animation with a static image.
document
.querySelector('.webchat__bubble__content img')
.setAttribute(
'src',
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface1.jpg'
);

await pageObjects.wait(conditions.scrollToBottomCompleted(), timeouts.directLine);
await pageObjects.wait(conditions.allImagesLoaded(), timeouts.fetch);

await host.snapshot();
await host.done();
})().catch(async err => {
console.error(err);

await host.error(err);
});
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js
*/

describe('accessibility requirement', () => {
describe('attachments in live region', () => {
test('animation card', () => runHTMLTest('accessibility.liveRegionAttachment.animationCard.html'));
});
});
62 changes: 62 additions & 0 deletions __tests__/html/accessibility.liveRegionAttachment.audio.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<link href="assets/accessibility.liveRegionAttachment.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="webchat"></div>
<script type="text/babel" data-presets="env,stage-3,react">
const {
React: { useEffect },
ReactDOM: { render },
WebChat: {
Components: { BasicWebChat, Composer },
createDirectLine,
hooks: { useConnectivityStatus, useSendMessage }
},
WebChatTest: { conditions, createStore, host, pageObjects, timeouts, token }
} = window;

(async function () {
const SendOnConnect = () => {
const [connectivityStatus] = useConnectivityStatus();
const sendMessage = useSendMessage();

useEffect(() => {
connectivityStatus === 'connected' && sendMessage('audio');
}, [connectivityStatus, sendMessage]);

return false;
};

render(
<Composer
directLine={window.WebChat.createDirectLine({ token: await token.fetchDirectLineToken() })}
store={createStore()}
>
<BasicWebChat />
<SendOnConnect />
</Composer>,
document.getElementById('webchat')
);

await pageObjects.wait(conditions.uiConnected(), timeouts.directLine);
await pageObjects.wait(conditions.minNumActivitiesShown(2), timeouts.directLine);
await pageObjects.wait(conditions.scrollToBottomCompleted(), timeouts.directLine);
await pageObjects.wait(
conditions.mediaBuffered(document.getElementsByTagName('audio')[0]),
timeouts.fetchImage
);

await host.snapshot();
await host.done();
})().catch(async err => {
console.error(err);

await host.error(err);
});
</script>
</body>
</html>
9 changes: 9 additions & 0 deletions __tests__/html/accessibility.liveRegionAttachment.audio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js
*/

describe('accessibility requirement', () => {
describe('attachments in live region', () => {
test('audio', () => runHTMLTest('accessibility.liveRegionAttachment.audio.html'));
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<link href="assets/accessibility.liveRegionAttachment.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="webchat"></div>
<script type="text/babel" data-presets="env,stage-3,react">
const {
React: { useEffect },
ReactDOM: { render },
WebChat: {
Components: { BasicWebChat, Composer },
createDirectLine,
hooks: { useConnectivityStatus, useSendMessage }
},
WebChatTest: { conditions, createStore, host, pageObjects, timeouts, token }
} = window;

(async function () {
const SendOnConnect = () => {
const [connectivityStatus] = useConnectivityStatus();
const sendMessage = useSendMessage();

useEffect(() => {
connectivityStatus === 'connected' && sendMessage('audiocard');
}, [connectivityStatus, sendMessage]);

return false;
};

render(
<Composer
directLine={window.WebChat.createDirectLine({ token: await token.fetchDirectLineToken() })}
store={createStore()}
>
<BasicWebChat />
<SendOnConnect />
</Composer>,
document.getElementById('webchat')
);

await pageObjects.wait(conditions.uiConnected(), timeouts.directLine);
await pageObjects.wait(conditions.minNumActivitiesShown(2), timeouts.directLine);
await pageObjects.wait(conditions.scrollToBottomCompleted(), timeouts.directLine);
await pageObjects.wait(
conditions.mediaBuffered(document.getElementsByTagName('audio')[0]),
timeouts.fetchImage
);

await host.snapshot();
await host.done();
})().catch(async err => {
console.error(err);

await host.error(err);
});
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js
*/

describe('accessibility requirement', () => {
describe('attachments in live region', () => {
test('audio card', () => runHTMLTest('accessibility.liveRegionAttachment.audioCard.html'));
});
});
64 changes: 64 additions & 0 deletions __tests__/html/accessibility.liveRegionAttachment.file.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<link href="assets/accessibility.liveRegionAttachment.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="webchat"></div>
<script type="text/babel" data-presets="env,stage-3,react">
const {
React: { useEffect },
ReactDOM: { render },
WebChat: {
Components: { BasicWebChat, Composer },
createDirectLine,
hooks: { useConnectivityStatus, useSendFiles }
},
WebChatTest: { conditions, createStore, host, pageObjects, stringToArrayBuffer, timeouts, token }
} = window;

(async function () {
const SendOnConnect = () => {
const [connectivityStatus] = useConnectivityStatus();
const sendFiles = useSendFiles();

useEffect(() => {
if (connectivityStatus === 'connected') {
const blob = new Blob([stringToArrayBuffer('Hello, World!')]);

blob.name = 'hello.zip';

sendFiles([blob]);
}
}, [connectivityStatus, sendFiles]);

return false;
};

render(
<Composer
directLine={window.WebChat.createDirectLine({ token: await token.fetchDirectLineToken() })}
store={createStore()}
>
<BasicWebChat />
<SendOnConnect />
</Composer>,
document.getElementById('webchat')
);

await pageObjects.wait(conditions.uiConnected(), timeouts.directLine);
await pageObjects.wait(conditions.minNumActivitiesShown(2), timeouts.directLine);
await pageObjects.wait(conditions.scrollToBottomCompleted(), timeouts.directLine);

await host.snapshot();
await host.done();
})().catch(async err => {
console.error(err);

await host.error(err);
});
</script>
</body>
</html>
9 changes: 9 additions & 0 deletions __tests__/html/accessibility.liveRegionAttachment.file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js
*/

describe('accessibility requirement', () => {
describe('attachments in live region', () => {
test('file', () => runHTMLTest('accessibility.liveRegionAttachment.file.html'));
});
});
Loading