Skip to content

Commit fd1b1d0

Browse files
authored
fixing the failing mrt e2e tests (#327)
1 parent 4d068b6 commit fd1b1d0

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

packages/b2c-cli/test/functional/e2e/mrt-lifecycle.test.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
import {expect} from 'chai';
88
import {parseJSONOutput, runCLI, runCLIWithRetry, TIMEOUTS} from './test-utils.js';
99

10+
/**
11+
* MRT member list/get JSON uses `user` for the member's email per APIProjectMember;
12+
*/
13+
function mrtMemberEmail(member: {user?: string; email?: string}): string | undefined {
14+
return member.user ?? member.email;
15+
}
16+
1017
/**
1118
* E2E Tests for MRT (Managed Runtime) Lifecycle
1219
*
@@ -200,8 +207,9 @@ describe('MRT Lifecycle E2E Tests', function () {
200207
expect(response.members).to.be.an('array');
201208

202209
if (response.members.length > 0) {
203-
expect(response.members[0]).to.have.property('email');
204-
expect(response.members[0]).to.have.property('role');
210+
const first = response.members[0];
211+
expect(mrtMemberEmail(first), 'member should include user (email)').to.be.a('string').and.not.empty;
212+
expect(first).to.have.property('role');
205213
}
206214
});
207215

@@ -224,7 +232,11 @@ describe('MRT Lifecycle E2E Tests', function () {
224232
this.skip();
225233
}
226234

227-
const memberEmail = listResponse.members[0].email;
235+
const memberEmail = mrtMemberEmail(listResponse.members[0]);
236+
if (!memberEmail) {
237+
console.log(' ⚠ Member has no user/email field, skipping test');
238+
this.skip();
239+
}
228240

229241
const result = await runCLIWithRetry(
230242
['mrt', 'project', 'member', 'get', memberEmail, '--project', projectSlug, '--json'],
@@ -234,8 +246,8 @@ describe('MRT Lifecycle E2E Tests', function () {
234246
expect(result.exitCode, `Member get command failed: ${result.stderr}`).to.equal(0);
235247

236248
const response = parseJSONOutput(result);
237-
// Response is a flat object, not nested under "member"
238-
expect(response).to.have.property('email').that.equals(memberEmail);
249+
// API returns `user` (email), not top-level `email`
250+
expect(mrtMemberEmail(response)).to.equal(memberEmail);
239251
expect(response).to.have.property('role');
240252
});
241253
});

0 commit comments

Comments
 (0)