From 5ec13683ff555bdaf03df7d9fc43b5c80c97e606 Mon Sep 17 00:00:00 2001 From: Sumit Suthar Date: Fri, 20 Sep 2024 16:30:31 +0530 Subject: [PATCH] Revert "test: Updated koa-router to tests to handle bug fixes from 13.0.1 (#2578)" This reverts commit 23e979c36dc95c4d3d74c267a11147400d43f697. --- test/versioned/koa/package.json | 4 ++-- test/versioned/koa/router-common.js | 35 +++++++++++++---------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/test/versioned/koa/package.json b/test/versioned/koa/package.json index 50a1775d0f..bee8c70660 100644 --- a/test/versioned/koa/package.json +++ b/test/versioned/koa/package.json @@ -34,7 +34,7 @@ "samples": 5 }, "koa-router": { - "versions": ">=11.0.2", + "versions": ">=11.0.2 && <13.0.0", "samples": 5 } }, @@ -53,7 +53,7 @@ "samples": 5 }, "@koa/router": { - "versions": ">=11.0.2", + "versions": ">=11.0.2 && <13.0.0", "samples": 5 } }, diff --git a/test/versioned/koa/router-common.js b/test/versioned/koa/router-common.js index 698531aec3..7927391e36 100644 --- a/test/versioned/koa/router-common.js +++ b/test/versioned/koa/router-common.js @@ -45,7 +45,7 @@ module.exports = (pkg) => { } function tearDown(t) { - t.context?.server?.close() + t.context.server.close() helper.unloadAgent(t.context.agent) } @@ -148,22 +148,18 @@ module.exports = (pkg) => { t.test('should name and produce segments for matched wildcard path', (t) => { const { agent, router, app } = t.context - let path = '(.*)' - if (semver.gte(pkgVersion, '13.0.1')) { - path = '{*any}' - } - router.get(`/:first/${path}`, function firstMiddleware(ctx) { + router.get('/:first/(.*)', function firstMiddleware(ctx) { ctx.body = 'first' }) app.use(router.routes()) agent.on('transactionFinished', (tx) => { t.assertSegments(tx.trace.root, [ - `WebTransaction/WebFrameworkUri/Koa/GET//:first/${path}`, - ['Koa/Router: /', [`Nodejs/Middleware/Koa/firstMiddleware//:first/${path}`]] + 'WebTransaction/WebFrameworkUri/Koa/GET//:first/(.*)', + ['Koa/Router: /', ['Nodejs/Middleware/Koa/firstMiddleware//:first/(.*)']] ]) t.equal( tx.name, - `WebTransaction/WebFrameworkUri/Koa/GET//:first/${path}`, + 'WebTransaction/WebFrameworkUri/Koa/GET//:first/(.*)', 'transaction should be named after the matched regex path' ) t.end() @@ -346,21 +342,20 @@ module.exports = (pkg) => { router.get('/:second', function terminalMiddleware(ctx) { ctx.body = ' second' }) - - const segmentTree = semver.gte(pkgVersion, '13.0.1') - ? ['Nodejs/Middleware/Koa/terminalMiddleware//:second'] - : [ - 'Nodejs/Middleware/Koa/secondMiddleware//:first', - [ - 'Nodejs/Middleware/Koa/secondMiddleware//:second', - ['Nodejs/Middleware/Koa/terminalMiddleware//:second'] - ] - ] app.use(router.routes()) agent.on('transactionFinished', (tx) => { t.assertSegments(tx.trace.root, [ 'WebTransaction/WebFrameworkUri/Koa/GET//:second', - ['Koa/Router: /', segmentTree] + [ + 'Koa/Router: /', + [ + 'Nodejs/Middleware/Koa/secondMiddleware//:first', + [ + 'Nodejs/Middleware/Koa/secondMiddleware//:second', + ['Nodejs/Middleware/Koa/terminalMiddleware//:second'] + ] + ] + ] ]) t.equal( tx.name,