fix: update plugin server adjustment to use new style
MODIFY
lib/express/server.js
lib/express/server.js
@@ -185,7 +185,7 @@ function configureHttp ({httpServer, reject, keepAliveTimeout}) {
async function configureServerPlugins ({plugins, app, httpServer}) {
// allow plugins to update the app and http server objects
- for (const plugin of plugins.filter((p) => p.updatesServer)) {
+ for (const plugin of plugins.filter((p) => _.isFunction(p.updateServer))) {
log.info(`Allowing plugin ${plugin.name} to modify the Appium server`);
try {
// wrap this in error handling in case the plugin forgot to mark the function async or

MODIFY
test/express/server-e2e-specs.js
test/express/server-e2e-specs.js
@@ -112,29 +112,13 @@ describe('server plugins', function () {
};
}
- // TODO: Fix plugins configuration for the tests
- it.skip('should not allow a plugin to update server if it has updatesServer set to false', async function () {
- hwServer = await server({
- routeConfiguringFunction: _.noop,
- port: 8181,
- plugins: [
- {
- updatesServer: false,
- updateServer: updaterWithGetRoute('no', 'Should never see this'),
- }
- ]
- });
- await axios.get('http://localhost:8181/no').should.eventually.be.rejectedWith(/404/);
- });
- it.skip('should allow one or more plugins to update the server', async function () {
+ it('should allow one or more plugins to update the server', async function () {
hwServer = await server({
routeConfiguringFunction: _.noop,
port: 8181,
plugins: [{
- updatesServer: true,
updateServer: updaterWithGetRoute('plugin1', 'res from plugin1 route'),
}, {
- updatesServer: true,
updateServer: updaterWithGetRoute('plugin2', 'res from plugin2 route'),
}]
});
@@ -145,14 +129,13 @@ describe('server plugins', function () {
hwServer._updated_plugin1.should.be.true;
hwServer._updated_plugin2.should.be.true;
});
- it('should not allow a plugin to update server if it has incorrect updateServer method', async function () {
+ it('should pass on errors from the plugin updateServer method', async function () {
await server({
routeConfiguringFunction: _.noop,
port: 8181,
plugins: [{
- updatesServer: true,
- updateServer: false
+ updateServer: () => { throw new Error('ugh'); }
}]
- }).should.eventually.be.rejectedWith(/is not a function/);
+ }).should.eventually.be.rejectedWith(/ugh/);
});
});

MODIFY
test/express/server-specs.js
test/express/server-specs.js
@@ -34,7 +34,6 @@ function fakePlugin () {
POST: {command: 'fakePost', payloadParams: {required: ['fakeParam']}}
},
},
- updatesServer: true,
updateServer: (app, httpServer) => {
app.updated = true;
httpServer.updated = true;

fix: update plugin server adjustment to use new style