From 50013279f438490d6a7ba7babe1e49fa1e94fd65 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Fri, 18 Aug 2023 15:09:47 +0200 Subject: [PATCH] test: verify empty + broken diagram opening --- src/test/fixtures/broken.bpmn | 2 + src/test/fixtures/collapsedSubprocess.bpmn | 29 ------------- src/test/fixtures/specialChars.bpmn | 25 ----------- src/test/suite/extension.test.ts | 50 ++++++++++++++++++---- 4 files changed, 43 insertions(+), 63 deletions(-) create mode 100644 src/test/fixtures/broken.bpmn delete mode 100644 src/test/fixtures/collapsedSubprocess.bpmn delete mode 100644 src/test/fixtures/specialChars.bpmn diff --git a/src/test/fixtures/broken.bpmn b/src/test/fixtures/broken.bpmn new file mode 100644 index 0000000..33aa2ba --- /dev/null +++ b/src/test/fixtures/broken.bpmn @@ -0,0 +1,2 @@ + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/test/fixtures/specialChars.bpmn b/src/test/fixtures/specialChars.bpmn deleted file mode 100644 index bad9995..0000000 --- a/src/test/fixtures/specialChars.bpmn +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - foo""'bar>< - - - - - - - - - - - - - - - - - - - diff --git a/src/test/suite/extension.test.ts b/src/test/suite/extension.test.ts index 57b3035..1c8511f 100644 --- a/src/test/suite/extension.test.ts +++ b/src/test/suite/extension.test.ts @@ -12,10 +12,18 @@ import * as vscode from 'vscode'; chai.use(sinonChai); -const TEST_FILE = vscode.Uri.file( +const SIMPLE_TEST_FILE = vscode.Uri.file( path.join(__dirname, '..', 'fixtures', 'simple.bpmn') ); +const EMPTY_TEST_FILE = vscode.Uri.file( + path.join(__dirname, '..', 'fixtures', 'empty.bpmn') +); + +const BROKEN_TEST_FILE = vscode.Uri.file( + path.join(__dirname, '..', 'fixtures', 'broken.bpmn') +); + describe('extension', function() { this.timeout(5000); @@ -30,10 +38,10 @@ describe('extension', function() { it('should open file', async () => { // when - await vscode.commands.executeCommand('vscode.open', TEST_FILE); + await vscode.commands.executeCommand('vscode.open', SIMPLE_TEST_FILE); // then - const extension = await getExtension(TEST_FILE); + const extension = await getExtension(SIMPLE_TEST_FILE); expect(extension, 'editor open').to.exist; }); @@ -42,10 +50,10 @@ describe('extension', function() { it('should open as BPMN', async () => { // when - await vscode.commands.executeCommand('vscode.open', TEST_FILE); + await vscode.commands.executeCommand('vscode.open', SIMPLE_TEST_FILE); // then - const extension = await getExtension(TEST_FILE); + const extension = await getExtension(SIMPLE_TEST_FILE); expect(extension, 'editor open').to.exist; }); @@ -54,12 +62,36 @@ describe('extension', function() { it('should create new BPMN file', async () => { // when - const uri = await vscode.commands.executeCommand('bpmn-io.bpmnEditor.new'); + const uri = await vscode.commands.executeCommand('bpmn-io.bpmnEditor.new') as vscode.Uri; // then expect(uri, 'uri exists').to.exist; - const extension = await getExtension(TEST_FILE); + const extension = await getExtension(uri); + + expect(extension, 'editor open').to.exist; + }); + + + it('should open empty BPMN file', async () => { + + // when + await vscode.commands.executeCommand('vscode.open', EMPTY_TEST_FILE); + + // then + const extension = await getExtension(EMPTY_TEST_FILE); + + expect(extension, 'editor open').to.exist; + }); + + + it('should open broken BPMN file', async () => { + + // when + await vscode.commands.executeCommand('vscode.open', BROKEN_TEST_FILE); + + // then + const extension = await getExtension(BROKEN_TEST_FILE); expect(extension, 'editor open').to.exist; }); @@ -68,13 +100,13 @@ describe('extension', function() { it('should close opened editor', async () => { // given - await vscode.commands.executeCommand('vscode.open', TEST_FILE); + await vscode.commands.executeCommand('vscode.open', SIMPLE_TEST_FILE); // when await vscode.commands.executeCommand('workbench.action.closeActiveEditor'); // then - const extension = await getExtension(TEST_FILE); + const extension = await getExtension(SIMPLE_TEST_FILE); expect(extension, 'editor closed').not.to.exist; });