Skip to content

Commit df3d565

Browse files
authored
Merge pull request #20 from gitify-app/fix/sonar-javascript-S9382
fix(sonar): await outside loops in preferences smoke test (javascript:S9382)
2 parents 9100871 + 5a577c2 commit df3d565

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎tests/shell/preferences.js‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,20 @@ application.connect('activate', () => {
7272
if (installed) {
7373
open.emit('clicked');
7474
}
75-
for (const title of ['Get Gitify', 'Set up AppIndicator']) {
75+
await ['Get Gitify', 'Set up AppIndicator'].reduce(async (promise, title) => {
76+
await promise;
7677
const link = all.find(
7778
(widget) => widget instanceof Gtk.Button && widget.tooltip_text === title,
7879
);
7980
assert(link, `Missing link: ${title}`);
8081
link.emit('clicked');
8182
await delay(500);
82-
}
83+
}, Promise.resolve());
8384
const actionsPath = GLib.getenv('GITIFY_PREFS_ACTIONS');
84-
for (let attempt = 0; attempt < 20; attempt++) {
85+
const waitForActions = async (attempt = 0) => {
86+
if (attempt === 20) {
87+
throw new Error('Expected app/browser launches did not reach the desktop handlers');
88+
}
8589
if (GLib.file_test(actionsPath, GLib.FileTest.EXISTS)) {
8690
const [, bytes] = GLib.file_get_contents(actionsPath);
8791
const actions = new TextDecoder().decode(bytes);
@@ -104,8 +108,9 @@ application.connect('activate', () => {
104108
}
105109
}
106110
await delay(100);
107-
}
108-
throw new Error('Expected app/browser launches did not reach the desktop handlers');
111+
return waitForActions(attempt + 1);
112+
};
113+
await waitForActions();
109114
})().catch((error) => {
110115
failure = error;
111116
application.quit();

0 commit comments

Comments
 (0)