-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable copy button when it is denied/disabled (#5285)
* Disable copy button when it is denied/disabled * Update entry * Reset clipboard-write
- Loading branch information
Showing
15 changed files
with
210 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
Binary file added
BIN
+14.6 KB
...tton-denied-js-copy-button-with-denied-permission-should-be-disabled-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.6 KB
...tton-denied-js-copy-button-with-denied-permission-should-be-disabled-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.8 KB
..._/html/copy-button-disabled-js-copy-button-should-be-able-to-disable-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.8 KB
..._/html/copy-button-disabled-js-copy-button-should-be-able-to-disable-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,72 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script> | ||
<script crossorigin="anonymous" src="/test-harness.js"></script> | ||
<script crossorigin="anonymous" src="/test-page-object.js"></script> | ||
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
</head> | ||
<body> | ||
<main id="webchat" style="position: relative"></main> | ||
<script type="text/babel"> | ||
run(async function () { | ||
const { | ||
React, | ||
ReactDOM: { render }, | ||
WebChat: { ReactWebChat } | ||
} = window; // Imports in UMD fashion. | ||
|
||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
render(<ReactWebChat directLine={directLine} store={store} />, document.getElementById('webchat')); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
expect(window.isSecureContext).toBe(true); | ||
|
||
await host.sendDevToolsCommand('Browser.setPermission', { | ||
permission: { name: 'clipboard-write' }, | ||
setting: 'denied' | ||
}); | ||
|
||
await expect(navigator.permissions.query({ name: 'clipboard-write' })).resolves.toHaveProperty( | ||
'state', | ||
'denied' | ||
); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
entities: [ | ||
{ | ||
'@context': 'https://schema.org', | ||
'@id': '', | ||
'@type': 'Message', | ||
keywords: ['AllowCopy'], | ||
type: 'https://schema.org/Message' | ||
} | ||
], | ||
text: 'Mollit *aute* **aute** dolor ea ex magna incididunt nostrud sit nisi.', | ||
type: 'message' | ||
}); | ||
|
||
await pageConditions.numActivitiesShown(1); | ||
|
||
// THEN: The copy button should be disabled. | ||
const copyButton = document.querySelector(`[data-testid="${WebChat.testIds.copyButton}"]`); | ||
|
||
expect(copyButton.getAttribute('aria-disabled')).toBe('true'); | ||
|
||
// THEN: Should match screenshot. | ||
await host.snapshot(); | ||
|
||
// WHEN: Clicks the "Copy" button. | ||
await host.click(copyButton); | ||
|
||
// THEN: The copy button should not change to "Copied". | ||
await host.snapshot(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains 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,3 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
test('copy button with denied permission should be disabled', () => runHTML('copyButton.denied')); |
This file contains 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,72 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script> | ||
<script crossorigin="anonymous" src="/test-harness.js"></script> | ||
<script crossorigin="anonymous" src="/test-page-object.js"></script> | ||
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
</head> | ||
<body> | ||
<main id="webchat" style="position: relative"></main> | ||
<script type="text/babel"> | ||
run(async function () { | ||
const { | ||
React, | ||
ReactDOM: { render }, | ||
WebChat: { ReactWebChat } | ||
} = window; // Imports in UMD fashion. | ||
|
||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
render(<ReactWebChat directLine={directLine} store={store} uiState="disabled" />, document.getElementById('webchat')); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
expect(window.isSecureContext).toBe(true); | ||
|
||
await host.sendDevToolsCommand('Browser.setPermission', { | ||
permission: { name: 'clipboard-write' }, | ||
setting: 'granted' | ||
}); | ||
|
||
await expect(navigator.permissions.query({ name: 'clipboard-write' })).resolves.toHaveProperty( | ||
'state', | ||
'granted' | ||
); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
entities: [ | ||
{ | ||
'@context': 'https://schema.org', | ||
'@id': '', | ||
'@type': 'Message', | ||
keywords: ['AllowCopy'], | ||
type: 'https://schema.org/Message' | ||
} | ||
], | ||
text: 'Mollit *aute* **aute** dolor ea ex magna incididunt nostrud sit nisi.', | ||
type: 'message' | ||
}); | ||
|
||
await pageConditions.numActivitiesShown(1); | ||
|
||
// THEN: The copy button should be disabled. | ||
const copyButton = document.querySelector(`[data-testid="${WebChat.testIds.copyButton}"]`); | ||
|
||
expect(copyButton.getAttribute('aria-disabled')).toBe('true'); | ||
|
||
// THEN: Should match screenshot. | ||
await host.snapshot(); | ||
|
||
// WHEN: Clicks the "Copy" button. | ||
await host.click(copyButton); | ||
|
||
// THEN: The copy button should not change to "Copied". | ||
await host.snapshot(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains 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,3 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
test('copy button should be able to disable', () => runHTML('copyButton.disabled')); |
This file contains 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 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 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 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 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 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