|
| 1 | +/* |
| 2 | + * GNU AGPL-3.0 License |
| 3 | + * |
| 4 | + * Copyright (c) 2021 - present core.ai . All rights reserved. |
| 5 | + * |
| 6 | + * This program is free software: you can redistribute it and/or modify it |
| 7 | + * under the terms of the GNU Affero General Public License as published by |
| 8 | + * the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License |
| 14 | + * for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Affero General Public License |
| 17 | + * along with this program. If not, see https://opensource.org/licenses/AGPL-3.0. |
| 18 | + * |
| 19 | + */ |
| 20 | + |
| 21 | +/*global describe, it, expect, beforeAll, afterAll, beforeEach, afterEach, awaitsFor, awaitsForDone, awaits, jsPromise */ |
| 22 | + |
| 23 | +define(function (require, exports, module) { |
| 24 | + const SpecRunnerUtils = require("spec/SpecRunnerUtils"); |
| 25 | + |
| 26 | + describe("integration:TabBar", function () { |
| 27 | + let testWindow, PreferencesManager, $, FileSystem, MainViewManager, CommandManager, Commands, testFilePath; |
| 28 | + |
| 29 | + beforeAll(async function () { |
| 30 | + // Create the test window |
| 31 | + testWindow = await SpecRunnerUtils.createTestWindowAndRun(); |
| 32 | + // Get reference to useful modules |
| 33 | + $ = testWindow.$; |
| 34 | + PreferencesManager = testWindow.brackets.test.PreferencesManager; |
| 35 | + FileSystem = testWindow.brackets.test.FileSystem; |
| 36 | + MainViewManager = testWindow.brackets.test.MainViewManager; |
| 37 | + CommandManager = testWindow.brackets.test.CommandManager; |
| 38 | + Commands = testWindow.brackets.test.Commands; |
| 39 | + |
| 40 | + // Create a test file |
| 41 | + testFilePath = SpecRunnerUtils.getTempDirectory() + "/tabbar-test.js"; |
| 42 | + await SpecRunnerUtils.createTempDirectory(); |
| 43 | + await jsPromise(SpecRunnerUtils.createTextFile(testFilePath, "// Test file for TabBar", FileSystem)); |
| 44 | + |
| 45 | + // Open the test file |
| 46 | + await awaitsForDone( |
| 47 | + CommandManager.execute(Commands.FILE_OPEN, { fullPath: testFilePath }), |
| 48 | + "Open test file" |
| 49 | + ); |
| 50 | + }, 30000); |
| 51 | + |
| 52 | + afterAll(async function () { |
| 53 | + // Close the test file |
| 54 | + await awaitsForDone(CommandManager.execute(Commands.FILE_CLOSE_ALL), "Close all files"); |
| 55 | + |
| 56 | + testWindow = null; |
| 57 | + await SpecRunnerUtils.closeTestWindow(); |
| 58 | + await SpecRunnerUtils.removeTempDirectory(); |
| 59 | + }, 30000); |
| 60 | + |
| 61 | + describe("Visibility", function () { |
| 62 | + it("should show tab bar when the feature is enabled", async function () { |
| 63 | + // Enable the tab bar feature |
| 64 | + PreferencesManager.set("tabBar.options", { showTabBar: true, numberOfTabs: -1 }); |
| 65 | + |
| 66 | + // Wait for the tab bar to become visible |
| 67 | + await awaitsFor( |
| 68 | + function () { |
| 69 | + return $("#phoenix-tab-bar").is(":visible"); |
| 70 | + }, |
| 71 | + "Tab bar to become visible", |
| 72 | + 1000 |
| 73 | + ); |
| 74 | + |
| 75 | + // Verify the tab bar is visible |
| 76 | + expect($("#phoenix-tab-bar").is(":visible")).toBe(true); |
| 77 | + }); |
| 78 | + |
| 79 | + it("should hide tab bar when the feature is disabled", async function () { |
| 80 | + // Disable the tab bar feature |
| 81 | + PreferencesManager.set("tabBar.options", { showTabBar: false, numberOfTabs: -1 }); |
| 82 | + |
| 83 | + // Wait for the tab bar to become hidden |
| 84 | + await awaitsFor( |
| 85 | + function () { |
| 86 | + return !$("#phoenix-tab-bar").is(":visible"); |
| 87 | + }, |
| 88 | + "Tab bar to become hidden", |
| 89 | + 1000 |
| 90 | + ); |
| 91 | + |
| 92 | + // Verify the tab bar is not visible |
| 93 | + expect($("#phoenix-tab-bar").is(":visible")).toBe(false); |
| 94 | + }); |
| 95 | + }); |
| 96 | + }); |
| 97 | +}); |
0 commit comments