Skip to content

Commit

Permalink
fix: complete MewType serialization refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyg committed Aug 22, 2024
1 parent 6734fa7 commit 4767271
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 125 deletions.
62 changes: 0 additions & 62 deletions dnas/mewsfeed/zomes/integrity/mews/tests/create_mew_test.rs

This file was deleted.

24 changes: 12 additions & 12 deletions tests/src/mewsfeed/mews/followed-creators-mews.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ it("Unfollowing should exclude creators mews from feed", async () => {
const aliceMewInput: Mew = {
text: aliceMewContent,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
await alice.cells[0].callZome({
zome_name: "mews",
Expand Down Expand Up @@ -339,7 +339,7 @@ it("Followed creators mews should be ordered by timestamp in descending order",
const firstMewInput: Mew = {
text: firstMewContent,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -351,7 +351,7 @@ it("Followed creators mews should be ordered by timestamp in descending order",
const secondMewInput: Mew = {
text: secondMewContent,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
await bob.cells[0].callZome({
zome_name: "mews",
Expand All @@ -363,7 +363,7 @@ it("Followed creators mews should be ordered by timestamp in descending order",
const thirdMewInput: Mew = {
text: thirdMewContent,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
await carol.cells[0].callZome({
zome_name: "mews",
Expand All @@ -375,7 +375,7 @@ it("Followed creators mews should be ordered by timestamp in descending order",
const fourthMewInput: Mew = {
text: fourthMewContent,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
await alice.cells[0].callZome({
zome_name: "mews",
Expand Down Expand Up @@ -453,7 +453,7 @@ it("Followed creators mews list are time-paginated", async () => {
const createMewInput1: Mew = {
text: mewContent1,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash1 = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -465,7 +465,7 @@ it("Followed creators mews list are time-paginated", async () => {
const createMewInput2: Mew = {
text: mewContent2,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash2 = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -477,7 +477,7 @@ it("Followed creators mews list are time-paginated", async () => {
const createMewInput3: Mew = {
text: mewContent3,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash3 = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -489,7 +489,7 @@ it("Followed creators mews list are time-paginated", async () => {
const createMewInput4: Mew = {
text: mewContent4,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash4 = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -501,7 +501,7 @@ it("Followed creators mews list are time-paginated", async () => {
const createMewInput5: Mew = {
text: mewContent5,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash5 = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -513,7 +513,7 @@ it("Followed creators mews list are time-paginated", async () => {
const createMewInput6: Mew = {
text: mewContent6,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash6 = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -525,7 +525,7 @@ it("Followed creators mews list are time-paginated", async () => {
const createMewInput7: Mew = {
text: mewContent7,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash7 = await alice.cells[0].callZome({
zome_name: "mews",
Expand Down
20 changes: 10 additions & 10 deletions tests/src/mewsfeed/mews/mention-to-mews.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ it("mention in mews", async () => {
await createMew(alice.cells[0], {
text: "this is for @bob",
links: [{ [LinkTargetName.Mention]: bob.agentPubKey }],
mew_type: { Original: null },
mew_type: { type: MewTypeName.Original },
});

const actionHash2: ActionHash = await createMew(bob.cells[0], {
text: "this is for @bob 2",
links: [{ [LinkTargetName.Mention]: bob.agentPubKey }],
mew_type: { Original: null },
mew_type: { type: MewTypeName.Original },
});

const actionHash3: ActionHash = await createMew(alice.cells[0], {
text: "this is for @alice",
links: [{ [LinkTargetName.Mention]: alice.agentPubKey }],
mew_type: { Original: null },
mew_type: { type: MewTypeName.Original },
});

await dhtSync([alice, bob], alice.cells[0].cell_id[0]);
Expand Down Expand Up @@ -90,7 +90,7 @@ it("Mentions list are time-paginated", async () => {
const createMewInput1: Mew = {
text: mewContent1,
links: [{ [LinkTargetName.Mention]: alice.agentPubKey }],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash1 = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -102,7 +102,7 @@ it("Mentions list are time-paginated", async () => {
const createMewInput2: Mew = {
text: mewContent2,
links: [{ [LinkTargetName.Mention]: alice.agentPubKey }],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash2 = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -114,7 +114,7 @@ it("Mentions list are time-paginated", async () => {
const createMewInput3: Mew = {
text: mewContent3,
links: [{ [LinkTargetName.Mention]: alice.agentPubKey }],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash3 = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -126,7 +126,7 @@ it("Mentions list are time-paginated", async () => {
const createMewInput4: Mew = {
text: mewContent4,
links: [{ [LinkTargetName.Mention]: alice.agentPubKey }],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash4 = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -138,7 +138,7 @@ it("Mentions list are time-paginated", async () => {
const createMewInput5: Mew = {
text: mewContent5,
links: [{ [LinkTargetName.Mention]: alice.agentPubKey }],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash5 = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -150,7 +150,7 @@ it("Mentions list are time-paginated", async () => {
const createMewInput6: Mew = {
text: mewContent6,
links: [{ [LinkTargetName.Mention]: alice.agentPubKey }],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash6 = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -162,7 +162,7 @@ it("Mentions list are time-paginated", async () => {
const createMewInput7: Mew = {
text: mewContent7,
links: [{ [LinkTargetName.Mention]: alice.agentPubKey }],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const mewActionHash7 = await alice.cells[0].callZome({
zome_name: "mews",
Expand Down
25 changes: 13 additions & 12 deletions tests/src/mewsfeed/mews/mew-to-responses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ it("Agent can reply to a mew", async () => {
const aliceMewInput: Mew = {
text: aliceMewContent,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const action_hash: ActionHash = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -33,7 +33,7 @@ it("Agent can reply to a mew", async () => {
const aliceReplyInput: Mew = {
text: aliceReplyContent,
links: [],
mew_type: { [MewTypeName.Reply]: action_hash },
mew_type: { type: MewTypeName.Reply, original_action_hash: action_hash },
};
const reply_action_hash: ActionHash = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -46,7 +46,7 @@ it("Agent can reply to a mew", async () => {
fn_name: "get_mew_with_context",
payload: reply_action_hash,
});
assert.ok(MewTypeName.Reply in replyMew.mew.mew_type, "mew is a reply");
assert.ok(MewTypeName.Reply === replyMew.mew.mew_type.type, "mew is a reply");
assert.equal(
replyMew.mew.text,
aliceReplyContent,
Expand All @@ -59,7 +59,7 @@ it("Agent can reply to a mew", async () => {
payload: action_hash,
});
assert.ok(
MewTypeName.Original in originalMew.mew.mew_type,
MewTypeName.Original === originalMew.mew.mew_type.type,
"mew is an original mew"
);
assert.equal(originalMew.mew.text, aliceMewContent, "mew is alice's mew");
Expand Down Expand Up @@ -89,7 +89,7 @@ it("Agent can mewmew a mew, only once", async () => {
const aliceMewInput: Mew = {
text: aliceMewContent,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const action_hash: ActionHash = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -100,7 +100,7 @@ it("Agent can mewmew a mew, only once", async () => {
const aliceMewmewInput: Mew = {
text: "",
links: [],
mew_type: { [MewTypeName.Mewmew]: action_hash },
mew_type: { type: MewTypeName.Mewmew, original_action_hash: action_hash },
};
const mewmew_action_hash: ActionHash = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -113,7 +113,7 @@ it("Agent can mewmew a mew, only once", async () => {
fn_name: "get_mew_with_context",
payload: mewmew_action_hash,
});
assert.ok(MewTypeName.Mewmew in mewmew.mew.mew_type, "mew is a mewmew");
assert.ok(MewTypeName.Mewmew === mewmew.mew.mew_type.type, "mew is a mewmew");
assert.deepEqual(
mewmew.mew,
aliceMewmewInput,
Expand All @@ -126,7 +126,7 @@ it("Agent can mewmew a mew, only once", async () => {
payload: action_hash,
});
assert.ok(
MewTypeName.Original in originalMew.mew.mew_type,
MewTypeName.Original === originalMew.mew.mew_type.type,
"mew is an original mew"
);
assert.equal(originalMew.mew.text, aliceMewContent, "mew is alice's mew");
Expand Down Expand Up @@ -167,7 +167,7 @@ it("Agent can quote a mew", async () => {
const aliceMewInput: Mew = {
text: aliceMewContent,
links: [],
mew_type: { [MewTypeName.Original]: null },
mew_type: { type: MewTypeName.Original },
};
const action_hash: ActionHash = await alice.cells[0].callZome({
zome_name: "mews",
Expand All @@ -180,7 +180,8 @@ it("Agent can quote a mew", async () => {
text: aliceQuoteText,
links: [],
mew_type: {
[MewTypeName.Quote]: action_hash,
type: MewTypeName.Quote,
original_action_hash: action_hash,
},
};
const quote_action_hash: ActionHash = await alice.cells[0].callZome({
Expand All @@ -194,7 +195,7 @@ it("Agent can quote a mew", async () => {
fn_name: "get_mew_with_context",
payload: quote_action_hash,
});
assert.ok(MewTypeName.Quote in quote.mew.mew_type, "mew is a quote");
assert.ok(MewTypeName.Quote === quote.mew.mew_type.type, "mew is a quote");
assert.equal(quote.mew.text, aliceQuoteText, "quote is alice's quote");

const originalMew: FeedMew = await alice.cells[0].callZome({
Expand All @@ -203,7 +204,7 @@ it("Agent can quote a mew", async () => {
payload: action_hash,
});
assert.ok(
MewTypeName.Original in originalMew.mew.mew_type,
MewTypeName.Original === originalMew.mew.mew_type.type,
"mew is an original mew"
);
assert.equal(originalMew.mew.text, aliceMewContent, "mew is alice's mew");
Expand Down
6 changes: 3 additions & 3 deletions tests/src/mewsfeed/mews/mew-with-context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ it("Mew with context contains replies count and is_replied", async () => {
payload: {
text: "my reply blah blah",
links: [],
mew_type: { [MewTypeName.Reply]: actionHash },
mew_type: { type: MewTypeName.Reply, original_action_hash: actionHash },
},
});

Expand Down Expand Up @@ -176,7 +176,7 @@ it("Mew with context contains quotes count and is_quoted", async () => {
payload: {
text: "this is a quote blah blah",
links: [],
mew_type: { [MewTypeName.Quote]: actionHash },
mew_type: { type: MewTypeName.Quote, original_action_hash: actionHash },
},
});

Expand Down Expand Up @@ -235,7 +235,7 @@ it("Mew with context contains mewmews count and is_mewmewed", async () => {
payload: {
text: "",
links: [],
mew_type: { [MewTypeName.Mewmew]: actionHash },
mew_type: { type: MewTypeName.Mewmew, original_action_hash: actionHash },
},
});

Expand Down
Loading

0 comments on commit 4767271

Please sign in to comment.