Skip to content

Commit

Permalink
Merge pull request #1731 from xodio/feat-1631-update-tutorial-hardwar…
Browse files Browse the repository at this point in the history
…e-patterns-parts

New tutorial patches: hardware and patterns sections
  • Loading branch information
brusherru committed Apr 4, 2019
2 parents 7163536 + 1416cbe commit f320286
Show file tree
Hide file tree
Showing 56 changed files with 2,590 additions and 2,400 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ it('deletes an open patch', async () => {
await patchGroup.clickOnTrigger();
assert.isTrue(await patchGroup.isExpanded(), 'patch group is open');

const patchGroupItem = await patchGroup.findPatchGroupItem('01-hello');
const patchGroupItem = await patchGroup.findPatchGroupItem('100-hardware');
await patchGroupItem.click();
assert.isTrue(await patchGroupItem.isSelected(), 'patch is selected');

Expand All @@ -28,10 +28,13 @@ it('deletes an open patch', async () => {
assert.equal(await popup.getTitle(), 'Delete the patch');
await popup.clickConfirm();

assert.isNull(await EditorTab.findByName(page, '01-hello'), 'tab is closed');
assert.isNull(
await EditorTab.findByName(page, '100-hardware'),
'tab is closed'
);

assert.isNull(
await patchGroup.findPatchGroupItem('01-hello'),
await patchGroup.findPatchGroupItem('100-hardware'),
'patch is not available in project browser'
);
});
71 changes: 41 additions & 30 deletions packages/xod-client-electron/test-func/0-fs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,37 @@ describe('Test FS things', () => {
it('opens welcome-to-xod project on first start', () =>
ide.page.assertProjectIsOpened('welcome-to-xod'));

describe('saving welcome-to-xod project to disk', () => {
describe('opening and saving blink project to disk', () => {
it('opens blink project', () =>
ide.app.electron.ipcRenderer
.emit(TRIGGER_LOAD_PROJECT, bundledWsPath('blink/project.xod'))
.then(() => ide.page.assertProjectIsOpened('blink')));

const compareSavedWithFixture = () =>
dircompare.compareSync(
ide.wsPath('welcome-to-xod'),
path.join(__dirname, '../src/workspace/welcome-to-xod'),
ide.wsPath('blink'),
path.join(__dirname, '../src/workspace/blink'),
{
compareContent: true,
excludeFilter: '.DS_Store,.directory,.Trash-*,Thumbs.db,desktop.ini',
excludeFilter:
'.DS_Store,.directory,.Trash-*,Thumbs.db,desktop.ini,__fixtures__',
}
);

const saveAsXodballAndCheck = () =>
ide.app.electron.ipcRenderer
.emit(TRIGGER_SAVE_AS, ide.wsPath('welcome-to-xod.xodball'))
.emit(TRIGGER_SAVE_AS, ide.wsPath('blink.xodball'))
.then(ide.page.waitUntilProjectSaved)
.then(() => {
const expectedXodball = fse.readFileSync(
path.join(__dirname, './fixtures/welcome-to-xod.xodball'),
path.join(
__dirname,
'../src/workspace/blink/__fixtures__/blink.xodball'
),
'utf8'
);
const actualXodball = fse.readFileSync(
ide.wsPath('welcome-to-xod.xodball'),
ide.wsPath('blink.xodball'),
'utf8'
);
assert.equal(actualXodball, expectedXodball);
Expand All @@ -60,15 +69,15 @@ describe('Test FS things', () => {
// !!! Ideally, we should simulate clicking 'file -> save',
// check that a file dialog appears and enter desired path there.
// But spectron can't handle file dialogs :(
it('saves welcome project to disk as xodball', saveAsXodballAndCheck);
it('saves blink project to disk as xodball', saveAsXodballAndCheck);
it(
'saves welcome project to disk as xodball again and it remains the same',
'saves blink project to disk as xodball again and it remains the same',
saveAsXodballAndCheck
);

it('saves welcome project to disk', () =>
it('saves blink project to disk', () =>
ide.app.electron.ipcRenderer
.emit(TRIGGER_SAVE_AS, ide.wsPath('welcome-to-xod'))
.emit(TRIGGER_SAVE_AS, ide.wsPath('blink'))
.then(ide.page.waitUntilProjectSaved));

it('is exaclty like bundled welcome project', () => {
Expand All @@ -78,7 +87,7 @@ describe('Test FS things', () => {

it('saves a project for a second time without changing anything', () =>
ide.app.electron.ipcRenderer
.emit(TRIGGER_SAVE_AS, ide.wsPath('welcome-to-xod'))
.emit(TRIGGER_SAVE_AS, ide.wsPath('blink'))
.then(ide.page.waitUntilProjectSaved));

it('remains the same after saving for a second time', () => {
Expand Down Expand Up @@ -137,7 +146,7 @@ describe('Test FS things', () => {

before(() => {
userCustomFileInLibPath = ide.libPath('xod/core/add/accounting.txt');
userCustomFileInProject = ide.wsPath('welcome-to-xod/02-deploy/note.txt');
userCustomFileInProject = ide.wsPath('blink/my-patch/note.txt');
});

// Prepare local project changes
Expand All @@ -154,31 +163,33 @@ describe('Test FS things', () => {
.then(() => ide.page.clickAddNodeButton('input-string'))
.then(() => ide.page.expandPatchGroup('xod/patch-nodes')));

it('delete another patch (`01-hello`)', () =>
it('delete another patch (`main`)', () =>
ide.page
.expandPatchGroup('welcome-to-xod')
.then(() => ide.page.deletePatch('01-hello'))
.then(() =>
ide.page.assertNodeUnavailableInProjectBrowser('01-hello')
));
.expandPatchGroup('blink')
.then(() => ide.page.deletePatch('main'))
.then(() => ide.page.assertNodeUnavailableInProjectBrowser('main')));

it('modify another patch (`04-pwm`)', () =>
it('modify newly created patch (`my-patch`)', () =>
ide.page
.expandPatchGroup('welcome-to-xod')
.then(() => ide.page.scrollToPatchInProjectBrowser('04-pwm'))
.then(() => ide.page.openPatchFromProjectBrowser('04-pwm'))
.expandPatchGroup('blink')
.then(() => ide.page.scrollToPatchInProjectBrowser('my-patch'))
.then(() => ide.page.openPatchFromProjectBrowser('my-patch'))
.then(() => ide.page.expandPatchGroup('xod/patch-nodes'))
.then(() => ide.page.scrollToPatchInProjectBrowser('input-string'))
.then(() => ide.page.selectPatchInProjectBrowser('input-string'))
.then(() => ide.page.clickAddNodeButton('input-string'))
.then(() => ide.page.expandPatchGroup('xod/patch-nodes')));

it('put user file to the patch directory of the project', () =>
fse.writeFile(
userCustomFileInProject,
'My awesome note, that should not been deleted on project save!',
'utf8'
));
fse
.ensureFile(userCustomFileInProject)
.then(() =>
fse.writeFile(
userCustomFileInProject,
'My awesome note, that should not been deleted on project save!',
'utf8'
)
));

// Prepare changes for already saved library (by installing lib)
it('open library patch `xod/core/clock`', () =>
Expand Down Expand Up @@ -235,8 +246,8 @@ describe('Test FS things', () => {
it('checks that saved only changes in the local project', () =>
Promise.all([
assert.eventually.isTrue(
fse.pathExists(ide.wsPath('welcome-to-xod/my-patch/patch.xodp')),
'Expected to `my-patch` be saved in the `welcome-to-xod` project, actually did not.'
fse.pathExists(ide.wsPath('blink/my-patch/patch.xodp')),
'Expected to `my-patch` be saved in the `blink` project, actually did not.'
),
assert.eventually.isTrue(
fse.pathExists(userCustomFileInProject),
Expand Down
7 changes: 4 additions & 3 deletions packages/xod-patch-search/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ describe('xod-patch-search/index', () => {
const results = search(indexData, 'therm');
assert.equal(
results[0].item.path,
'xod/common-hardware/thermometer-tmp36' // Cause this node has a `thermometer` in the path and it alphabetically sorted
'xod/common-hardware/thermometer-tmp36'
);
assert.equal(results[1].item.path, '@/109-thermometer');
assert.equal(
results[1].item.path,
'xod/common-hardware/dht11-thermometer' // Cause this node has a `thermometer` in the path and it alphabetically sorted
results[2].item.path,
'xod/common-hardware/dht11-thermometer'
);
});

Expand Down
74 changes: 74 additions & 0 deletions workspace/blink/__fixtures__/blink.xodball
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"name": "blink",
"patches": {
"@/main": {
"links": {
"rJDD4FSZZ": {
"id": "rJDD4FSZZ",
"input": {
"nodeId": "rkwIEFrWb",
"pinKey": "ryTIROHwkW"
},
"output": {
"nodeId": "By6HVYHZb",
"pinKey": "HJU8CE2lW"
}
},
"ry2wNFB-Z": {
"id": "ry2wNFB-Z",
"input": {
"nodeId": "SyeDNFBWZ",
"pinKey": "HJ6HsEngZ"
},
"output": {
"nodeId": "rkwIEFrWb",
"pinKey": "HkyxURuSPyW"
}
}
},
"nodes": {
"By6HVYHZb": {
"boundLiterals": {
"B13SCNhl-": "0.25",
"BJJICN2lW": "Never"
},
"id": "By6HVYHZb",
"position": {
"x": 2,
"y": 0,
"units": "slots"
},
"type": "xod/core/clock"
},
"SyeDNFBWZ": {
"boundLiterals": {
"HJ6HsEngZ": "False",
"rJjXFA9JQ": "D13"
},
"id": "SyeDNFBWZ",
"position": {
"x": 0,
"y": 2,
"units": "slots"
},
"type": "xod/gpio/digital-write"
},
"rkwIEFrWb": {
"boundLiterals": {
"B1RU0OrDkb": "Never",
"Bkh8A_Sv1-": "Never",
"ryTIROHwkW": "Never"
},
"id": "rkwIEFrWb",
"position": {
"x": 1,
"y": 1,
"units": "slots"
},
"type": "xod/core/flip-flop"
}
},
"path": "@/main"
}
}
}
47 changes: 0 additions & 47 deletions workspace/welcome-to-xod/01-hello/patch.xodp

This file was deleted.

33 changes: 0 additions & 33 deletions workspace/welcome-to-xod/02-deploy/patch.xodp

This file was deleted.

33 changes: 0 additions & 33 deletions workspace/welcome-to-xod/03-inspector/patch.xodp

This file was deleted.

Loading

0 comments on commit f320286

Please sign in to comment.