Skip to content

Commit

Permalink
test: verify empty + broken diagram opening
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Aug 18, 2023
1 parent 1f68696 commit 5001327
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 63 deletions.
2 changes: 2 additions & 0 deletions src/test/fixtures/broken.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
29 changes: 0 additions & 29 deletions src/test/fixtures/collapsedSubprocess.bpmn

This file was deleted.

25 changes: 0 additions & 25 deletions src/test/fixtures/specialChars.bpmn

This file was deleted.

50 changes: 41 additions & 9 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
});
Expand All @@ -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;
});
Expand All @@ -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;
});
Expand All @@ -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;
});
Expand Down

0 comments on commit 5001327

Please sign in to comment.