Skip to content

Commit

Permalink
Add pagination support for follows endpoint test buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
luminamystere committed Jul 12, 2024
1 parent 67e1fea commit 5f460a6
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
55 changes: 55 additions & 0 deletions src/Fluff4me.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
}));

}
}

Expand Down
8 changes: 4 additions & 4 deletions src/dev/ButtonRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 5f460a6

Please sign in to comment.