/**
 * Test script to validate explorer locating currently open buffer
 */ import * as assert from "assert" ; import * as fs from "fs" ; import * as os from "os" ; import * as path from "path" ; import * as Oni from "oni-api" ; import * as Log from "oni-core-logging" ; import { getElementsBySelector , navigateToFile , useTempWorkspace , waitForCommand } from "./Common" ; const command = "explorer.locate.buffer" ; const fileToLocate = "File.ts" ; const isFileToLocateVisibleAndHighlighted = ( ) => { return ! ! [ ] . slice . call ( getElementsBySelector ( "div.item > div[icon]" ) ) . filter ( el => getComputedStyle ( el ) [ "background-color" ] !== "rgba(0, 0, 0, 0)" ) . map ( el => el . parentElement . textContent ) . filter ( text => text === fileToLocate ) . length ; } ; export const test = async ( oni ) => { await oni . automation . waitForEditors ( ) ; await oni . automation . waitFor ( ( ) => document . querySelectorAll ( ".sidebar-content" ) . length === 1 ) ; await waitForCommand ( command , oni ) ; const rootPath = await useTempWorkspace ( oni ) ; await navigateToFile ( path . join ( rootPath , "src" , fileToLocate ) , oni ) ; await oni . automation . waitFor ( ( ) => ! isFileToLocateVisibleAndHighlighted ( ) ) ; oni . commands . executeCommand ( command ) ; await oni . automation . waitFor ( ( ) => isFileToLocateVisibleAndHighlighted ( ) ) ; await oni . commands . executeCommand ( "sidebar.toggle" ) ; await oni . automation . waitFor ( ( ) => ! isFileToLocateVisibleAndHighlighted ( ) ) ; oni . commands . executeCommand ( command ) ; await oni . automation . waitFor ( ( ) => isFileToLocateVisibleAndHighlighted ( ) ) ; } ;