Skip to content

Commit 1f3654a

Browse files
authored
test: get correct git decoration on filetree (#1834)
1 parent 118c190 commit 1f3654a

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import path from 'path';
2+
3+
import { expect } from '@playwright/test';
4+
5+
import { OpenSumiApp } from '../app';
6+
import { OpenSumiExplorerView } from '../explorer-view';
7+
import { OpenSumiFileTreeView } from '../filetree-view';
8+
import { OpenSumiTerminal } from '../terminal';
9+
import { OpenSumiWorkspace } from '../workspace';
10+
11+
import test, { page } from './hooks';
12+
13+
let app: OpenSumiApp;
14+
let explorer: OpenSumiExplorerView;
15+
let fileTreeView: OpenSumiFileTreeView;
16+
let workspace: OpenSumiWorkspace;
17+
18+
test.describe('OpenSumi SCM Panel', () => {
19+
test.beforeAll(async () => {
20+
workspace = new OpenSumiWorkspace([path.resolve('./src/tests/workspaces/git-workspace')]);
21+
app = await OpenSumiApp.load(page, workspace);
22+
explorer = await app.open(OpenSumiExplorerView);
23+
explorer.initFileTreeView(workspace.workspace.displayName);
24+
fileTreeView = explorer.fileTreeView;
25+
});
26+
27+
test.afterAll(() => {
28+
app.dispose();
29+
});
30+
31+
test('The "U" charset should on the files tail after git initialized', async () => {
32+
await explorer.fileTreeView.open();
33+
const terminal = await app.open(OpenSumiTerminal);
34+
// There should have GIT on the PATH
35+
await terminal.sendText('git init');
36+
const action = await fileTreeView.getTitleActionByName('Refresh');
37+
await action?.click();
38+
await app.page.waitForTimeout(2000);
39+
const node = await explorer.getFileStatTreeNodeByPath('a.js');
40+
const badge = await node?.badge();
41+
expect(badge).toBe('U');
42+
});
43+
});

tools/playwright/src/tests/workspaces/git-workspace/a.js

Whitespace-only changes.

tools/playwright/src/tree-node.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { OpenSumiContextMenu } from './context-menu';
66
export interface IOpenSumiTreeNodeSelector {
77
labelClass: string;
88
descriptionClass: string;
9+
badgeClass: string;
910
toggleClass: string;
1011
selectedClass: string;
1112
focusedClass: string;
@@ -19,6 +20,7 @@ export class OpenSumiTreeNode {
1920
private selector: IOpenSumiTreeNodeSelector = {
2021
labelClass: "[class*='tree_node_displayname__']",
2122
descriptionClass: "[class*='tree_node_description__']",
23+
badgeClass: "[class*='tree_node_status___']",
2224
toggleClass: "[class*='expansion_toggle__']",
2325
selectedClass: "[class*='mod_selected__']",
2426
focusedClass: "[class*='mod_focused__']",
@@ -47,6 +49,14 @@ export class OpenSumiTreeNode {
4749
return descriptionElement.textContent();
4850
}
4951

52+
async badge() {
53+
const badgeElement = await this.elementHandle.$(this.selector.badgeClass);
54+
if (!badgeElement) {
55+
throw new Error(`Cannot read description from ${this.selector.badgeClass} of ${this.elementHandle}`);
56+
}
57+
return badgeElement.textContent();
58+
}
59+
5060
async isSelected() {
5161
const id = await this.elementHandle.getAttribute('data-id');
5262
const parent = await this.parentElementHandle();

0 commit comments

Comments
 (0)