diff --git a/src/Fluff4me.ts b/src/Fluff4me.ts index 58ac9f8..2cade74 100644 --- a/src/Fluff4me.ts +++ b/src/Fluff4me.ts @@ -171,6 +171,61 @@ export default class Fluff4me { }, })); + const testButtons = document.createElement("div"); + document.body.append(testButtons); + + testButtons.append(createButton({ + name: "Test Following Private Works", + async execute () { + await BUTTON_REGISTRY.createWork.execute("private from start", "aaaaaaa", "story1", "Ongoing", "Private"); + await BUTTON_REGISTRY.createChapter.execute("aaaaa", "aaaaaaa", "story1", "Private"); + await BUTTON_REGISTRY.follow.execute("work", "story1"); + await BUTTON_REGISTRY.getFollow.execute("work", "story1"); + await BUTTON_REGISTRY.getAllFollows.execute("work"); + await BUTTON_REGISTRY.getAllFollowsMerged.execute(); + }, + })); + + testButtons.append(createButton({ + name: "Test Following Works Made Private", + async execute () { + await BUTTON_REGISTRY.createWork.execute("made private later", "bbbbbbbb", "story2", "Ongoing", "Public"); + await BUTTON_REGISTRY.createChapter.execute("bbbbbb", "bbbbbbbb", "story2", "Public"); + await BUTTON_REGISTRY.follow.execute("work", "story2"); + await BUTTON_REGISTRY.getFollow.execute("work", "story2"); + await BUTTON_REGISTRY.getAllFollows.execute("work"); + await BUTTON_REGISTRY.getAllFollowsMerged.execute(); + await BUTTON_REGISTRY.updateWork.execute("story2", undefined, undefined, undefined, undefined, "Private"); + await BUTTON_REGISTRY.viewWork.execute("story2"); + await BUTTON_REGISTRY.getFollow.execute("work", "story2"); + await BUTTON_REGISTRY.getAllFollows.execute("work"); + await BUTTON_REGISTRY.getAllFollowsMerged.execute(); + + }, + })); + + testButtons.append(createButton({ + name: "Create 40 works", + async execute () { + for (let i = 0; i < 30; i++) { + await BUTTON_REGISTRY.createWork.execute(`test story ${i}`, "aaaaaaaaa", `teststory${i}`, "Ongoing", "Public"); + } + for (let i = 0; i < 30; i++) { + await BUTTON_REGISTRY.follow.execute("work", `teststory${i}`); + } + await BUTTON_REGISTRY.getAllFollows.execute("work", 0); + await BUTTON_REGISTRY.getAllFollows.execute("work", 1); + }, + })); + + testButtons.append(createButton({ + name: "Get all follows testing", + async execute () { + await BUTTON_REGISTRY.getAllFollowsMerged.execute(0); + await BUTTON_REGISTRY.getAllFollowsMerged.execute(1); + }, + })); + } } diff --git a/src/dev/ButtonRegistry.ts b/src/dev/ButtonRegistry.ts index 3cb71f8..58fd733 100644 --- a/src/dev/ButtonRegistry.ts +++ b/src/dev/ButtonRegistry.ts @@ -234,8 +234,8 @@ export const BUTTON_REGISTRY = { getAllFollows: { name: "Get All Follows", - async execute (type: string) { - const response = await fetch(`${Env.API_ORIGIN}following/${type}`, { + async execute (type: string, page: number = 0) { + const response = await fetch(`${Env.API_ORIGIN}following/${type}?page=${page}`, { credentials: "include", }).then(response => response.json()); console.log(response); @@ -244,8 +244,8 @@ export const BUTTON_REGISTRY = { getAllFollowsMerged: { name: "Get All Follows Merged", - async execute () { - const response = await fetch(`${Env.API_ORIGIN}following`, { + async execute (page: number = 0) { + const response = await fetch(`${Env.API_ORIGIN}following?page=${page}`, { credentials: "include", }).then(response => response.json()); console.log(response);