2024-06-04 11:25:09 +02:00
|
|
|
import { BaseWebSocketPage } from "./BaseWebSocketPage";
|
|
|
|
|
|
|
|
export class ViewerPage extends BaseWebSocketPage {
|
|
|
|
static anyFileId = "c7ce0794-0992-8105-8004-38f280443849";
|
|
|
|
static anyPageId = "c7ce0794-0992-8105-8004-38f28044384a";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This should be called on `test.beforeEach`.
|
|
|
|
*
|
|
|
|
* @param {Page} page
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
static async init(page) {
|
|
|
|
await BaseWebSocketPage.initWebSockets(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
async setupLoggedInUser() {
|
2024-07-01 10:28:40 +02:00
|
|
|
await this.mockRPC(
|
|
|
|
"get-profile",
|
|
|
|
"logged-in-user/get-profile-logged-in.json",
|
|
|
|
);
|
2024-06-04 11:25:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async setupEmptyFile() {
|
2024-07-01 10:28:40 +02:00
|
|
|
await this.mockRPC(
|
|
|
|
/get\-view\-only\-bundle\?/,
|
|
|
|
"viewer/get-view-only-bundle-empty-file.json",
|
|
|
|
);
|
|
|
|
await this.mockRPC(
|
|
|
|
"get-comment-threads?file-id=*",
|
|
|
|
"workspace/get-comment-threads-empty.json",
|
|
|
|
);
|
2024-06-04 11:25:09 +02:00
|
|
|
await this.mockRPC(
|
|
|
|
"get-file-fragment?file-id=*&fragment-id=*",
|
|
|
|
"viewer/get-file-fragment-empty-file.json",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-06-19 09:25:58 +02:00
|
|
|
async setupFileWithSingleBoard() {
|
2024-07-01 10:28:40 +02:00
|
|
|
await this.mockRPC(
|
|
|
|
/get\-view\-only\-bundle\?/,
|
|
|
|
"viewer/get-view-only-bundle-single-board.json",
|
|
|
|
);
|
|
|
|
await this.mockRPC(
|
|
|
|
"get-comment-threads?file-id=*",
|
|
|
|
"workspace/get-comment-threads-empty.json",
|
|
|
|
);
|
2024-06-19 09:25:58 +02:00
|
|
|
await this.mockRPC(
|
|
|
|
"get-file-fragment?file-id=*&fragment-id=*",
|
|
|
|
"viewer/get-file-fragment-single-board.json",
|
|
|
|
);
|
2024-07-01 10:28:40 +02:00
|
|
|
}
|
2024-06-19 09:25:58 +02:00
|
|
|
|
|
|
|
async setupFileWithComments() {
|
2024-07-01 10:28:40 +02:00
|
|
|
await this.mockRPC(
|
|
|
|
/get\-view\-only\-bundle\?/,
|
|
|
|
"viewer/get-view-only-bundle-single-board.json",
|
|
|
|
);
|
|
|
|
await this.mockRPC(
|
|
|
|
"get-comment-threads?file-id=*",
|
|
|
|
"workspace/get-comment-threads-not-empty.json",
|
|
|
|
);
|
2024-06-19 09:25:58 +02:00
|
|
|
await this.mockRPC(
|
|
|
|
"get-file-fragment?file-id=*&fragment-id=*",
|
|
|
|
"viewer/get-file-fragment-single-board.json",
|
|
|
|
);
|
2024-07-01 10:28:40 +02:00
|
|
|
await this.mockRPC(
|
|
|
|
"get-comments?thread-id=*",
|
|
|
|
"workspace/get-thread-comments.json",
|
|
|
|
);
|
|
|
|
await this.mockRPC(
|
|
|
|
"update-comment-thread-status",
|
|
|
|
"workspace/update-comment-thread-status.json",
|
|
|
|
);
|
|
|
|
}
|
2024-06-19 09:25:58 +02:00
|
|
|
|
2024-06-04 11:25:09 +02:00
|
|
|
#ws = null;
|
|
|
|
|
|
|
|
constructor(page) {
|
|
|
|
super(page);
|
|
|
|
}
|
|
|
|
|
2024-07-01 10:28:40 +02:00
|
|
|
async goToViewer({
|
|
|
|
fileId = ViewerPage.anyFileId,
|
|
|
|
pageId = ViewerPage.anyPageId,
|
|
|
|
} = {}) {
|
|
|
|
await this.page.goto(
|
|
|
|
`/#/view/${fileId}?page-id=${pageId}§ion=interactions&index=0`,
|
|
|
|
);
|
2024-06-04 11:25:09 +02:00
|
|
|
|
|
|
|
this.#ws = await this.waitForNotificationsWebSocket();
|
|
|
|
await this.#ws.mockOpen();
|
|
|
|
}
|
|
|
|
|
|
|
|
async cleanUp() {
|
|
|
|
await this.#ws.mockClose();
|
|
|
|
}
|
2024-06-07 12:58:19 +02:00
|
|
|
|
|
|
|
async showComments(clickOptions = {}) {
|
|
|
|
await this.page
|
|
|
|
.getByRole("button", { name: "Comments (G C)" })
|
|
|
|
.click(clickOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
async showCommentsThread(number, clickOptions = {}) {
|
|
|
|
await this.page
|
2024-07-01 10:28:40 +02:00
|
|
|
.getByTestId("floating-thread-bubble")
|
|
|
|
.filter({ hasText: number.toString() })
|
|
|
|
.click(clickOptions);
|
2024-06-07 12:58:19 +02:00
|
|
|
}
|
2024-06-19 09:25:58 +02:00
|
|
|
|
|
|
|
async showCode(clickOptions = {}) {
|
|
|
|
await this.page
|
2024-07-01 10:28:40 +02:00
|
|
|
.getByRole("button", { name: "Inspect (G I)" })
|
2024-06-19 09:25:58 +02:00
|
|
|
.click(clickOptions);
|
|
|
|
}
|
2024-06-04 11:25:09 +02:00
|
|
|
}
|