This commit is contained in:
Elio Struyf
2024-02-03 13:08:15 +02:00
parent 4a4db839ab
commit 7b689326e3
13 changed files with 6 additions and 150 deletions

View File

@@ -1,78 +0,0 @@
import { By, VSBrowser, EditorView, WebView, Workbench, Notification, StatusBar, NotificationType } from "vscode-extension-tester";
import { expect } from "chai";
import { sleep } from "./utils";
import { join } from "path";
// https://github.com/microsoft/vscode-java-dependency/blob/4256fa6adcaff5ec24dbdbb8d9a516fad21431c5/test/ui/index.ts
// https://github.com/microsoft/vscode-java-dependency/blob/4256fa6adcaff5ec24dbdbb8d9a516fad21431c5/test/ui/command.test.ts
describe("Initialization testing", function() {
this.timeout(2 * 60 * 1000 /*ms*/);
let workbench: Workbench;
let view: WebView;
before(async function() {
await VSBrowser.instance.openResources(join(__dirname, '../sample'));
await sleep(3000);
workbench = new Workbench();
await workbench.executeCommand("frontMatter.dashboard");
await sleep(3000);
await new EditorView().openEditor(`FrontMatter Dashboard`);
view = new WebView();
await view.switchToFrame();
});
it("1. Open welcome dashboard", async function() {
const element = await view.findWebElement(By.css('h1'));
const title = await element.getText();
expect(title).has.string(`Front Matter`);
});
it("2. Initialize project", async function() {
const btn = await view.findWebElement(By.css('[data-test="welcome-init"] button'));
expect(btn).to.exist;
await btn.click();
await sleep(1000);
await VSBrowser.instance.driver.wait(() => {
return notificationExists(workbench, 'Front Matter:');
}, 2000) as Notification;
const notifications = await workbench.getNotifications();
let notification!: Notification;
for (const not of notifications) {
console.log(not);
// const message = await not.get;
// console.log(message);
// if (message.includes('Front Matter:')) {
// notification = not;
// }
}
expect(await notification.getMessage()).has.string(`Project initialized successfully.`);
});
it("3. Check if project file is created", async function() {});
});
async function notificationExists(workbench: Workbench, text: string): Promise<Notification | undefined> {
const notifications = await (await (new StatusBar()).openNotificationsCenter()).getNotifications(NotificationType.Info);
for (const notification of notifications) {
const message = await notification.getMessage();
if (message.indexOf(text) >= 0) {
return notification;
}
}
}

View File

@@ -1,33 +0,0 @@
import * as path from 'path'
import * as semver from 'semver'
import { ExTester, ReleaseQuality } from 'vscode-extension-tester'
async function main(): Promise<void> {
const vsCodeVersion: semver.SemVer = new semver.SemVer(`1.66.0`)
const version = vsCodeVersion.version
const storageFolder = path.join(__dirname, '..', 'storage')
const extFolder = path.join(__dirname, '..', 'extensions')
try {
const testPath = path.join(__dirname, 'command.test.js')
const exTester = new ExTester(storageFolder, ReleaseQuality.Stable, extFolder)
await exTester.downloadCode(version)
await exTester.installVsix({ useYarn: false })
// await exTester.installFromMarketplace("eliostruyf.vscode-front-matter");
await exTester.downloadChromeDriver(version)
// await exTester.setupRequirements({vscodeVersion: version});
const result = await exTester.runTests(testPath, {
vscodeVersion: version,
resources: [storageFolder],
})
process.exit(result)
} catch (err) {
console.log(err)
process.exit(1)
}
}
main()

View File

@@ -1 +0,0 @@
export * from './sleep';

View File

@@ -1,3 +0,0 @@
export async function sleep(time: number) {
await new Promise((resolve) => setTimeout(resolve, time));
}

View File

@@ -2564,9 +2564,6 @@
"prod:panel": "webpack --mode production --config ./webpack/panel.config.js",
"test-compile": "tsc -p ./",
"clean": "rimraf dist",
"start:site": "cd ./docs && npm run dev",
"clean:test": "rm ./e2e/sample/frontmatter.json || exit 0 && rm -rf ./e2e/sample/.frontmatter || exit 0",
"test": "npm run lint; tsc -p tsconfig.e2e.json && npm run clean:test && npm run i -g @vscode/vsce && node ./e2e/out/runTests.js",
"lint": "eslint --max-warnings=0 ./src/{commands,components}",
"prettier": "prettier --write ./src",
"localization:watch": "node ./scripts/watch-localization.js",

View File

@@ -363,7 +363,7 @@ export class Article {
return;
}
let position = editor.selection.active;
const position = editor.selection.active;
const selectionText = editor.document.getText(editor.selection);
// Check for snippet wrapper

View File

@@ -22,7 +22,7 @@ export class Cache {
await Extension.getInstance().setState(key, data, type);
}
public static async clear(showNotification: boolean = true) {
public static async clear(showNotification = true) {
const ext = Extension.getInstance();
await ext.setState(ExtensionState.Dashboard.Pages.Cache, undefined, 'workspace', true);

View File

@@ -283,7 +283,6 @@ export class Folders {
public static async getInfo(limit?: number): Promise<FolderInfo[] | null> {
const supportedFiles = Settings.get<string[]>(SETTING_CONTENT_SUPPORTED_FILETYPES);
const folders = Folders.get();
const wsFolder = parseWinPath(Folders.getWorkspaceFolder()?.fsPath || '');
if (folders && folders.length > 0) {
const folderInfo: FolderInfo[] = [];

View File

@@ -199,7 +199,7 @@ export class Preview {
* @param filePath
* @param slug
*/
public static async updatePageUrl(filePath: string, slug?: string) {
public static async updatePageUrl(filePath: string, _: string) {
const webView = this.webviews[filePath];
if (webView) {
const localhost = await this.getLocalServerUrl();

View File

@@ -24,7 +24,7 @@ export class Settings {
});
if (newOption) {
let options = (await TaxonomyHelper.get(type)) || [];
const options = (await TaxonomyHelper.get(type)) || [];
if (options.find((o) => o === newOption)) {
Notifications.warning(l10n.t(LocalizationKey.commandsSettingsCreateWarning, taxonomy));

View File

@@ -163,7 +163,7 @@ export class Template {
await copyFileAsync(template.fsPath, newFilePath);
// Update the properties inside the template
let frontMatter = await ArticleHelper.getFrontMatterByPath(newFilePath);
const frontMatter = await ArticleHelper.getFrontMatterByPath(newFilePath);
if (!frontMatter) {
Notifications.warning(l10n.t(LocalizationKey.commonError));
return;

View File

@@ -1,24 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "e2e/out",
"lib": [
"es6",
"dom"
],
"sourceMap": true,
"strict": false,
"noUnusedLocals": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"skipLibCheck": true
},
"include": [
"e2e/src/**/*"
],
"exclude": [
"node_modules",
"src"
]
}

View File

@@ -19,7 +19,6 @@
"exclude": [
"node_modules",
".vscode-test",
"docs",
"e2e"
"docs"
]
}