@opensumi/playwright 2.21.13-rc-1673328992.0 → 2.21.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/lib/app.d.ts +1 -2
  2. package/lib/app.d.ts.map +1 -1
  3. package/lib/app.js +9 -21
  4. package/lib/app.js.map +1 -1
  5. package/lib/component-editor.d.ts +2 -2
  6. package/lib/debug-view.d.ts +0 -10
  7. package/lib/debug-view.d.ts.map +1 -1
  8. package/lib/debug-view.js +1 -41
  9. package/lib/debug-view.js.map +1 -1
  10. package/lib/editor.d.ts +5 -5
  11. package/lib/editor.d.ts.map +1 -1
  12. package/lib/editor.js.map +1 -1
  13. package/lib/explorer-view.d.ts +0 -4
  14. package/lib/explorer-view.d.ts.map +1 -1
  15. package/lib/explorer-view.js +10 -36
  16. package/lib/explorer-view.js.map +1 -1
  17. package/lib/filetree-view.d.ts +1 -1
  18. package/lib/filetree-view.js +2 -2
  19. package/lib/filetree-view.js.map +1 -1
  20. package/lib/index.d.ts +1 -2
  21. package/lib/index.d.ts.map +1 -1
  22. package/lib/index.js +1 -2
  23. package/lib/index.js.map +1 -1
  24. package/lib/menu.d.ts +1 -1
  25. package/lib/opened-editor-view.d.ts +2 -2
  26. package/lib/opened-editor-view.d.ts.map +1 -1
  27. package/lib/opened-editor-view.js +4 -4
  28. package/lib/opened-editor-view.js.map +1 -1
  29. package/lib/panel.js +2 -2
  30. package/lib/panel.js.map +1 -1
  31. package/lib/search-view.d.ts +0 -34
  32. package/lib/search-view.d.ts.map +1 -1
  33. package/lib/search-view.js +4 -196
  34. package/lib/search-view.js.map +1 -1
  35. package/lib/terminal.d.ts +7 -0
  36. package/lib/terminal.d.ts.map +1 -0
  37. package/lib/terminal.js +25 -0
  38. package/lib/terminal.js.map +1 -0
  39. package/lib/tests/debug.test.js +0 -49
  40. package/lib/tests/debug.test.js.map +1 -1
  41. package/lib/tests/editor.test.js +2 -2
  42. package/lib/tests/explorer-view.test.js +5 -129
  43. package/lib/tests/explorer-view.test.js.map +1 -1
  44. package/lib/tests/scm.test.js +4 -42
  45. package/lib/tests/scm.test.js.map +1 -1
  46. package/lib/tests/search-view.test.js +8 -191
  47. package/lib/tests/search-view.test.js.map +1 -1
  48. package/lib/text-editor.d.ts +2 -2
  49. package/lib/text-editor.d.ts.map +1 -1
  50. package/lib/text-editor.js.map +1 -1
  51. package/lib/tree-node.d.ts +1 -3
  52. package/lib/tree-node.d.ts.map +1 -1
  53. package/lib/tree-node.js +4 -4
  54. package/lib/tree-node.js.map +1 -1
  55. package/lib/utils/key.d.ts +0 -1
  56. package/lib/utils/key.d.ts.map +1 -1
  57. package/lib/utils/key.js +1 -6
  58. package/lib/utils/key.js.map +1 -1
  59. package/lib/view.js +1 -1
  60. package/lib/view.js.map +1 -1
  61. package/package.json +11 -12
  62. package/lib/diff-editor.d.ts +0 -4
  63. package/lib/diff-editor.d.ts.map +0 -1
  64. package/lib/diff-editor.js +0 -8
  65. package/lib/diff-editor.js.map +0 -1
  66. package/lib/outline-view.d.ts +0 -9
  67. package/lib/outline-view.d.ts.map +0 -1
  68. package/lib/outline-view.js +0 -38
  69. package/lib/outline-view.js.map +0 -1
  70. package/lib/output-view.d.ts +0 -10
  71. package/lib/output-view.d.ts.map +0 -1
  72. package/lib/output-view.js +0 -78
  73. package/lib/output-view.js.map +0 -1
  74. package/lib/scm-view.d.ts +0 -21
  75. package/lib/scm-view.d.ts.map +0 -1
  76. package/lib/scm-view.js +0 -65
  77. package/lib/scm-view.js.map +0 -1
  78. package/lib/source-control-view.d.ts +0 -8
  79. package/lib/source-control-view.d.ts.map +0 -1
  80. package/lib/source-control-view.js +0 -45
  81. package/lib/source-control-view.js.map +0 -1
  82. package/lib/terminal-view.d.ts +0 -10
  83. package/lib/terminal-view.d.ts.map +0 -1
  84. package/lib/terminal-view.js +0 -50
  85. package/lib/terminal-view.js.map +0 -1
  86. package/lib/tests/output.test.d.ts +0 -2
  87. package/lib/tests/output.test.d.ts.map +0 -1
  88. package/lib/tests/output.test.js +0 -76
  89. package/lib/tests/output.test.js.map +0 -1
  90. package/lib/tests/settings.test.d.ts +0 -2
  91. package/lib/tests/settings.test.d.ts.map +0 -1
  92. package/lib/tests/settings.test.js +0 -95
  93. package/lib/tests/settings.test.js.map +0 -1
  94. package/src/app.ts +0 -148
  95. package/src/component-editor.ts +0 -64
  96. package/src/constans/index.ts +0 -18
  97. package/src/context-menu.ts +0 -27
  98. package/src/debug-view.ts +0 -73
  99. package/src/diff-editor.ts +0 -3
  100. package/src/editor.ts +0 -130
  101. package/src/explorer-view.ts +0 -149
  102. package/src/filetree-view.ts +0 -28
  103. package/src/index.ts +0 -20
  104. package/src/menu-item.ts +0 -40
  105. package/src/menu.ts +0 -69
  106. package/src/menubar.ts +0 -53
  107. package/src/opened-editor-view.ts +0 -28
  108. package/src/outline-view.ts +0 -37
  109. package/src/output-view.ts +0 -76
  110. package/src/panel.ts +0 -50
  111. package/src/quick-command-palette.ts +0 -62
  112. package/src/quick-open-palette.ts +0 -62
  113. package/src/scm-view.ts +0 -72
  114. package/src/search-view.ts +0 -260
  115. package/src/source-control-view.ts +0 -44
  116. package/src/terminal-view.ts +0 -50
  117. package/src/tests/app.test.ts +0 -16
  118. package/src/tests/debug.test.ts +0 -121
  119. package/src/tests/editor.test.ts +0 -143
  120. package/src/tests/explorer-view.test.ts +0 -329
  121. package/src/tests/hooks/index.ts +0 -13
  122. package/src/tests/keymaps.test.ts +0 -118
  123. package/src/tests/language.test.ts +0 -55
  124. package/src/tests/output.test.ts +0 -87
  125. package/src/tests/scm.test.ts +0 -84
  126. package/src/tests/search-view.test.ts +0 -239
  127. package/src/tests/settings.test.ts +0 -115
  128. package/src/tests/workspaces/debug/.sumi/launch.json +0 -15
  129. package/src/tests/workspaces/debug/index.js +0 -18
  130. package/src/tests/workspaces/default/editor.js +0 -0
  131. package/src/tests/workspaces/default/editor2.js +0 -87
  132. package/src/tests/workspaces/default/editor3.js +0 -0
  133. package/src/tests/workspaces/default/test/test.js +0 -1
  134. package/src/tests/workspaces/git-workspace/a.js +0 -0
  135. package/src/tests/workspaces/language/definition.ts +0 -12
  136. package/src/tests/workspaces/language/reference.ts +0 -9
  137. package/src/tests/workspaces/search/index.js +0 -5
  138. package/src/tests/workspaces/search/index2.js +0 -1
  139. package/src/text-editor.ts +0 -318
  140. package/src/tree-node.ts +0 -98
  141. package/src/utils/element.ts +0 -35
  142. package/src/utils/index.ts +0 -2
  143. package/src/utils/key.ts +0 -11
  144. package/src/view-base.ts +0 -11
  145. package/src/view.ts +0 -90
  146. package/src/workspace.ts +0 -36
