Skip to content

Commit 73bbf87

Browse files
authored
bump(platform): bump electron & android to latest release (#889)
* bump(platform): bump electron & android to latest release * test: separate project per test
1 parent 41ed972 commit 73bbf87

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

integration-tests/plugin.spec.js

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const util = require('../src/cordova/util');
3232

3333
const tmpDir = helpers.tmpDir('plugin_test');
3434
const preparedProject = path.join(tmpDir, 'prepared-project');
35-
const project = path.join(tmpDir, 'project');
3635
const fixturesDir = path.join(__dirname, '..', 'spec', 'cordova', 'fixtures');
3736
const pluginsDir = path.join(fixturesDir, 'plugins');
3837

@@ -55,7 +54,7 @@ const testGitPluginId = 'cordova-plugin-device';
5554
let results;
5655

5756
// Runs: list, add, list
58-
function addPlugin (target, id, options) {
57+
function addPlugin (project, target, id, options) {
5958
// Check there are no plugins yet.
6059
return cordova.plugin('list').then(function () {
6160
expect(results).toMatch(/No plugins added/gi);
@@ -72,7 +71,7 @@ function addPlugin (target, id, options) {
7271
}
7372

7473
// Runs: remove, list
75-
function removePlugin (id) {
74+
function removePlugin (project, id) {
7675
return cordova.plugin('rm', id)
7776
.then(function () {
7877
// The whole dir should be gone.
@@ -87,7 +86,7 @@ function removePlugin (id) {
8786
// We can't call add with a searchpath or else we will conflict with other tests
8887
// that use a searchpath. See loadLocalPlugins() in plugman/fetch.js for details.
8988
// The searchpath behavior gets tested in the plugman spec
90-
function mockPluginFetch (id, dir) {
89+
function mockPluginFetch (project, id, dir) {
9190
spyOn(plugman, 'fetch').and.callFake(function (target, pluginPath, fetchOptions) {
9291
const dest = path.join(project, 'plugins', id);
9392

@@ -97,13 +96,16 @@ function mockPluginFetch (id, dir) {
9796
}
9897

9998
describe('plugin end-to-end', function () {
99+
let project;
100+
100101
events.on('results', function (res) { results = res; });
101102

102103
beforeAll(() => {
103104
return helpers.getFixture('projectWithPlatform').copyTo(preparedProject);
104105
}, 20000);
105106

106107
beforeEach(function () {
108+
project = path.join(tmpDir, `project-${Date.now()}`);
107109
// Reset our test project and change into it
108110
fs.copySync(preparedProject, project);
109111
process.chdir(project);
@@ -122,11 +124,11 @@ describe('plugin end-to-end', function () {
122124
});
123125

124126
it('Test 001 : should successfully add and remove a plugin with no options', function () {
125-
return addPlugin(path.join(pluginsDir, 'fake1'), pluginId)
127+
return addPlugin(project, path.join(pluginsDir, 'fake1'), pluginId)
126128
.then(function () {
127129
expect(install.runInstall).toHaveBeenCalled();
128130
expect(platforms.getPlatformApi.calls.count()).toEqual(1);
129-
return removePlugin(pluginId);
131+
return removePlugin(project, pluginId);
130132
}).then(function () {
131133
expect(platforms.getPlatformApi.calls.count()).toEqual(2);
132134
});
@@ -144,16 +146,16 @@ describe('plugin end-to-end', function () {
144146
process.chdir(subdir);
145147

146148
// Add plugin using relative path
147-
return addPlugin(path.relative(subdir, plugindir), pluginId)
149+
return addPlugin(project, path.relative(subdir, plugindir), pluginId)
148150
.then(function () {
149-
return removePlugin(pluginId);
151+
return removePlugin(project, pluginId);
150152
});
151153
}, 30000);
152154

153155
it('Test 005 : should respect preference default values', function () {
154156
const plugin_util = require('../src/cordova/plugin/util');
155157
spyOn(plugin_util, 'mergeVariables').and.returnValue({ REQUIRED: 'NO', REQUIRED_ANDROID: 'NO' });
156-
return addPlugin(path.join(pluginsDir, org_test_defaultvariables), org_test_defaultvariables, { cli_variables: { REQUIRED: 'NO', REQUIRED_ANDROID: 'NO' } })
158+
return addPlugin(project, path.join(pluginsDir, org_test_defaultvariables), org_test_defaultvariables, { cli_variables: { REQUIRED: 'NO', REQUIRED_ANDROID: 'NO' } })
157159
.then(function () {
158160
const platformJsonPath = path.join(project, 'plugins', helpers.testPlatform + '.json');
159161
const installed_plugins = require(platformJsonPath).installed_plugins;
@@ -163,18 +165,18 @@ describe('plugin end-to-end', function () {
163165
expect(defaultPluginPreferences.DEFAULT_ANDROID).toBe('yes');
164166
expect(defaultPluginPreferences.REQUIRED_ANDROID).toBe('NO');
165167
expect(defaultPluginPreferences.REQUIRED).toBe('NO');
166-
return removePlugin(org_test_defaultvariables);
168+
return removePlugin(project, org_test_defaultvariables);
167169
});
168170
}, 30000);
169171

170172
it('Test 006 : should successfully add a plugin when specifying CLI variables', function () {
171-
return addPlugin(path.join(pluginsDir, org_test_defaultvariables), org_test_defaultvariables, { cli_variables: { REQUIRED: 'yes', REQUIRED_ANDROID: 'yes' } });
173+
return addPlugin(project, path.join(pluginsDir, org_test_defaultvariables), org_test_defaultvariables, { cli_variables: { REQUIRED: 'yes', REQUIRED_ANDROID: 'yes' } });
172174
}, 30000);
173175

174176
it('Test 007 : should not check npm info when using the searchpath flag', function () {
175-
mockPluginFetch(npmInfoTestPlugin, path.join(pluginsDir, npmInfoTestPlugin));
177+
mockPluginFetch(project, npmInfoTestPlugin, path.join(pluginsDir, npmInfoTestPlugin));
176178
spyOn(plugin_util, 'info');
177-
return addPlugin(npmInfoTestPlugin, npmInfoTestPlugin, { searchpath: pluginsDir })
179+
return addPlugin(project, npmInfoTestPlugin, npmInfoTestPlugin, { searchpath: pluginsDir })
178180
.then(function () {
179181
expect(plugin_util.info).not.toHaveBeenCalled();
180182
const fetchOptions = plugman.fetch.calls.mostRecent().args[2];
@@ -183,10 +185,10 @@ describe('plugin end-to-end', function () {
183185
}, 30000);
184186

185187
it('Test 008 : should not check npm info when using the noregistry flag', function () {
186-
mockPluginFetch(npmInfoTestPlugin, path.join(pluginsDir, npmInfoTestPlugin));
188+
mockPluginFetch(project, npmInfoTestPlugin, path.join(pluginsDir, npmInfoTestPlugin));
187189

188190
spyOn(plugin_util, 'info');
189-
return addPlugin(npmInfoTestPlugin, npmInfoTestPlugin, { noregistry: true })
191+
return addPlugin(project, npmInfoTestPlugin, npmInfoTestPlugin, { noregistry: true })
190192
.then(function () {
191193
expect(plugin_util.info).not.toHaveBeenCalled();
192194

@@ -197,26 +199,26 @@ describe('plugin end-to-end', function () {
197199

198200
it('Test 009 : should not check npm info when fetching from a Git repository', function () {
199201
spyOn(plugin_util, 'info');
200-
return addPlugin(testGitPluginRepository, testGitPluginId)
202+
return addPlugin(project, testGitPluginRepository, testGitPluginId)
201203
.then(function () {
202204
expect(plugin_util.info).not.toHaveBeenCalled();
203205
});
204206
}, 30000);
205207

206208
it('Test 010 : should select the plugin version based on npm info when fetching from npm', function () {
207-
mockPluginFetch(npmInfoTestPlugin, path.join(pluginsDir, npmInfoTestPlugin));
209+
mockPluginFetch(project, npmInfoTestPlugin, path.join(pluginsDir, npmInfoTestPlugin));
208210

209211
spyOn(plugin_util, 'info').and.callThrough();
210212

211213
// Pretend to have cordova-android 5.2.2 installed to force the
212214
// expected version outcome for the plugin below
213215
const targetVersion = '5.2.2';
214-
const apiFile = path.join(project, 'platforms/android/cordova/Api.js');
216+
const apiFile = path.join(project, 'node_modules/cordova-android/lib/Api.js');
215217
const apiString = fs.readFileSync(apiFile, 'utf8')
216-
.replace(/const VERSION = '[^']+';/, `const VERSION = '${targetVersion}';`);
218+
.replace('const VERSION = require(\'../package\').version;', `const VERSION = '${targetVersion}';`);
217219
fs.writeFileSync(apiFile, apiString, 'utf8');
218220

219-
return addPlugin(npmInfoTestPlugin, npmInfoTestPlugin)
221+
return addPlugin(project, npmInfoTestPlugin, npmInfoTestPlugin)
220222
.then(function () {
221223
expect(plugin_util.info).toHaveBeenCalled();
222224

@@ -226,10 +228,10 @@ describe('plugin end-to-end', function () {
226228
}, 30000);
227229

228230
it('Test 011 : should handle scoped npm packages', function () {
229-
mockPluginFetch(scopedTestPlugin, path.join(pluginsDir, scopedTestPlugin));
231+
mockPluginFetch(project, scopedTestPlugin, path.join(pluginsDir, scopedTestPlugin));
230232

231233
spyOn(plugin_util, 'info').and.returnValue(Promise.resolve({}));
232-
return addPlugin(scopedTestPlugin, scopedTestPlugin, {})
234+
return addPlugin(project, scopedTestPlugin, scopedTestPlugin, {})
233235
.then(function () {
234236
// Check to make sure that we are at least trying to get the correct package.
235237
// This package is not published to npm, so we can't truly do end-to-end tests
@@ -243,10 +245,10 @@ describe('plugin end-to-end', function () {
243245

244246
it('Test 012 : should handle scoped npm packages with given version tags', function () {
245247
const scopedPackage = scopedTestPlugin + '@latest';
246-
mockPluginFetch(scopedTestPlugin, path.join(pluginsDir, scopedTestPlugin));
248+
mockPluginFetch(project, scopedTestPlugin, path.join(pluginsDir, scopedTestPlugin));
247249

248250
spyOn(plugin_util, 'info');
249-
return addPlugin(scopedPackage, scopedTestPlugin, {})
251+
return addPlugin(project, scopedPackage, scopedTestPlugin, {})
250252
.then(function () {
251253
expect(plugin_util.info).not.toHaveBeenCalled();
252254

@@ -256,17 +258,17 @@ describe('plugin end-to-end', function () {
256258
}, 30000);
257259

258260
it('Test 013 : should be able to add and remove scoped npm packages without screwing up everything', () => {
259-
mockPluginFetch(scopedTestPlugin, path.join(pluginsDir, scopedTestPlugin));
261+
mockPluginFetch(project, scopedTestPlugin, path.join(pluginsDir, scopedTestPlugin));
260262
spyOn(plugin_util, 'info').and.returnValue(Promise.resolve({}));
261263

262-
return addPlugin(scopedTestPlugin, scopedTestPlugin, {})
264+
return addPlugin(project, scopedTestPlugin, scopedTestPlugin, {})
263265
.then(() => {
264266
expect(plugin_util.info).toHaveBeenCalledWith([scopedTestPlugin]);
265267

266268
const fetchTarget = plugman.fetch.calls.mostRecent().args[0];
267269
expect(fetchTarget).toEqual(scopedTestPlugin);
268270

269-
return removePlugin(scopedTestPlugin);
271+
return removePlugin(project, scopedTestPlugin);
270272
});
271273
}, 30000);
272274

@@ -290,7 +292,7 @@ describe('plugin end-to-end', function () {
290292
projectRoot: project
291293
});
292294

293-
mockPluginFetch(npmInfoTestPlugin, path.join(pluginsDir, npmInfoTestPlugin));
295+
mockPluginFetch(project, npmInfoTestPlugin, path.join(pluginsDir, npmInfoTestPlugin));
294296
spyOn(HooksRunner.prototype, 'fire').and.callThrough();
295297

296298
await cordova.plugin('add', npmInfoTestPlugin);

src/platforms/platformsConfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"android": {
1515
"url": "https://github.com/apache/cordova-android.git",
16-
"version": "^9.1.0",
16+
"version": "^10.1.1",
1717
"deprecated": false
1818
},
1919
"windows": {
@@ -31,7 +31,7 @@
3131
},
3232
"electron": {
3333
"url": "https://github.com/apache/cordova-electron.git",
34-
"version": "^1.1.1",
34+
"version": "^3.0.0",
3535
"deprecated": false
3636
}
3737
}

0 commit comments

Comments
 (0)