-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
4,275 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: E2E | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'pnpm' | ||
|
||
- name: install | ||
run: pnpm i | ||
|
||
- name: build | ||
run: pnpm build | ||
|
||
- name: restore vscode | ||
id: cache-vscode-restore | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
./e2e/.wdio-vscode-service | ||
key: ${{ runner.os }}-vscode-1.80.0 | ||
|
||
- name: e2e | ||
uses: coactions/setup-xvfb@v1 | ||
with: | ||
run: pnpm e2e | ||
|
||
- name: cache vscode | ||
id: cache-vscode | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: | | ||
./e2e/.wdio-vscode-service | ||
key: ${{ steps.cache-vscode-restore.outputs.cache-primary-key }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,11 @@ pnpm test | |
pnpm validate | ||
``` | ||
|
||
```sh | ||
# e2e | ||
pnpm e2e | ||
``` | ||
|
||
## PR | ||
|
||
Use `czg` or make sure to prefix type. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.wdio-vscode-service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Empty file.
12 changes: 12 additions & 0 deletions
12
e2e/fixtures/workspaces/multiroot-configured.code-workspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "../folders/a" | ||
} | ||
], | ||
"settings": { | ||
"workbench.colorCustomizations": { | ||
"titleBar.activeBackground": "#000000" | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
e2e/fixtures/workspaces/multiroot-not-configured.code-workspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "../folders/a" | ||
} | ||
], | ||
"settings": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "e2e", | ||
"scripts": { | ||
"wdio": "wdio run ./wdio.conf.ts" | ||
}, | ||
"devDependencies": { | ||
"@wdio/cli": "^8.12.2", | ||
"@wdio/globals": "^8.12.1", | ||
"@wdio/local-runner": "^8.12.1", | ||
"@wdio/mocha-framework": "^8.12.1", | ||
"@wdio/spec-reporter": "^8.12.2", | ||
"@wdio/types": "^8.10.4", | ||
"chromedriver": "^114.0.2", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.1.6", | ||
"wdio-vscode-service": "^5.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { browser } from '@wdio/globals'; | ||
import { TextEditor } from 'wdio-vscode-service'; | ||
|
||
import { | ||
getBasenameFromPath, | ||
openWorkspace, | ||
resolveFixture, | ||
snapshotFile, | ||
} from './utils'; | ||
|
||
describe('multiroot', () => { | ||
describe('configured', () => { | ||
const workspaceFile = resolveFixture( | ||
'workspaces/multiroot-configured.code-workspace', | ||
); | ||
|
||
snapshotFile(workspaceFile); | ||
|
||
it('should not be colorized', async () => { | ||
await openWorkspace(workspaceFile); | ||
|
||
const workbench = await browser.getWorkbench(); | ||
|
||
await workbench.executeCommand('Open Workspace Configuration File'); | ||
const textEditor = (await workbench | ||
.getEditorView() | ||
.openEditor(getBasenameFromPath(workspaceFile))) as TextEditor; | ||
const text = await textEditor.getText(); | ||
|
||
expect(text.includes('"titleBar.activeBackground": "#000000"')).toBe( | ||
true, | ||
); | ||
expect(text.includes('"titleBar.activeForeground"')).toBe(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { browser } from '@wdio/globals'; | ||
import { TextEditor } from 'wdio-vscode-service'; | ||
|
||
import { | ||
getBasenameFromPath, | ||
openWorkspace, | ||
resolveFixture, | ||
snapshotFile, | ||
} from './utils'; | ||
|
||
describe('multi-root', () => { | ||
describe('not configured', () => { | ||
const workspaceFile = resolveFixture( | ||
'workspaces/multiroot-not-configured.code-workspace', | ||
); | ||
|
||
snapshotFile(workspaceFile); | ||
|
||
it('should be colorized', async () => { | ||
await openWorkspace(workspaceFile); | ||
|
||
const workbench = await browser.getWorkbench(); | ||
|
||
await workbench.executeCommand('Open Workspace Configuration File'); | ||
const textEditor = (await workbench | ||
.getEditorView() | ||
.openEditor(getBasenameFromPath(workspaceFile))) as TextEditor; | ||
const text = await textEditor.getText(); | ||
|
||
expect(text.includes('"titleBar.activeBackground"')).toBe(true); | ||
expect(text.includes('"titleBar.activeForeground"')).toBe(true); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { browser } from '@wdio/globals'; | ||
import { TextEditor } from 'wdio-vscode-service'; | ||
|
||
import { openFolder, resolveFixture, snapshotFile } from './utils'; | ||
|
||
describe('singlefolder', () => { | ||
const folder = resolveFixture('folders/a'); | ||
|
||
snapshotFile(resolveFixture('folders/a/.vscode/settings.json')); | ||
|
||
it('should not be colorized', async () => { | ||
await openFolder(folder); | ||
|
||
const workbench = await browser.getWorkbench(); | ||
|
||
const inputBox = await workbench.executeCommand('Go to File'); | ||
await inputBox.setText('settings.json'); | ||
await inputBox.confirm(); | ||
|
||
const textEditor = (await workbench | ||
.getEditorView() | ||
.openEditor('settings.json')) as TextEditor; | ||
const text = await textEditor.getText(); | ||
|
||
expect(text.includes('{}')).toBe(true); | ||
expect(text.includes('"titleBar.activeBackground"')).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { readFile, writeFile } from 'node:fs/promises'; | ||
import { basename, resolve } from 'node:path'; | ||
|
||
export function resolveFixture(pathFromFixture: string) { | ||
return resolve(__dirname, '../fixtures', pathFromFixture); | ||
} | ||
|
||
export function getBasenameFromPath(path: string) { | ||
return basename(path); | ||
} | ||
|
||
export function getWorkspaceNameFromPath(path: string) { | ||
return basename(path, '.code-workspace'); | ||
} | ||
|
||
export function snapshotFile(filePath: string) { | ||
let originalContent: string; | ||
|
||
before(async () => { | ||
// store original content | ||
const content = await readFile(filePath, { | ||
encoding: 'utf-8', | ||
}); | ||
originalContent = content; | ||
}); | ||
|
||
after(async () => { | ||
// reset content | ||
if (originalContent) { | ||
await writeFile(filePath, originalContent); | ||
} | ||
}); | ||
} | ||
|
||
export async function openWorkspace(workspaceFile: string) { | ||
await browser.executeWorkbench((vscode, workspaceFile) => { | ||
vscode.commands.executeCommand( | ||
'vscode.openFolder', | ||
vscode.Uri.parse(workspaceFile), | ||
); | ||
}, workspaceFile); | ||
|
||
const workspaceName = getWorkspaceNameFromPath(workspaceFile); | ||
await browser.waitUntil(async () => { | ||
const title = await (await browser.getWorkbench()).getTitleBar().getTitle(); | ||
return title.includes(workspaceName); | ||
}); | ||
} | ||
|
||
export async function openFolder(folder: string) { | ||
await browser.executeWorkbench((vscode, folder) => { | ||
vscode.commands.executeCommand( | ||
'vscode.openFolder', | ||
vscode.Uri.parse(folder), | ||
); | ||
}, folder); | ||
|
||
const folderName = getBasenameFromPath(folder); | ||
await browser.waitUntil(async () => { | ||
const title = await (await browser.getWorkbench()).getTitleBar().getTitle(); | ||
return title.includes(folderName); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "node", | ||
"module": "commonjs", | ||
"types": [ | ||
"@wdio/globals/types", | ||
"@wdio/mocha-framework", | ||
"expect-webdriverio", | ||
"node", | ||
"wdio-vscode-service" | ||
], | ||
"target": "es2022" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type { Options } from '@wdio/types'; | ||
|
||
import { resolve } from 'node:path'; | ||
|
||
// https://webdriver.io/docs/configurationfile/ | ||
export const config: Options.Testrunner = { | ||
autoCompileOpts: { | ||
autoCompile: true, | ||
tsNodeOpts: { | ||
project: './tsconfig.json', | ||
transpileOnly: true, | ||
}, | ||
}, | ||
bail: 0, | ||
baseUrl: '', | ||
capabilities: [ | ||
{ | ||
browserName: 'vscode', | ||
browserVersion: '1.80.0', | ||
'wdio:vscodeOptions': { | ||
// specify extension path that includes `package.json` | ||
extensionPath: resolve(__dirname, '..'), | ||
}, | ||
}, | ||
], | ||
connectionRetryCount: 3, | ||
connectionRetryTimeout: 120000, | ||
exclude: [], | ||
framework: 'mocha', | ||
// less info to more easily see spec result | ||
logLevel: 'warn', | ||
// avoid manipulation conflict | ||
maxInstancesPerCapability: 1, | ||
mochaOpts: { | ||
timeout: 60000, | ||
ui: 'bdd', | ||
}, | ||
reporters: ['spec'], | ||
runner: 'local', | ||
services: ['vscode'], | ||
// specify spec path | ||
specs: ['./specs/**/*.e2e.ts'], | ||
waitforTimeout: 10000, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.