Skip to content

Commit

Permalink
Add hackish workaround to remove unstable property
Browse files Browse the repository at this point in the history
I hate it??? But what is to be done.
  • Loading branch information
backspace committed Feb 10, 2025
1 parent 84f02e3 commit 72b80bd
Showing 1 changed file with 44 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,25 @@ const testModuleRealm = 'http://localhost:4202/test/';

let loader: Loader;

function stripRealmUserId(card: any) {
let strippedCard = { ...card };
delete strippedCard?.data?.meta?.realmInfo?.realmUserId;
delete strippedCard?.meta?.realmInfo?.realmUserId;

if (strippedCard?.included) {
strippedCard.included = strippedCard.included.map((card: any) => {
delete card.meta.realmInfo.realmUserId;
return card;
});
}

return strippedCard;
}

function stripRealmUserIds(cards: any[]) {
return cards.map((card) => stripRealmUserId(card));
}

module(`Integration | realm indexing and querying`, function (hooks) {
setupRenderingTest(hooks);
setupBaseRealm(hooks);
Expand Down Expand Up @@ -91,7 +110,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
});
let queryEngine = realm.realmIndexQueryEngine;
let { data: cards } = await queryEngine.search({});
assert.deepEqual(cards, [
assert.deepEqual(stripRealmUserIds(cards), [
{
id: `${testRealmURL}empty`,
type: 'card',
Expand Down Expand Up @@ -260,7 +279,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
new URL(`${testRealmURL}Pet/mango`),
);
if (mango?.type === 'doc') {
assert.deepEqual(mango.doc.data, {
assert.deepEqual(stripRealmUserId(mango.doc.data), {
id: `${testRealmURL}Pet/mango`,
type: 'card',
links: {
Expand Down Expand Up @@ -348,7 +367,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
// we see the "production" version of this card while it is being indexed
delete entry.doc.data.meta.lastModified;
delete entry.doc.data.meta.resourceCreatedAt;
assert.deepEqual(entry.doc.data, {
assert.deepEqual(stripRealmUserId(entry.doc.data), {
id: `${testRealmURL}Pet/mango`,
type: 'card',
links: {
Expand Down Expand Up @@ -392,7 +411,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
// we see the "production" version of this card while it is being indexed
delete entry.doc.data.meta.lastModified;
delete entry.doc.data.meta.resourceCreatedAt;
assert.deepEqual(entry.doc.data, {
assert.deepEqual(stripRealmUserId(entry.doc.data), {
id: `${testRealmURL}Pet/mango`,
type: 'card',
links: {
Expand Down Expand Up @@ -475,7 +494,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
new URL(`${testRealmURL}Pet/mango`),
);
if (mango?.type === 'doc') {
assert.deepEqual(mango.doc.data, {
assert.deepEqual(stripRealmUserId(mango.doc.data), {
id: `${testRealmURL}Pet/mango`,
type: 'card',
links: {
Expand Down Expand Up @@ -561,7 +580,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
let indexer = realm.realmIndexQueryEngine;
let mango = await indexer.cardDocument(new URL(`${testRealmURL}Pet/mango`));
if (mango?.type === 'doc') {
assert.deepEqual(mango.doc.data, {
assert.deepEqual(stripRealmUserId(mango.doc.data), {
id: `${testRealmURL}Pet/mango`,
type: 'card',
links: {
Expand Down Expand Up @@ -638,7 +657,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
new URL(`${testRealmURL}person-spec`),
);
if (entry?.type === 'doc') {
assert.deepEqual(entry.doc.data, {
assert.deepEqual(stripRealmUserId(entry.doc.data), {
id: `${testRealmURL}person-spec`,
type: 'card',
links: {
Expand Down Expand Up @@ -1602,7 +1621,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
},
);
if (vendor?.type === 'doc') {
assert.deepEqual(vendor.doc, {
assert.deepEqual(stripRealmUserId(vendor.doc), {
data: {
id: `${testRealmURL}Vendor/vendor1`,
type: 'card',
Expand Down Expand Up @@ -2101,7 +2120,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
);

if (hassan?.type === 'doc') {
assert.deepEqual(hassan.doc.data, {
assert.deepEqual(stripRealmUserId(hassan.doc.data), {
id: `${testRealmURL}PetPerson/hassan`,
type: 'card',
links: { self: `${testRealmURL}PetPerson/hassan` },
Expand Down Expand Up @@ -2141,7 +2160,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
realmURL: 'http://test-realm/test/',
},
});
assert.deepEqual(hassan.doc.included, [
assert.deepEqual(stripRealmUserIds(hassan.doc.included), [
{
id: `${testRealmURL}Pet/mango`,
type: 'card',
Expand Down Expand Up @@ -2201,7 +2220,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
new URL(`${testRealmURL}PetPerson/hassan`),
);
if (hassanEntry) {
assert.deepEqual(hassanEntry.searchDoc, {
assert.deepEqual(stripRealmUserId(hassanEntry.searchDoc), {
_cardType: 'Pet Person',
id: `${testRealmURL}PetPerson/hassan`,
firstName: 'Hassan',
Expand Down Expand Up @@ -2263,7 +2282,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
);

if (card?.type === 'doc') {
assert.deepEqual(card.doc, {
assert.deepEqual(stripRealmUserId(card.doc), {
data: {
id: `${testRealmURL}PetPerson/burcu`,
type: 'card',
Expand Down Expand Up @@ -2306,7 +2325,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
new URL(`${testRealmURL}PetPerson/burcu`),
);
if (entry) {
assert.deepEqual(entry.searchDoc, {
assert.deepEqual(stripRealmUserId(entry.searchDoc), {
_cardType: 'Pet Person',
id: `${testRealmURL}PetPerson/burcu`,
firstName: 'Burcu',
Expand Down Expand Up @@ -2380,7 +2399,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
);

if (spec?.type === 'doc') {
assert.deepEqual(spec.doc.data, {
assert.deepEqual(stripRealmUserId(spec.doc.data), {
id: `${testRealmURL}pet-person-spec`,
type: 'card',
links: { self: `${testRealmURL}pet-person-spec` },
Expand Down Expand Up @@ -2533,7 +2552,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
new URL(`${testRealmURL}Friend/hassan`),
);
if (hassan?.type === 'doc') {
assert.deepEqual(hassan.doc.data, {
assert.deepEqual(stripRealmUserId(hassan.doc.data), {
id: `${testRealmURL}Friend/hassan`,
type: 'card',
links: {
Expand Down Expand Up @@ -2579,7 +2598,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
new URL(`${testRealmURL}Friend/hassan`),
);
if (hassanEntry) {
assert.deepEqual(hassanEntry.searchDoc, {
assert.deepEqual(stripRealmUserId(hassanEntry.searchDoc), {
_cardType: 'Friend',
id: `${testRealmURL}Friend/hassan`,
firstName: 'Hassan',
Expand Down Expand Up @@ -2666,7 +2685,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
},
);
if (hassan?.type === 'doc') {
assert.deepEqual(hassan.doc, {
assert.deepEqual(stripRealmUserId(hassan.doc), {
data: {
id: `${testRealmURL}Friend/hassan`,
type: 'card',
Expand Down Expand Up @@ -2784,7 +2803,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
},
);
if (mango?.type === 'doc') {
assert.deepEqual(mango.doc, {
assert.deepEqual(stripRealmUserId(mango.doc), {
data: {
id: `${testRealmURL}Friend/mango`,
type: 'card',
Expand Down Expand Up @@ -2932,7 +2951,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
},
);
if (hassan?.type === 'doc') {
assert.deepEqual(hassan.doc, {
assert.deepEqual(stripRealmUserId(hassan.doc), {
data: {
id: `${testRealmURL}Friend/hassan`,
type: 'card',
Expand Down Expand Up @@ -3056,7 +3075,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
});
if (hassan?.type === 'doc') {
assert.deepEqual(
hassan.doc.data,
stripRealmUserId(hassan.doc.data),
{
id: hassanID,
type: 'card',
Expand Down Expand Up @@ -3091,7 +3110,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
);

assert.deepEqual(
hassan.doc.included,
stripRealmUserIds(hassan.doc.included),
[
{
id: mangoID,
Expand Down Expand Up @@ -3190,7 +3209,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
});
if (mango?.type === 'doc') {
assert.deepEqual(
mango.doc.data,
stripRealmUserId(mango.doc.data),
{
id: mangoID,
type: 'card',
Expand Down Expand Up @@ -3220,7 +3239,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
'mango doc.data is correct',
);
assert.deepEqual(
mango.doc.included,
stripRealmUserIds(mango.doc.included),
[
{
id: hassanID,
Expand Down Expand Up @@ -3329,7 +3348,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
});
if (vanGogh?.type === 'doc') {
assert.deepEqual(
vanGogh.doc.data,
stripRealmUserId(vanGogh.doc.data),
{
id: vanGoghID,
type: 'card',
Expand Down Expand Up @@ -3359,7 +3378,7 @@ module(`Integration | realm indexing and querying`, function (hooks) {
'vanGogh doc.data is correct',
);
assert.deepEqual(
vanGogh.doc.included,
stripRealmUserIds(vanGogh.doc.included),
[
{
id: hassanID,
Expand Down

0 comments on commit 72b80bd

Please sign in to comment.