Skip to content

Commit

Permalink
fix: Prevent "TypeError: object is not iterable" (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanpoulter authored Feb 7, 2024
1 parent c25410f commit 5fd38b8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/pageobjects/editor/EditorView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,11 @@ export class EditorGroup extends BasePage<typeof EditorViewLocators> {
* @returns promise resolving to EditorTab list
*/
async getOpenTabs (): Promise<EditorTab[]> {
const tabs = await this.tab$$
return Promise.all(
tabs.map(async (tab) => (
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
new EditorTab(this.locatorMap, tab as any, this.view).wait()
))
)
const tabs = this.tab$$
return tabs.map(async (tab) => (
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
new EditorTab(this.locatorMap, tab as any, this.view).wait()
))
}

/**
Expand Down
17 changes: 17 additions & 0 deletions test/specs/editor.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../../dist/service.d.ts" />

import { browser, expect } from '@wdio/globals'

describe('editor', () => {
describe('getOpenTabs', () => {
it('returns an empty array when no tabs are open', async () => {
const workbench = await browser.getWorkbench()
await workbench.getEditorView().closeAllEditors()

expect(await workbench.getEditorView().getOpenTabs()).toStrictEqual([])
})
})
})

0 comments on commit 5fd38b8

Please sign in to comment.