Tests/OrgAppTests/EditorCommandListTests.swift

6e76718b67275264fce9c9041e50ec01592edace
orgstar/Tests/OrgAppTests/EditorCommandListTests.swift

24 lines · 1409 bytes

 1import Foundation
 2import Testing
 3@testable import OrgApp
 4
 5/// The iOS editor's Commands list, read from its source as CommandTitleTests does: the target
 6/// isn't built by `swift test`.
 7struct EditorCommandListTests {
 8    static let root = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
 9
10    static func viewCommands() throws -> [(id: String, title: String)] {
11        let source = try String(contentsOf: root.appendingPathComponent("Sources/OrgstarMobile/EditorScreen.swift"), encoding: .utf8)
12        return source.matches(of: /\("((?:app|org|edit|editor|view)\.[^"]+)", "([^"\\]+)"\)/).map { (String($0.1), String($0.2)) }
13    }
14
15    /// #236: Export is in Commands, under Export, since the iPhone toolbar has no room for it.
16    @Test func exportIsInTheEditorsCommands() throws {
17        let commands = try Self.viewCommands()
18        #expect(commands.contains { $0 == ("app.export-dialog", "Export…") })
19        #expect(commands.contains { $0 == ("app.export-subtree-dialog", "Export Subtree…") })
20        let export = try #require(CommandGroups.commandList.firstIndex { $0.prefixes.contains("app.export") })
21        #expect(CommandGroups.group(of: "app.export-dialog", in: CommandGroups.commandList) == export)
22        #expect(CommandGroups.group(of: "app.export-subtree-dialog", in: CommandGroups.commandList) == export)
23    }
24}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form