-
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.
Bump Adaptive Cards to 3.0.2 (#5115)
* Add tests for mods * Add test entrypoints * Test clicking on disabled button * Test show card button with disabled mod * Fix test filename * Bump adaptivecards@3.0.2 * More conclusive tests * Remove an unnecessary hack * Add 4.16.1 notable changes * Add entry
- Loading branch information
Showing
18 changed files
with
572 additions
and
65 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
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
70 changes: 70 additions & 0 deletions
70
__tests__/html/accessibility.adaptiveCard.hack.actionSetShouldNotBeMenuBarMod.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,70 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<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"></main> | ||
<script> | ||
run(async function () { | ||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
WebChat.renderWebChat({ directLine, store }, document.getElementById('webchat')); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
attachments: [ | ||
{ | ||
content: { | ||
type: 'AdaptiveCard', | ||
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
version: '1.5', | ||
body: [ | ||
{ | ||
type: 'ActionSet', | ||
actions: [ | ||
{ | ||
type: 'Action.Submit', | ||
title: 'Button 0' | ||
} | ||
] | ||
}, | ||
{ | ||
type: 'TextBlock', | ||
text: 'Laborum sit incididunt ea laboris incididunt minim commodo Lorem excepteur sit ipsum eu.' | ||
} | ||
], | ||
actions: [ | ||
{ | ||
type: 'Action.Submit', | ||
title: 'Button 1' | ||
}, | ||
{ | ||
type: 'Action.Submit', | ||
title: 'Button 2' | ||
}, | ||
{ | ||
type: 'Action.Submit', | ||
title: 'Button 3' | ||
} | ||
] | ||
}, | ||
contentType: 'application/vnd.microsoft.card.adaptive' | ||
} | ||
] | ||
}); | ||
|
||
await pageConditions.numActivitiesShown(1); | ||
|
||
const actionSets = Array.from(document.querySelectorAll('.ac-actionSet')); | ||
|
||
expect(actionSets).toHaveLength(2); | ||
expect(actionSets.every(actionSet => !actionSet.hasAttribute('role'))).toBe(true); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
__tests__/html/accessibility.adaptiveCard.hack.actionSetShouldNotBeMenuBarMod.js
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,5 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('accessibility hacks for Adaptive Cards', () => { | ||
test('actionSets should not have role="menubar"', () => runHTML('accessibility.adaptiveCard.hack.actionSetShouldNotBeMenuBarMod.html')); | ||
}); |
90 changes: 90 additions & 0 deletions
90
__tests__/html/accessibility.adaptiveCard.hack.actionShouldBePushButtonMod.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,90 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<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"></main> | ||
<script> | ||
run(async function () { | ||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
WebChat.renderWebChat({ directLine, store }, document.getElementById('webchat')); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
attachments: [ | ||
{ | ||
content: { | ||
type: 'AdaptiveCard', | ||
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
version: '1.5', | ||
actions: [ | ||
{ type: 'Action.Submit', title: 'Button 1' }, | ||
{ | ||
type: 'Action.ShowCard', | ||
title: 'Show card', | ||
card: { | ||
type: 'AdaptiveCard', | ||
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
version: '1.5', | ||
actions: [ | ||
{ type: 'Action.Submit', title: 'Button 2' }, | ||
{ type: 'Action.Submit', title: 'Button 3' } | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
contentType: 'application/vnd.microsoft.card.adaptive' | ||
} | ||
] | ||
}); | ||
|
||
await pageConditions.numActivitiesShown(1); | ||
|
||
const [firstPushButton, secondPushButton] = Array.from(document.querySelectorAll('.ac-pushButton')); | ||
|
||
expect(firstPushButton).toHaveProperty('textContent', 'Button 1'); | ||
expect(firstPushButton.getAttribute('aria-pressed')).toBe('false'); | ||
expect(firstPushButton.hasAttribute('aria-posinset')).toBe(false); | ||
expect(firstPushButton.hasAttribute('aria-setsize')).toBe(false); | ||
expect(firstPushButton.hasAttribute('role')).toBe(false); | ||
|
||
expect(secondPushButton).toHaveProperty('textContent', 'Show card'); | ||
expect(secondPushButton.hasAttribute('aria-pressed')).toBe(false); | ||
expect(secondPushButton.hasAttribute('aria-posinset')).toBe(false); | ||
expect(secondPushButton.hasAttribute('aria-setsize')).toBe(false); | ||
expect(secondPushButton.hasAttribute('role')).toBe(false); | ||
|
||
await (await directLine.actPostActivity(() => host.click(firstPushButton))).resolveAll(); | ||
|
||
expect(firstPushButton.getAttribute('aria-pressed')).toBe('true'); | ||
|
||
await host.click(secondPushButton); | ||
|
||
const [, , thirdPushButton, fourthPushButton] = Array.from(document.querySelectorAll('.ac-pushButton')); | ||
|
||
expect(thirdPushButton).toHaveProperty('textContent', 'Button 2'); | ||
expect(thirdPushButton.getAttribute('aria-pressed')).toBe('false'); | ||
expect(thirdPushButton.hasAttribute('aria-posinset')).toBe(false); | ||
expect(thirdPushButton.hasAttribute('aria-setsize')).toBe(false); | ||
expect(thirdPushButton.hasAttribute('role')).toBe(false); | ||
|
||
await (await directLine.actPostActivity(() => host.click(thirdPushButton))).resolveAll(); | ||
|
||
expect(thirdPushButton.getAttribute('aria-pressed')).toBe('true'); | ||
|
||
await WebChat.renderWebChat({ directLine, disabled: true, store }, document.getElementById('webchat')); | ||
|
||
await host.click(fourthPushButton); | ||
|
||
expect(fourthPushButton.getAttribute('aria-pressed')).toBe('false'); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
__tests__/html/accessibility.adaptiveCard.hack.actionShouldBePushButtonMod.js
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,5 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('accessibility hacks for Adaptive Cards', () => { | ||
test('action should be push button', () => runHTML('accessibility.adaptiveCard.hack.actionShouldBePushButtonMod.html')); | ||
}); |
64 changes: 64 additions & 0 deletions
64
__tests__/html/accessibility.adaptiveCard.hack.activeElementMod.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,64 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<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"></main> | ||
<script> | ||
run(async function () { | ||
const adaptiveCard = { | ||
content: { | ||
type: 'AdaptiveCard', | ||
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
version: '1.5', | ||
actions: [{ type: 'Action.Submit', title: 'Button' }] | ||
}, | ||
contentType: 'application/vnd.microsoft.card.adaptive' | ||
}; | ||
|
||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
WebChat.renderWebChat({ directLine, store }, document.getElementById('webchat')); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
attachments: [adaptiveCard], | ||
id: 'a-00001', | ||
text: 'Hello, World!', | ||
type: 'message' | ||
}); | ||
|
||
await pageConditions.numActivitiesShown(1); | ||
|
||
expect(pageElements.activityContents()[0]).toHaveProperty('textContent', 'Hello, World!\n'); | ||
|
||
const pushButton1 = document.querySelector('.ac-pushButton'); | ||
|
||
pushButton1.focus(); | ||
|
||
expect(document.activeElement).toBe(pushButton1); | ||
|
||
// Modifying "adaptiveCardsHostConfig" props will cause the Adaptive Card to be re-rendered. | ||
WebChat.renderWebChat({ adaptiveCardsHostConfig: {}, directLine, store }, document.getElementById('webchat')); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
attachments: [adaptiveCard], | ||
id: 'a-00001', | ||
text: 'Aloha!', | ||
type: 'message' | ||
}); | ||
|
||
expect(pageElements.activityContents()[0]).toHaveProperty('textContent', 'Aloha!\n'); | ||
|
||
const pushButton2 = document.querySelector('.ac-pushButton'); | ||
|
||
expect(document.activeElement).toBe(pushButton2); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
__tests__/html/accessibility.adaptiveCard.hack.activeElementMod.js
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,5 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('accessibility hacks for Adaptive Cards', () => { | ||
test('when rerendered should persist focused element', () => runHTML('accessibility.adaptiveCard.hack.activeElementMod.html')); | ||
}); |
77 changes: 77 additions & 0 deletions
77
__tests__/html/accessibility.adaptiveCard.hack.disabledMod.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,77 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<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"></main> | ||
<script> | ||
run(async function () { | ||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
WebChat.renderWebChat({ directLine, store }, document.getElementById('webchat')); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
attachments: [ | ||
{ | ||
content: { | ||
type: 'AdaptiveCard', | ||
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
version: '1.5', | ||
actions: [ | ||
{ type: 'Action.Submit', title: 'Button' }, | ||
{ | ||
type: 'Action.ShowCard', | ||
title: 'Show card', | ||
card: { | ||
type: 'AdaptiveCard', | ||
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
version: '1.5', | ||
body: [{ type: 'TextBlock', text: 'Hello, World!' }] | ||
} | ||
} | ||
] | ||
}, | ||
contentType: 'application/vnd.microsoft.card.adaptive' | ||
} | ||
] | ||
}); | ||
|
||
await pageConditions.numActivitiesShown(1); | ||
|
||
const pushButton1 = document.querySelector('.ac-pushButton'); | ||
|
||
expect(pushButton1).toHaveProperty('disabled', false); | ||
expect(pushButton1.hasAttribute('aria-disabled')).toBe(false); | ||
|
||
pushButton1.focus(); | ||
|
||
WebChat.renderWebChat({ directLine, disabled: true, store }, document.getElementById('webchat')); | ||
|
||
const pushButton2 = document.querySelector('.ac-pushButton'); | ||
|
||
expect(document.activeElement).toBe(pushButton2); | ||
expect(pushButton2).toHaveProperty('disabled', false); | ||
expect(pushButton2.getAttribute('aria-disabled')).toBe('true'); | ||
|
||
await host.sendTab(); | ||
await host.sendShiftTab(); | ||
|
||
// Once focused to another element, the button should not be focusable. | ||
expect(document.activeElement).not.toBe(pushButton2); | ||
|
||
const showCardButton = Array.from(document.querySelectorAll('.ac-pushButton'))[1]; | ||
|
||
await host.click(showCardButton); | ||
|
||
expect(showCardButton.hasAttribute('aria-disabled')).toBe(false); | ||
expect(showCardButton.getAttribute('aria-expanded')).toBe('true'); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
__tests__/html/accessibility.adaptiveCard.hack.disabledMod.js
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,5 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('accessibility hacks for Adaptive Cards', () => { | ||
test('when disabled should add aria-disabled', () => runHTML('accessibility.adaptiveCard.hack.disabledMod.html')); | ||
}); |
Oops, something went wrong.