Skip to content

Commit

Permalink
Add username uniqueness for test Matrix usernames
Browse files Browse the repository at this point in the history
  • Loading branch information
backspace committed Feb 10, 2025
1 parent c04b76a commit 367df2c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/host/app/services/realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,6 @@ export default class RealmService extends Service {
}

realmOfMatrixUsername(username: string) {
// FIXME username is not fully-qualified (@experiments_realm:localhost vs experiments_realm)
username = `@${username}:localhost`;
console.log(
'all realm usernames ',
Array.from(this.realms.values()).map((r) => r.info?.realmUserId),
Expand All @@ -515,6 +513,7 @@ export default class RealmService extends Service {
(r) => r.info?.realmUserId === username,
);
console.log('realm', realm);
console.log('username looked for: ', username);
return realm;
}

Expand Down
1 change: 0 additions & 1 deletion packages/host/tests/acceptance/interact-submode-test.gts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ module('Acceptance | interact submode tests', function (hooks) {
backgroundURL:
'https://i.postimg.cc/VNvHH93M/pawel-czerwinski-Ly-ZLa-A5jti-Y-unsplash.jpg',
iconURL: 'https://i.postimg.cc/L8yXRvws/icon.png',
realmUserId: '@test_realm:localhost',
},
},
}));
Expand Down
16 changes: 13 additions & 3 deletions packages/host/tests/helpers/index.gts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export * from '@cardstack/runtime-common/helpers/indexer';
const { sqlSchema } = ENV;

type CardAPI = typeof import('https://cardstack.com/base/card-api');
const testMatrix = {

let testMatrixCount = 0;

const baseTestMatrix = {
url: new URL(`http://localhost:8008`),
username: 'test_realm',
password: 'password',
Expand Down Expand Up @@ -652,13 +655,20 @@ async function setupTestRealm({
runnerOptsManager: runnerOptsMgr,
indexRunner,
virtualNetwork,
matrixURL: testMatrix.url,
matrixURL: baseTestMatrix.url,
secretSeed: testRealmSecretSeed,
});

let iteratedTestMatrix = {
...baseTestMatrix,
username: `@${baseTestMatrix.username}-${testMatrixCount}:localhost`,
};
testMatrixCount++;

realm = new Realm({
url: realmURL,
adapter,
matrix: testMatrix,
matrix: iteratedTestMatrix,
secretSeed: testRealmSecretSeed,
virtualNetwork,
dbAdapter,
Expand Down

0 comments on commit 367df2c

Please sign in to comment.