package/src/app.ts DELETED
@@ -1,148 +0,0 @@
1
- import { ElementHandle, Page } from '@playwright/test';
2
-
3
- import { Disposable } from '@opensumi/ide-utils';
4
-
5
- import { IComponentEditorInfo } from './component-editor';
6
- import { OpenSumiEditor } from './editor';
7
- import { OpenSumiExplorerView } from './explorer-view';
8
- import { OpenSumiMenubar } from './menubar';
9
- import { OpenSumiPanel } from './panel';
10
- import { OpenSumiCommandPalette } from './quick-command-palette';
11
- import { OpenSumiQuickOpenPalette } from './quick-open-palette';
12
- import { OpenSumiTreeNode } from './tree-node';
13
- import { OpenSumiWorkspace } from './workspace';
14
-
15
- export interface AppData {
16
- loadingSelector: string;
17
- mainSelector: string;
18
- }
19
-
20
- export const DefaultAppData: AppData = {
21
- loadingSelector: '.loading_indicator',
22
- mainSelector: '#main',
23
- };
24
-
25
- export class OpenSumiApp extends Disposable {
26
- private _loaded = false;
27
- private _quickCommandPalette: OpenSumiCommandPalette;
28
- private _quickOpenPalette: OpenSumiQuickOpenPalette;
29
- private _menubar: OpenSumiMenubar;
30
-
31
- static async load(page: Page, workspace: OpenSumiWorkspace): Promise<OpenSumiApp> {
32
- return this.loadApp(page, workspace, OpenSumiApp);
33
- }
34
-
35
- static async loadApp<T extends OpenSumiApp>(
36
- page: Page,
37
- workspace: OpenSumiWorkspace,
38
- appFactory: new (page: Page) => T,
39
- ): Promise<T> {
40
- await workspace.initWorksapce();
41
- const app = new appFactory(page);
42
- await app.load(workspace);
43
- return app;
44
- }
45
-
46
- public constructor(public page: Page, protected appData = DefaultAppData) {
47
- super();
48
- this._quickCommandPalette = new OpenSumiCommandPalette(this);
49
- this._quickOpenPalette = new OpenSumiQuickOpenPalette(this);
50
- this._menubar = new OpenSumiMenubar(this);
51
- }
52
-
53
- get quickCommandPalette() {
54
- return this._quickCommandPalette;
55
- }
56
-
57
- get quickOpenPalette() {
58
- return this._quickOpenPalette;
59
- }
60
-
61
- get menubar() {
62
- return this._menubar;
63
- }
64
-
65
- protected async load(workspace: OpenSumiWorkspace): Promise<void> {
66
- this.disposables.push(workspace);
67
- const now = Date.now();
68
- await this.loadOrReload(this.page, `/#${workspace.workspace.codeUri.fsPath}`);
69
- await this.page.waitForSelector(this.appData.loadingSelector, { state: 'detached' });
70
- const time = Date.now() - now;
71
- // eslint-disable-next-line no-console
72
- console.log(`Loading page cost ${time} ms`);
73
- await this.page.waitForSelector(this.appData.mainSelector);
74
- await this.waitForInitialized();
75
- }
76
-
77
- protected async loadOrReload(page: Page, url = '/') {
78
- if (!this._loaded) {
79
- const wasLoadedAlready = await page.isVisible(this.appData.mainSelector);
80
- await page.goto(url);
81
- if (wasLoadedAlready) {
82
- await page.reload();
83
- }
84
- this._loaded = true;
85
- } else {
86
- await page.reload();
87
- }
88
- }
89
-
90
- async isMainLayoutVisible(): Promise<boolean> {
91
- const contentPanel = await this.page.$('#main');
92
- return !!contentPanel && contentPanel.isVisible();
93
- }
94
-
95
- async open<T extends OpenSumiPanel>(PanelConstruction: new (app: OpenSumiApp) => T) {
96
- const panel = new PanelConstruction(this);
97
- if (await panel.isVisible()) {
98
- return panel;
99
- }
100
- await panel.open();
101
- return panel;
102
- }
103
-
104
- async openEditor<T extends OpenSumiEditor>(
105
- EditorConstruction: new (app: OpenSumiApp, element?: OpenSumiTreeNode) => T,
106
- explorer: OpenSumiExplorerView,
107
- filePath: string,
108
- preview = true,
109
- ) {
110
- const node = await explorer.getFileStatTreeNodeByPath(filePath);
111
- if (!node || (await node?.isFolder())) {
112
- throw Error(`File ${filePath} could not be opened on the editor`);
113
- }
114
- const editor = new EditorConstruction(this, node);
115
- await editor.open(preview);
116
- return editor;
117
- }
118
-
119
- // use for component editors
120
- async openComponentEditor<T extends OpenSumiEditor>(
121
- EditorConstruction: new (app: OpenSumiApp, info: IComponentEditorInfo) => T,
122
- path: string,
123
- name: string,
124
- containerSelector: string,
125
- ) {
126
- const editor = new EditorConstruction(this, { path, name, containerSelector });
127
- await editor.open();
128
- return editor;
129
- }
130
-
131
- async getDialogButton(value: string): Promise<ElementHandle<SVGElement | HTMLElement> | void> {
132
- const buttonWrapper = await this.page.$('.kt-dialog-buttonWrap');
133
- const buttons = await buttonWrapper?.$$('.kt-button');
134
- if (buttons) {
135
- for (const button of buttons) {
136
- const text = await button.textContent();
137
- if (text === value) {
138
- return button;
139
- }
140
- }
141
- }
142
- }
143
-
144
- async waitForInitialized(): Promise<void> {
145
- // custom app initialize process.
146
- // empty by default
147
- }
148
- }
@@ -1,64 +0,0 @@
1
- import { OpenSumiApp } from './app';
2
- import { OpenSumiContextMenu } from './context-menu';
3
- import { OpenSumiEditor } from './editor';
4
- import { isElementVisible } from './utils';
5
-
6
- export interface IComponentEditorInfo {
7
- path: string;
8
- name: string;
9
- containerSelector: string;
10
- }
11
-
12
- export class OpenSumiComponentEditor extends OpenSumiEditor {
13
- constructor(app: OpenSumiApp, private readonly info: IComponentEditorInfo) {
14
- super(app);
15
- }
16
-
17
- async openTabContextMenu() {
18
- const view = await this.getTab();
19
- if (!view) {
20
- return;
21
- }
22
- return OpenSumiContextMenu.open(this.app, async () => view);
23
- }
24
-
25
- async close() {
26
- const contextMenu = await this.openTabContextMenu();
27
- await contextMenu?.isOpen();
28
- const close = await contextMenu?.menuItemByName('Close');
29
- await close?.click();
30
- }
31
-
32
- async getTab() {
33
- const tabsItems = await (await this.getTabElement())?.$$("[class*='kt_editor_tab___']");
34
-
35
- if (!tabsItems) {
36
- return;
37
- }
38
-
39
- for (const item of tabsItems) {
40
- const uri = await item.getAttribute('data-uri');
41
- if (uri?.includes(this.info.path)) {
42
- return item;
43
- }
44
- }
45
- }
46
-
47
- async getContainer() {
48
- return await super.getContainer(this.info.containerSelector);
49
- }
50
-
51
- async isVisible() {
52
- const container = await this.getContainer();
53
- if (!container) {
54
- return false;
55
- }
56
- return await isElementVisible(Promise.resolve(container));
57
- }
58
-
59
- async open() {
60
- const tab = await this.getTab();
61
- await tab?.click();
62
- return this;
63
- }
64
- }
@@ -1,18 +0,0 @@
1
- const VIEW_CONTAINERS_PREFIX = 'opensumi';
2
-
3
- export namespace OPENSUMI_VIEW_CONTAINERS {
4
- export const LEFT_TABBAR_PANEL = `${VIEW_CONTAINERS_PREFIX}-left-tabbar-panel`;
5
- export const LEFT_TABBAR = `${VIEW_CONTAINERS_PREFIX}-left-tabbar`;
6
- export const RIGHT_TABBAR_PANEL = `${VIEW_CONTAINERS_PREFIX}-right-tabbar-panel`;
7
- export const RIGHT_TABBAR = `${VIEW_CONTAINERS_PREFIX}-right-tabbar`;
8
- export const BOTTOM_TABBAR = `${VIEW_CONTAINERS_PREFIX}-bottom-tabbar`;
9
- export const BOTTOM_TABBAR_PANEL = `${VIEW_CONTAINERS_PREFIX}-bottom-tabbar-panel`;
10
- export const STATUSBAR = `${VIEW_CONTAINERS_PREFIX}-statusbar`;
11
- export const MENUBAR = `${VIEW_CONTAINERS_PREFIX}-menubar`;
12
- export const EDITOR = `${VIEW_CONTAINERS_PREFIX}-editor`;
13
- export const EDITOR_TABS = `${VIEW_CONTAINERS_PREFIX}-editor-tabs`;
14
- export const QUICKPICK = `${VIEW_CONTAINERS_PREFIX}-quickpick`;
15
- export const QUICKPICK_INPUT = `${VIEW_CONTAINERS_PREFIX}-quickpick-input`;
16
- export const QUICKPICK_TABS = `${VIEW_CONTAINERS_PREFIX}-quickpick-tabs`;
17
- export const QUICKPICK_ITEM = `${VIEW_CONTAINERS_PREFIX}-quickpick-item`;
18
- }
@@ -1,27 +0,0 @@
1
- import { ElementHandle } from '@playwright/test';
2
-
3
- import { OpenSumiApp } from './app';
4
- import { OpenSumiMenu } from './menu';
5
-
6
- export class OpenSumiContextMenu extends OpenSumiMenu {
7
- public static async openAt(app: OpenSumiApp, x: number, y: number): Promise<OpenSumiContextMenu> {
8
- await app.page.mouse.move(x, y);
9
- await app.page.mouse.click(x, y, { button: 'right' });
10
- return OpenSumiContextMenu.returnWhenVisible(app);
11
- }
12
-
13
- public static async open(
14
- app: OpenSumiApp,
15
- element: () => Promise<ElementHandle<SVGElement | HTMLElement>>,
16
- ): Promise<OpenSumiContextMenu> {
17
- const elementHandle = await element();
18
- await elementHandle.click({ button: 'right' });
19
- return OpenSumiContextMenu.returnWhenVisible(app);
20
- }
21
-
22
- private static async returnWhenVisible(app: OpenSumiApp): Promise<OpenSumiContextMenu> {
23
- const menu = new OpenSumiContextMenu(app);
24
- await menu.waitForVisible();
25
- return menu;
26
- }
27
- }
package/src/debug-view.ts DELETED
@@ -1,73 +0,0 @@
1
- import { OpenSumiApp } from './app';
2
- import { OpenSumiPanel } from './panel';
3
-
4
- type DebugToolbarActionType = 'Continue' | 'Step Over' | 'Step Into' | 'Step Out' | 'Restart' | 'Stop';
5
- export class OpenSumiDebugView extends OpenSumiPanel {
6
- private selector = {
7
- toolbarClass: "[class*='debug_configuration_toolbar___']",
8
- actionStartID: "[id='debug.action.start']",
9
- };
10
-
11
- constructor(app: OpenSumiApp) {
12
- super(app, 'DEBUG');
13
- }
14
-
15
- async getDebugToolbar() {
16
- return this.page.$('[class*="debug_toolbar_wrapper__"]');
17
- }
18
-
19
- async start(): Promise<void> {
20
- const toolbarLocator = this.app.page.locator(this.selector.toolbarClass);
21
- if (!toolbarLocator) {
22
- return;
23
- }
24
-
25
- const element = await toolbarLocator.elementHandle();
26
- const startIcon = await element?.$(this.selector.actionStartID);
27
- await startIcon?.click();
28
- }
29
-
30
- async getToobarAction(action: DebugToolbarActionType) {
31
- const toolbar = await this.getDebugToolbar();
32
- const buttons = await toolbar?.$$('[class*="debug_action__"]');
33
- if (!buttons) {
34
- return;
35
- }
36
- for (const button of buttons) {
37
- const title = await button.getAttribute('title');
38
- if (title === action) {
39
- return button;
40
- }
41
- }
42
- }
43
-
44
- async stop() {
45
- const action = await this.getToobarAction('Stop');
46
- await action?.click();
47
- }
48
-
49
- async continue() {
50
- const action = await this.getToobarAction('Continue');
51
- await action?.click();
52
- }
53
-
54
- async restart() {
55
- const action = await this.getToobarAction('Restart');
56
- await action?.click();
57
- }
58
-
59
- async stepInto() {
60
- const action = await this.getToobarAction('Step Into');
61
- await action?.click();
62
- }
63
-
64
- async stepOver() {
65
- const action = await this.getToobarAction('Step Over');
66
- await action?.click();
67
- }
68
-
69
- async stepOut() {
70
- const action = await this.getToobarAction('Step Out');
71
- await action?.click();
72
- }
73
- }
@@ -1,3 +0,0 @@
1
- import { OpenSumiTextEditor } from './text-editor';
2
-
3
- export class OpenSumiDiffEditor extends OpenSumiTextEditor {}
package/src/editor.ts DELETED
@@ -1,130 +0,0 @@
1
- import { OpenSumiApp } from './app';
2
- import { OPENSUMI_VIEW_CONTAINERS } from './constans';
3
- import { OpenSumiTreeNode } from './tree-node';
4
- import { OpenSumiView } from './view';
5
-
6
- export class OpenSumiEditor extends OpenSumiView {
7
- constructor(app: OpenSumiApp, private readonly filestatElement?: OpenSumiTreeNode) {
8
- super(app, {
9
- tabSelector: `#${OPENSUMI_VIEW_CONTAINERS.EDITOR_TABS}`,
10
- viewSelector: `#${OPENSUMI_VIEW_CONTAINERS.EDITOR}`,
11
- name: 'Editor',
12
- });
13
- }
14
-
15
- async getTab() {
16
- const path = (await this.filestatElement?.getFsPath()) || '';
17
- const tabsItems = await (await this.getTabElement())?.$$("[class*='kt_editor_tab___']");
18
-
19
- if (!tabsItems) {
20
- return;
21
- }
22
-
23
- for (const item of tabsItems) {
24
- const uri = await item.getAttribute('data-uri');
25
- if (uri?.includes(path)) {
26
- return item;
27
- }
28
- }
29
- }
30
-
31
- async getContainer(selector?: string) {
32
- if (!selector) {
33
- return;
34
- }
35
- const container = await (await this.getViewElement())?.$(selector);
36
- return container;
37
- }
38
-
39
- async getCurrentTab() {
40
- return await (await this.getTabElement())?.waitForSelector("[class*='kt_editor_tab_current___']");
41
- }
42
-
43
- async open(preview?: boolean) {
44
- await this.filestatElement?.open(preview);
45
- // waiting editor render, it maybe fail while opening a large file.
46
- await this.app.page.waitForTimeout(1000);
47
- return this;
48
- }
49
-
50
- async isPreview() {
51
- const currentTab = await this.getTab();
52
- const isPreview = (await currentTab?.getAttribute('class'))?.includes('kt_editor_tab_preview___');
53
- return !!isPreview;
54
- }
55
-
56
- async isDirty() {
57
- const dirtyIcon = await (await this.getTab())?.$("[class*='dirty___']");
58
- const className = await dirtyIcon?.getAttribute('class');
59
- const hidden = className?.includes('hidden__');
60
- return !hidden;
61
- }
62
-
63
- async save() {
64
- await this.activate();
65
- if (!(await this.isDirty())) {
66
- return;
67
- }
68
- const dirtyIcon = await (await this.getTab())?.$("[class*='dirty___']");
69
- await this.app.menubar.trigger('File', 'Save File');
70
- // waiting for saved
71
- await dirtyIcon?.waitForElementState('hidden');
72
- }
73
-
74
- async close() {
75
- const currentTab = await this.getTabElement();
76
- await currentTab?.hover({
77
- position: {
78
- x: 10,
79
- y: 10,
80
- },
81
- });
82
- const closeIcon = await currentTab?.$("[class*='close_tab___']");
83
- await closeIcon?.click();
84
- }
85
-
86
- async saveAndClose() {
87
- await this.save();
88
- await this.close();
89
- }
90
-
91
- async undo(times = 1) {
92
- await this.activate();
93
- for (let i = 0; i < times; i++) {
94
- await this.app.menubar.trigger('Edit', 'Undo');
95
- await this.app.page.waitForTimeout(200);
96
- }
97
- }
98
-
99
- async redo(times = 1) {
100
- await this.activate();
101
- for (let i = 0; i < times; i++) {
102
- await this.app.menubar.trigger('Edit', 'Redo');
103
- await this.app.page.waitForTimeout(200);
104
- }
105
- }
106
-
107
- async triggerTitleMenu(name: string) {
108
- const tab = await this.getTabElement();
109
- const actions = (await tab?.$$('[class*="iconAction___"]')) || [];
110
- for (const action of actions) {
111
- const title = await action.getAttribute('title');
112
- if (title === name) {
113
- await action.click();
114
- break;
115
- }
116
- }
117
- }
118
-
119
- async triggerTitleMenuById(id: string) {
120
- const tab = await this.getTabElement();
121
- const actions = (await tab?.$$('[class*="iconAction___"]')) || [];
122
- for (const action of actions) {
123
- const title = await action.getAttribute('id');
124
- if (title === id) {
125
- await action.click();
126
- break;
127
- }
128
- }
129
- }
130
- }
@@ -1,149 +0,0 @@
1
- import { OpenSumiApp } from './app';
2
- import { OpenSumiFileTreeView } from './filetree-view';
3
- import { OpenSumiOpenedEditorView } from './opened-editor-view';
4
- import { OpenSumiOutlineView } from './outline-view';
5
- import { OpenSumiPanel } from './panel';
6
- import { OpenSumiTreeNode } from './tree-node';
7
-
8
- export class OpenSumiExplorerFileStatNode extends OpenSumiTreeNode {
9
- async getFsPath() {
10
- return await this.elementHandle.getAttribute('title');
11
- }
12
-
13
- async isFolder() {
14
- const icon = await this.elementHandle.$("[class*='file_icon___']");
15
- if (!icon) {
16
- return false;
17
- }
18
- const className = await icon.getAttribute('class');
19
- return className?.includes('folder-icon');
20
- }
21
-
22
- async getMenuItemByName(name: string) {
23
- const contextMenu = await this.openContextMenu();
24
- const menuItem = await contextMenu.menuItemByName(name);
25
- return menuItem;
26
- }
27
-
28
- async open(preview = true) {
29
- if (!preview) {
30
- await this.elementHandle.dblclick();
31
- } else {
32
- await this.elementHandle.click();
33
- }
34
- }
35
-
36
- async isDirty() {
37
- const classname = await this.elementHandle.getAttribute('class');
38
- if (classname?.includes('mod_dirty__')) {
39
- return true;
40
- }
41
- return false;
42
- }
43
- }
44
-
45
- export class OpenSumiExplorerOpenedEditorNode extends OpenSumiTreeNode {
46
- async getRelativePath() {
47
- return await (await this.elementHandle.$('[class*="opened_editor_node_description__"]'))?.textContent();
48
- }
49
-
50
- async getFsPath() {
51
- return await this.elementHandle.getAttribute('title');
52
- }
53
-
54
- async isGroup() {
55
- const icon = await this.elementHandle.waitForSelector("[class*='file_icon___']");
56
- const className = await icon.getAttribute('class');
57
- return className?.includes('folder-icon');
58
- }
59
-
60
- async getMenuItemByName(name: string) {
61
- const contextMenu = await this.openContextMenu();
62
- const menuItem = await contextMenu.menuItemByName(name);
63
- return menuItem;
64
- }
65
-
66
- async open() {
67
- await this.elementHandle.click();
68
- }
69
- }
70
-
71
- export class OpenSumiExplorerView extends OpenSumiPanel {
72
- private _fileTreeView: OpenSumiFileTreeView;
73
- private _openedEditorView: OpenSumiOpenedEditorView;
74
- private _outlineView: OpenSumiOutlineView;
75
-
76
- constructor(app: OpenSumiApp) {
77
- super(app, 'EXPLORER');
78
- this._openedEditorView = new OpenSumiOpenedEditorView(this.app);
79
- this._outlineView = new OpenSumiOutlineView(this.app);
80
- }
81
-
82
- initFileTreeView(name: string) {
83
- this._fileTreeView = new OpenSumiFileTreeView(this.app, name);
84
- }
85
-
86
- get fileTreeView() {
87
- return this._fileTreeView;
88
- }
89
-
90
- get openedEditorView() {
91
- return this._openedEditorView;
92
- }
93
-
94
- get outlineView() {
95
- return this._outlineView;
96
- }
97
-
98
- async getFileStatTreeNodeByPath(path: string) {
99
- const treeItems = await (await this.fileTreeView.getViewElement())?.$$('[class*="file_tree_node__"]');
100
- if (!treeItems) {
101
- return;
102
- }
103
- let node;
104
- for (const item of treeItems) {
105
- const title = await item.getAttribute('title');
106
- if (title?.startsWith('Group')) {
107
- if (title === path) {
108
- node = item;
109
- break;
110
- }
111
- } else {
112
- // The title maybe `~/a.js • Untracked`
113
- if (title?.split(' ')[0]?.endsWith(path)) {
114
- node = item;
115
- break;
116
- }
117
- }
118
- }
119
- if (node) {
120
- return new OpenSumiExplorerFileStatNode(node, this.app);
121
- }
122
- }
123
-
124
- async getOpenedEditorTreeNodeByPath(path: string) {
125
- const treeItems = await (await this.openedEditorView.getViewElement())?.$$('[class*="opened_editor_node__"]');
126
- if (!treeItems) {
127
- return;
128
- }
129
- let node;
130
- for (const item of treeItems) {
131
- const title = await item.getAttribute('title');
132
- if (title?.startsWith('GROUP')) {
133
- if (title === path) {
134
- node = item;
135
- break;
136
- }
137
- } else {
138
- // The title maybe `~/a.js • Untracked`
139
- if (title?.split(' ')[0]?.endsWith(path)) {
140
- node = item;
141
- break;
142
- }
143
- }
144
- }
145
- if (node) {
146
- return new OpenSumiExplorerFileStatNode(node, this.app);
147
- }
148
- }
149
- }
@@ -1,28 +0,0 @@
1
- import { OpenSumiApp } from './app';
2
- import { OpenSumiView } from './view';
3
-
4
- export class OpenSumiFileTreeView extends OpenSumiView {
5
- constructor(app: OpenSumiApp, workspaceName: string) {
6
- super(app, {
7
- viewSelector: '[data-view-id="file-explorer"]',
8
- tabSelector: '[data-view-id="file-explorer"] [tabindex="0"]',
9
- name: workspaceName,
10
- });
11
- }
12
-
13
- async getTitleActionByName(name: string) {
14
- const header = await this.getTabElement();
15
- if (!header) {
16
- return;
17
- }
18
- await header.hover();
19
- const titleAction = await header.waitForSelector('[class*="titleActions___"]');
20
- const actions = await titleAction.$$('[class*="iconAction__"]');
21
- for (const action of actions) {
22
- const title = await action.getAttribute('title');
23
- if (name === title) {
24
- return action;
25
- }
26
- }
27
- }
28
- }
package/src/index.ts DELETED
@@ -1,20 +0,0 @@
1
- export * from './app';
2
- export * from './component-editor';
3
- export * from './context-menu';
4
- export * from './editor';
5
- export * from './explorer-view';
6
- export * from './filetree-view';
7
- export * from './menu-item';
8
- export * from './menu';
9
- export * from './menubar';
10
- export * from './opened-editor-view';
11
- export * from './panel';
12
- export * from './quick-command-palette';
13
- export * from './search-view';
14
- export * from './terminal-view';
15
- export * from './output-view';
16
- export * from './text-editor';
17
- export * from './tree-node';
18
- export * from './view-base';
19
- export * from './view';
20
- export * from './workspace';