Skip to content

Commit

Permalink
Show index size in settings view
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschwendener committed Oct 20, 2018
1 parent 3365b9f commit f3b9a89
Show file tree
Hide file tree
Showing 23 changed files with 523 additions and 373 deletions.
1 change: 1 addition & 0 deletions main.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ <h1 class="setting-section-title">App Settings</h1>
<div>Chrome: {{ process.versions.chrome }}</div>
<div>Node: {{ process.versions.node }}</div>
<div>V8: {{ process.versions.v8 }}</div>
<div>Index size: {{ indexLength }}</div>
</div>
</div>
<div class="setting-group">
Expand Down
73 changes: 45 additions & 28 deletions src/tests/integration/search-plugins/file-search-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,47 @@ describe(FileSearchPlugin.name, (): void => {
"test-file-3",
];

describe("getAllItems", (): void => {
beforeEach((): void => {
for (const parentFolder of parentFolders) {
mkdirSync(parentFolder);

for (const subFolder of subFolders) {
mkdirSync(join(parentFolder, subFolder));
beforeEach((): void => {
for (const parentFolder of parentFolders) {
mkdirSync(parentFolder);

for (const testFile of testFiles) {
const filePath = join(parentFolder, subFolder, testFile);
writeFileSync(filePath, "", "utf-8");
}
}
for (const subFolder of subFolders) {
mkdirSync(join(parentFolder, subFolder));

for (const testFile of testFiles) {
const filePath = join(parentFolder, testFile);
const filePath = join(parentFolder, subFolder, testFile);
writeFileSync(filePath, "", "utf-8");
}
}
});

afterEach((): void => {
for (const parentFolder of parentFolders) {
for (const testFile of testFiles) {
const filePath = join(parentFolder, testFile);
unlinkSync(filePath);
}
for (const testFile of testFiles) {
const filePath = join(parentFolder, testFile);
writeFileSync(filePath, "", "utf-8");
}
}
});

for (const subFolder of subFolders) {
for (const testFile of testFiles) {
const filePath = join(parentFolder, subFolder, testFile);
unlinkSync(filePath);
}
afterEach((): void => {
for (const parentFolder of parentFolders) {
for (const testFile of testFiles) {
const filePath = join(parentFolder, testFile);
unlinkSync(filePath);
}

rmdirSync(join(parentFolder, subFolder));
for (const subFolder of subFolders) {
for (const testFile of testFiles) {
const filePath = join(parentFolder, subFolder, testFile);
unlinkSync(filePath);
}

rmdirSync(parentFolder);
rmdirSync(join(parentFolder, subFolder));
}
});

rmdirSync(parentFolder);
}
});

describe("getAllItems", (): void => {
it("should return only top level files and folders if recursive search is set to false", (): void => {
const recursiveSearch = false;
const options = parentFolders.map((folder: string): FileSearchOption => {
Expand Down Expand Up @@ -143,4 +143,21 @@ describe(FileSearchPlugin.name, (): void => {
expect(acutal.length).toBe(0);
});
});

describe("getIndexLength", (): void => {
it("should return the number of files", (): void => {
const recursive = false;
const options = parentFolders.map((folder: string): FileSearchOption => {
return {
folderPath: folder,
recursive,
};
});

const plugin = new FileSearchPlugin(options, testIconSet, emptyBlackList);

const actual = plugin.getIndexLength();
expect(actual).toBe(parentFolders.length * testFiles.length + parentFolders.length * subFolders.length);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ describe(EnvironmentVariablePlugin.name, (): void => {
}
});
});

describe(plugin.getIndexLength.name, (): void => {
it("should return the length of env variables", (): void => {
const actual = plugin.getIndexLength();
expect(actual).toBe(Object.keys(fakeEnvironmentVariableCollection).length);
});
});
});
14 changes: 12 additions & 2 deletions src/tests/unit/search-plugins/mac-os-settings-plugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { MacOsSettingsPlugin } from "../../../ts/search-plugins/mac-os-settings-plugin";
import { testIconSet } from "../../../ts/icon-sets/test-icon-set";
import { allMacOsSettings } from "../../../ts/operating-system-settings/macos/mac-os-settings";

describe(MacOsSettingsPlugin.name, () => {
describe(MacOsSettingsPlugin.name, (): void => {
const searchPlugin = new MacOsSettingsPlugin(testIconSet);

describe(searchPlugin.getAllItems.name, () => {
describe(searchPlugin.getAllItems.name, (): void => {
it("should return more than zero items", () => {
const actual = searchPlugin.getAllItems();
expect(actual).not.toBe(undefined);
expect(actual).not.toBe(null);
expect(actual.length).toBeGreaterThan(0);
});
});

describe(searchPlugin.getIndexLength.name, (): void => {
it("should return the number of os settings", (): void => {
const actual = searchPlugin.getIndexLength();
const expected = allMacOsSettings.length;

expect(actual).toBe(expected);
});
});
});
31 changes: 20 additions & 11 deletions src/tests/unit/search-plugins/programs-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ function getTestPrograms(programNames: string[]) {
}

describe("ProgramsPlugin", (): void => {
describe("getAllItems", (): void => {
it("should return all programs", (): void => {
const fakePrograms = getTestPrograms([
"Git Bash",
"Adobe Premiere Pro",
"FL Studio (64-bit)",
"Native Instruments Maschine 2",
"Visual Studio Code",
]);
const fakePrograms = getTestPrograms([
"Git Bash",
"Adobe Premiere Pro",
"FL Studio (64-bit)",
"Native Instruments Maschine 2",
"Visual Studio Code",
]);

const fakeProgramRepository = new FakeProgramRepository(fakePrograms);
const programsPlugin = new ProgramsPlugin(fakeProgramRepository, testIconSet);
const fakeProgramRepository = new FakeProgramRepository(fakePrograms);
const programsPlugin = new ProgramsPlugin(fakeProgramRepository, testIconSet);

describe(programsPlugin.getAllItems.name, (): void => {
it("should return all programs", (): void => {
const actual = programsPlugin.getAllItems();

expect(actual.length).toBeGreaterThan(0);
Expand All @@ -41,4 +41,13 @@ describe("ProgramsPlugin", (): void => {
}
});
});

describe(programsPlugin.getIndexLength.name, (): void => {
it("should return the number of programs", (): void => {
const actual = programsPlugin.getIndexLength();
const expected = fakePrograms.length;

expect(actual).toBe(expected);
});
});
});
18 changes: 18 additions & 0 deletions src/tests/unit/search-plugins/shortcut-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,22 @@ describe(ShortcutsPlugin.name, (): void => {
}
});
});

describe("getIndexLength", (): void => {
it("should return the number of shortcuts", (): void => {
const shortcuts: Shortcut[] = [
{ executionArgument: "execution-argument-1", name: "shortcut-1", icon: "icon" },
{ executionArgument: "execution-argument-2", name: "shortcut-2", icon: "icon" },
{ executionArgument: "execution-argument-3", name: "shortcut-3", icon: "icon" },
{ executionArgument: "execution-argument-4", name: "shortcut-4", icon: "icon" },
];

const shortcutPlugin = new ShortcutsPlugin(shortcuts, "default-shortcut-icon");

const actual = shortcutPlugin.getIndexLength();
const expected = shortcuts.length;

expect(actual).toBe(expected);
});
});
});
14 changes: 12 additions & 2 deletions src/tests/unit/search-plugins/windows-10-settings-plugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { Windows10SettingsSearchPlugin } from "../../../ts/search-plugins/windows-10-settings-plugin";
import { testIconSet } from "../../../ts/icon-sets/test-icon-set";
import { allWindows10Apps } from "../../../ts/operating-system-settings/windows/windows-10-apps";
import { allWindowsSettings } from "../../../ts/operating-system-settings/windows/windows-settings";

describe(Windows10SettingsSearchPlugin.name, () => {
describe(Windows10SettingsSearchPlugin.name, (): void => {
const searchPlugin = new Windows10SettingsSearchPlugin(testIconSet);

describe(searchPlugin.getAllItems.name, () => {
describe(searchPlugin.getAllItems.name, (): void => {
it("should return more than zero items", () => {
const actual = searchPlugin.getAllItems();
expect(actual).not.toBe(undefined);
expect(actual).not.toBe(null);
expect(actual.length).toBeGreaterThan(0);
});
});

describe(searchPlugin.getIndexLength.name, (): void => {
it("should return the number of settings", (): void => {
const actual = searchPlugin.getIndexLength();
const expected = allWindows10Apps.length + allWindowsSettings.length;
expect(actual).toBe(expected);
});
});
});
3 changes: 3 additions & 0 deletions src/ts/ipc-channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ export class IpcChannels {
public static readonly hideSettings = "hide-settings";
public static readonly updateAppConfig = "update-app-config";
public static readonly updateUserConfig = "update-user-config";
public static readonly getIndexLength = "get-index-length";
public static readonly getIndexLengthResponse = "get-index-length-reponse";
public static readonly appReloaded = "app-reloaded";
}
34 changes: 18 additions & 16 deletions src/ts/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,6 @@ function downloadUpdate(): void {
autoUpdater.downloadUpdate();
}

autoUpdater.on("update-available", (): void => {
mainWindow.webContents.send(IpcChannels.ueliUpdateWasFound);
});

autoUpdater.on("update-not-available", (): void => {
mainWindow.webContents.send(IpcChannels.ueliNoUpdateWasFound);
});

autoUpdater.on("error", (): void => {
mainWindow.webContents.send(IpcChannels.ueliUpdateCheckError);
});

autoUpdater.on("update-downloaded", (): void => {
autoUpdater.quitAndInstall();
});

function setAutostartSettings() {
app.setLoginItemSettings({
args: [],
Expand Down Expand Up @@ -260,6 +244,8 @@ function reloadApp(preventMainWindowReload?: boolean, preventWindowSizeReset?: b
if (!isInDevelopment) {
setAutostartSettings();
}

mainWindow.webContents.send(IpcChannels.appReloaded);
}

function destroyTrayIcon(): void {
Expand Down Expand Up @@ -289,6 +275,22 @@ function setUpNewRescanInterval(): void {
rescanInterval = setInterval(initializeInputValidationService, TimeHelpers.convertSecondsToMilliseconds(config.rescanInterval));
}

autoUpdater.on("update-available", (): void => {
mainWindow.webContents.send(IpcChannels.ueliUpdateWasFound);
});

autoUpdater.on("update-not-available", (): void => {
mainWindow.webContents.send(IpcChannels.ueliNoUpdateWasFound);
});

autoUpdater.on("error", (): void => {
mainWindow.webContents.send(IpcChannels.ueliUpdateCheckError);
});

autoUpdater.on("update-downloaded", (): void => {
autoUpdater.quitAndInstall();
});

ipcMain.on(IpcChannels.hideWindow, hideMainWindow);
ipcMain.on(IpcChannels.ueliReload, reloadApp);
ipcMain.on(IpcChannels.ueliExit, quitApp);
Expand Down
5 changes: 5 additions & 0 deletions src/ts/operating-system-settings/windows/windows-10-app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface Windows10App {
executionArgument: string;
icon: string;
name: string;
}
Loading

0 comments on commit f3b9a89

Please sign in to comment.