Skip to content

Commit 1b06882

Browse files
authored
[HIGH] Unset forced-colors after running accessibility.liveRegion.activityStatus.sendFailed.contrast test (#4570)
* Reset forced-colors when test start * Unset forced-colors on every run() * Reset timezone on every run
1 parent da90755 commit 1b06882

File tree

4 files changed

+26
-31
lines changed

4 files changed

+26
-31
lines changed

__tests__/html/accessibility.liveRegion.activityStatus.sendFailed.contrast.html

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@
1616
const directLine = testHelpers.createDirectLineEmulator(store);
1717

1818
await host.sendDevToolsCommand('Emulation.setEmulatedMedia', {
19-
features: [
20-
{
21-
name: 'forced-colors',
22-
value: 'active'
23-
}
24-
]});
19+
features: [{ name: 'forced-colors', value: 'active' }]
20+
});
2521

2622
WebChat.renderWebChat(
2723
{
@@ -37,29 +33,21 @@
3733

3834
await pageConditions.uiConnected();
3935

40-
const { disconnect, flush } = pageObjects.observeLiveRegion();
41-
42-
try {
43-
const sendMessage = await directLine.emulateOutgoingActivity('Hello, World!');
36+
const sendMessage = await directLine.emulateOutgoingActivity('Hello, World!');
4437

45-
await directLine.emulateIncomingActivity('Aloha!');
38+
await directLine.emulateIncomingActivity('Aloha!');
4639

47-
sendMessage.rejectPostActivity(new Error('artificial error'));
40+
sendMessage.rejectPostActivity(new Error('artificial error'));
4841

49-
await pageConditions.became(
50-
'failed to send message',
51-
() => pageElements.activityStatuses()[0]?.innerText === 'Send failed. Retry.',
52-
1000
53-
);
54-
55-
} finally {
56-
57-
await host.snapshot();
42+
await pageConditions.became(
43+
'failed to send message',
44+
() => pageElements.activityStatuses()[0]?.innerText === 'Send failed. Retry.',
45+
1000
46+
);
5847

59-
disconnect();
60-
}
48+
await host.snapshot();
6149
},
62-
{ ignoreErrors: true }
50+
{ ignoreErrors: 'artificial error' }
6351
);
6452
</script>
6553
</body>

packages/test/harness/src/browser/globals/run.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,20 @@ export default function () {
1010

1111
// Run the test, signal start by host.ready().
1212
// On success or failure, call host.done() or host.error() correspondingly.
13-
return Promise.resolve()
14-
.then(host.ready)
15-
.then(fn)
16-
.then(() => host.done(doneOptions))
17-
.catch(host.error);
13+
// This function will be executed in both Jest and "npm run browser".
14+
return (
15+
host
16+
// Previous run may have enabled "forced-colors", we should unset it.
17+
.sendDevToolsCommand('Emulation.setEmulatedMedia', {
18+
features: [{ name: 'forced-colors', value: '' }]
19+
})
20+
// Some tests may have changed the time zone, we should unset it.
21+
.then(() => host.sendDevToolsCommand('Emulation.setTimezoneOverride', { timezoneId: 'Etc/UTC' }))
22+
.then(host.ready)
23+
.then(fn)
24+
.then(() => host.done(doneOptions))
25+
.catch(host.error)
26+
);
1827
})
1928
);
2029
}

packages/test/harness/src/host/dev/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ async function main() {
6464
process.once('SIGTERM', terminate);
6565

6666
try {
67-
await webDriver.sendDevToolsCommand('Emulation.setTimezoneOverride', { timezoneId: 'Etc/UTC' });
6867
// eslint-disable-next-line no-magic-numbers
6968
await webDriver.get(process.argv[2] || 'http://localhost:5080/');
7069

packages/test/harness/src/host/jest/runHTML.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ global.runHTML = async function runHTML(url, options = DEFAULT_OPTIONS) {
5252

5353
global.__operation__ = `loading URL ${absoluteURL.toString()}`;
5454

55-
await webDriver.sendDevToolsCommand('Emulation.setTimezoneOverride', { timezoneId: 'Etc/UTC' });
5655
await webDriver.get(absoluteURL);
5756

5857
global.__operation__ = 'setting class name for body element';

0 commit comments

Comments
 (0)