mirror of
https://github.com/penpot/penpot.git
synced 2025-01-26 00:19:07 -05:00
3e090b126e
Mainly removes an inconsistent use of path params and normalize all routes to use query params for make it extensible without breaking urls.
117 lines
2.9 KiB
JavaScript
117 lines
2.9 KiB
JavaScript
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() {
|
|
await this.mockRPC(
|
|
"get-profile",
|
|
"logged-in-user/get-profile-logged-in.json",
|
|
);
|
|
}
|
|
|
|
async setupEmptyFile() {
|
|
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",
|
|
);
|
|
await this.mockRPC(
|
|
"get-file-fragment?file-id=*&fragment-id=*",
|
|
"viewer/get-file-fragment-empty-file.json",
|
|
);
|
|
}
|
|
|
|
async setupFileWithSingleBoard() {
|
|
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",
|
|
);
|
|
await this.mockRPC(
|
|
"get-file-fragment?file-id=*&fragment-id=*",
|
|
"viewer/get-file-fragment-single-board.json",
|
|
);
|
|
}
|
|
|
|
async setupFileWithComments() {
|
|
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",
|
|
);
|
|
await this.mockRPC(
|
|
"get-file-fragment?file-id=*&fragment-id=*",
|
|
"viewer/get-file-fragment-single-board.json",
|
|
);
|
|
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",
|
|
);
|
|
}
|
|
|
|
#ws = null;
|
|
|
|
constructor(page) {
|
|
super(page);
|
|
}
|
|
|
|
async goToViewer({
|
|
fileId = ViewerPage.anyFileId,
|
|
pageId = ViewerPage.anyPageId,
|
|
} = {}) {
|
|
await this.page.goto(
|
|
`/#/view?file-id=${fileId}&page-id=${pageId}§ion=interactions&index=0`,
|
|
);
|
|
|
|
this.#ws = await this.waitForNotificationsWebSocket();
|
|
await this.#ws.mockOpen();
|
|
}
|
|
|
|
async cleanUp() {
|
|
await this.#ws.mockClose();
|
|
}
|
|
|
|
async showComments(clickOptions = {}) {
|
|
await this.page
|
|
.getByRole("button", { name: "Comments (G C)" })
|
|
.click(clickOptions);
|
|
}
|
|
|
|
async showCommentsThread(number, clickOptions = {}) {
|
|
await this.page
|
|
.getByTestId("floating-thread-bubble")
|
|
.filter({ hasText: number.toString() })
|
|
.click(clickOptions);
|
|
}
|
|
|
|
async showCode(clickOptions = {}) {
|
|
await this.page
|
|
.getByRole("button", { name: "Inspect (G I)" })
|
|
.click(clickOptions);
|
|
}
|
|
}
|