186 lines
5.7 KiB
JavaScript
186 lines
5.7 KiB
JavaScript
/**
|
|
* Unit tests for useHelp hook
|
|
* Tests help system hook functionality and context-sensitive help utilities
|
|
* Requirements: 9.2, 9.5
|
|
*/
|
|
|
|
describe("useHelp Hook", () => {
|
|
test("should have useHelp hook available", () => {
|
|
const useHelp = require("../../../src/tui/hooks/useHelp.js");
|
|
expect(typeof useHelp).toBe("function");
|
|
});
|
|
|
|
test("should import required dependencies", () => {
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const useHelpPath = path.join(
|
|
__dirname,
|
|
"../../../src/tui/hooks/useHelp.js"
|
|
);
|
|
const useHelpContent = fs.readFileSync(useHelpPath, "utf8");
|
|
|
|
expect(useHelpContent).toContain('require("react")');
|
|
expect(useHelpContent).toContain('require("../providers/AppProvider.jsx")');
|
|
expect(useHelpContent).toContain('require("../utils/keyboardHandlers.js")');
|
|
});
|
|
|
|
test("should use AppContext", () => {
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const useHelpPath = path.join(
|
|
__dirname,
|
|
"../../../src/tui/hooks/useHelp.js"
|
|
);
|
|
const useHelpContent = fs.readFileSync(useHelpPath, "utf8");
|
|
|
|
expect(useHelpContent).toContain("useContext(AppContext)");
|
|
expect(useHelpContent).toContain(
|
|
"useHelp must be used within an AppProvider"
|
|
);
|
|
});
|
|
|
|
test("should provide help state properties", () => {
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const useHelpPath = path.join(
|
|
__dirname,
|
|
"../../../src/tui/hooks/useHelp.js"
|
|
);
|
|
const useHelpContent = fs.readFileSync(useHelpPath, "utf8");
|
|
|
|
expect(useHelpContent).toContain(
|
|
"isHelpVisible: appState.uiState.helpVisible"
|
|
);
|
|
expect(useHelpContent).toContain("currentScreen: appState.currentScreen");
|
|
});
|
|
|
|
test("should provide help actions", () => {
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const useHelpPath = path.join(
|
|
__dirname,
|
|
"../../../src/tui/hooks/useHelp.js"
|
|
);
|
|
const useHelpContent = fs.readFileSync(useHelpPath, "utf8");
|
|
|
|
expect(useHelpContent).toContain("toggleHelp");
|
|
expect(useHelpContent).toContain("showHelp");
|
|
expect(useHelpContent).toContain("hideHelp");
|
|
});
|
|
|
|
test("should provide help content utilities", () => {
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const useHelpPath = path.join(
|
|
__dirname,
|
|
"../../../src/tui/hooks/useHelp.js"
|
|
);
|
|
const useHelpContent = fs.readFileSync(useHelpPath, "utf8");
|
|
|
|
expect(useHelpContent).toContain("getScreenShortcuts:");
|
|
expect(useHelpContent).toContain("getGlobalShortcuts:");
|
|
expect(useHelpContent).toContain("getAllShortcuts:");
|
|
expect(useHelpContent).toContain("helpSystem.getScreenShortcuts");
|
|
expect(useHelpContent).toContain("helpSystem.getGlobalShortcuts");
|
|
});
|
|
|
|
test("should provide help system utilities", () => {
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const useHelpPath = path.join(
|
|
__dirname,
|
|
"../../../src/tui/hooks/useHelp.js"
|
|
);
|
|
const useHelpContent = fs.readFileSync(useHelpPath, "utf8");
|
|
|
|
expect(useHelpContent).toContain("isHelpAvailable:");
|
|
expect(useHelpContent).toContain("getHelpTitle:");
|
|
expect(useHelpContent).toContain("getHelpDescription:");
|
|
});
|
|
|
|
test("should define screen titles mapping", () => {
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const useHelpPath = path.join(
|
|
__dirname,
|
|
"../../../src/tui/hooks/useHelp.js"
|
|
);
|
|
const useHelpContent = fs.readFileSync(useHelpPath, "utf8");
|
|
|
|
expect(useHelpContent).toContain('"main-menu": "Main Menu Help"');
|
|
expect(useHelpContent).toContain('configuration: "Configuration Help"');
|
|
expect(useHelpContent).toContain('operation: "Operation Help"');
|
|
expect(useHelpContent).toContain('scheduling: "Scheduling Help"');
|
|
expect(useHelpContent).toContain('logs: "Log Viewer Help"');
|
|
expect(useHelpContent).toContain('"tag-analysis": "Tag Analysis Help"');
|
|
});
|
|
|
|
test("should define screen descriptions mapping", () => {
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const useHelpPath = path.join(
|
|
__dirname,
|
|
"../../../src/tui/hooks/useHelp.js"
|
|
);
|
|
const useHelpContent = fs.readFileSync(useHelpPath, "utf8");
|
|
|
|
expect(useHelpContent).toContain("Use the main menu to navigate");
|
|
expect(useHelpContent).toContain(
|
|
"Configure your Shopify store credentials"
|
|
);
|
|
expect(useHelpContent).toContain(
|
|
"Execute price update or rollback operations"
|
|
);
|
|
expect(useHelpContent).toContain(
|
|
"Schedule operations to run at specific times"
|
|
);
|
|
expect(useHelpContent).toContain("View and search through operation logs");
|
|
expect(useHelpContent).toContain(
|
|
"Analyze product tags and get recommendations"
|
|
);
|
|
});
|
|
|
|
test("should have fallback values", () => {
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const useHelpPath = path.join(
|
|
__dirname,
|
|
"../../../src/tui/hooks/useHelp.js"
|
|
);
|
|
const useHelpContent = fs.readFileSync(useHelpPath, "utf8");
|
|
|
|
expect(useHelpContent).toContain('"General Help"');
|
|
expect(useHelpContent).toContain(
|
|
"General keyboard shortcuts and navigation"
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("useHelp Hook Integration", () => {
|
|
test("should be used by HelpOverlay component", () => {
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const helpOverlayPath = path.join(
|
|
__dirname,
|
|
"../../../src/tui/components/common/HelpOverlay.jsx"
|
|
);
|
|
const helpOverlayContent = fs.readFileSync(helpOverlayPath, "utf8");
|
|
|
|
expect(helpOverlayContent).toContain('require("../../hooks/useHelp.js")');
|
|
expect(helpOverlayContent).toContain("useHelp()");
|
|
});
|
|
|
|
test("should integrate with helpSystem utilities", () => {
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const useHelpPath = path.join(
|
|
__dirname,
|
|
"../../../src/tui/hooks/useHelp.js"
|
|
);
|
|
const useHelpContent = fs.readFileSync(useHelpPath, "utf8");
|
|
|
|
expect(useHelpContent).toContain("helpSystem");
|
|
expect(useHelpContent).toContain("keyboardHandlers");
|
|
});
|
|
});
|