-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More commenting test #4719
Merged
Merged
More commenting test #4719
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { Page } from 'puppeteer' | ||
import type { UtopiaPuppeteerBrowser } from './test-utils' | ||
|
||
export const TIMEOUT = 120000 | ||
|
||
const BRANCH_NAME = process.env.BRANCH_NAME ? `&branch_name=${process.env.BRANCH_NAME}` : '' | ||
const BASE_URL = process.env.BASE_URL ?? 'http://localhost:8000' | ||
|
||
export async function init(utopiaBrowser: UtopiaPuppeteerBrowser) { | ||
const { page } = await utopiaBrowser.setup({ | ||
url: `${BASE_URL}/p/?fakeUser=alice&Multiplayer=true${BRANCH_NAME}`, | ||
timeout: TIMEOUT, | ||
}) | ||
|
||
const signInButton = await page.waitForSelector('div[data-testid="sign-in-button"]') | ||
await signInButton!.click() | ||
await page.waitForSelector('#playground-scene') // wait for the scene to render | ||
|
||
return page | ||
} | ||
|
||
export async function enterCommentMode(page: Page) { | ||
const commentModeButton = await page.waitForSelector( | ||
'div[data-testid="canvas-toolbar-comment-mode-connected"]', | ||
) | ||
await commentModeButton!.click() | ||
} | ||
|
||
export async function placeCommentOnCanvas(page: Page, text: string, x: number, y: number) { | ||
const canvasControlsContainer = await page.waitForSelector('#new-canvas-controls-container') | ||
await canvasControlsContainer!.click({ offset: { x, y } }) | ||
|
||
const commentBox = await page.waitForSelector('[contenteditable="true"]') | ||
await commentBox!.focus() | ||
await commentBox!.type(text) | ||
await page.keyboard.press('Enter') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import { setupBrowser, wait } from '../utils' | ||
import type { Browser } from 'puppeteer' | ||
import { TIMEOUT, enterCommentMode, init, placeCommentOnCanvas } from './comment-utils' | ||
import { createUtopiaPuppeteerBrowser } from './test-utils' | ||
|
||
describe('Comments test', () => { | ||
let utopiaBrowser = createUtopiaPuppeteerBrowser() | ||
it( | ||
'Basic comment workflow (place, reply)', | ||
async () => { | ||
const page = await init(utopiaBrowser) | ||
|
||
// Enter comment mode using the toolbar | ||
const commentModeButton = await page.waitForSelector( | ||
'div[data-testid="canvas-toolbar-comment-mode-connected"]', | ||
) | ||
await commentModeButton!.click() | ||
|
||
// Click on the canvas to open the comment popup | ||
const canvasControlsContainer = await page.waitForSelector('#new-canvas-controls-container') | ||
await canvasControlsContainer!.click({ offset: { x: 500, y: 500 } }) | ||
|
||
// Write to comment text and submit it | ||
const commentBox = await page.waitForSelector('[contenteditable="true"]') | ||
await commentBox!.focus() | ||
await commentBox!.type('hello comments') | ||
await page.keyboard.press('Enter') | ||
|
||
// Check if the comment text is on the screen | ||
const thread = await page.waitForFunction( | ||
'document.querySelector("body").innerText.includes("hello comments")', | ||
) | ||
expect(thread).not.toBeNull() | ||
|
||
// Click away to close the comment popup | ||
await canvasControlsContainer!.click({ offset: { x: 700, y: 700 } }) | ||
|
||
// Check if the comment indicator is still visible | ||
const commentIndicator = await page.waitForSelector('div[data-testid="comment-indicator"]') | ||
|
||
expect(commentIndicator).not.toBeNull() | ||
|
||
// Check that the comment popup is closed | ||
const popupAfterClose = await page.$$('div[data-testid="comment-popup"]') | ||
expect(popupAfterClose).toHaveLength(0) | ||
|
||
// Open the comment popup again | ||
const comment = await page.waitForSelector('div[data-testid="comment-wrapper"]') | ||
await comment!.click({ offset: { x: 10, y: 10 } }) | ||
|
||
// Check that the comment popup is open | ||
const popupAfterReopen = await page.$$('div[data-testid="comment-popup"]') | ||
expect(popupAfterReopen).toHaveLength(1) | ||
|
||
// Submit a reply | ||
const commentBox2 = await page.waitForSelector('[contenteditable="true"]') | ||
await commentBox2!.focus() | ||
await commentBox2!.type('this is a reply') | ||
await page.keyboard.press('Enter') | ||
|
||
// Check if the original comment and the reply comment are both on the screen | ||
const originalComment = await page.waitForFunction( | ||
'document.querySelector("body").innerText.includes("hello comments")', | ||
) | ||
expect(originalComment).not.toBeNull() | ||
|
||
const replyComment = await page.waitForFunction( | ||
'document.querySelector("body").innerText.includes("this is a reply")', | ||
) | ||
expect(replyComment).not.toBeNull() | ||
|
||
// Leave comment mode by pressing ESC | ||
await page.keyboard.press('Escape') | ||
|
||
// Check that the comment popup is closed | ||
const popupAfterEsc = await page.$$('div[data-testid="comment-popup"]') | ||
expect(popupAfterEsc).toHaveLength(0) | ||
}, | ||
TIMEOUT, | ||
) | ||
it( | ||
'Placing a comment without submitting does not create a comment', | ||
async () => { | ||
const page = await init(utopiaBrowser) | ||
|
||
await enterCommentMode(page) | ||
|
||
// Clicking to add a comment | ||
const canvasControlsContainer = await page.waitForSelector('#new-canvas-controls-container') | ||
await canvasControlsContainer!.click({ offset: { x: 500, y: 500 } }) | ||
|
||
// Pressing escape without submitting | ||
await page.keyboard.press('Escape') | ||
|
||
// There are no comment indicators on the canvas | ||
const commentIndicators = await page.$$('div[data-testid="comment-indicator"]') | ||
expect(commentIndicators).toHaveLength(0) | ||
}, | ||
TIMEOUT, | ||
) | ||
it( | ||
'Resolve comment', | ||
async () => { | ||
const page = await init(utopiaBrowser) | ||
|
||
await enterCommentMode(page) | ||
await placeCommentOnCanvas(page, 'hello comments', 500, 500) | ||
|
||
// Resolve the comment | ||
|
||
const resolveButton = await page.waitForSelector('div[data-testid="resolve-thread-button"]') | ||
await resolveButton!.click() | ||
|
||
// Check that the comment indicator is gone | ||
const commentIndicators = await page.$$('div[data-testid="comment-indicator"]') | ||
expect(commentIndicators).toHaveLength(0) | ||
}, | ||
TIMEOUT, | ||
) | ||
it( | ||
'Close comment popup with the mouse', | ||
async () => { | ||
const page = await init(utopiaBrowser) | ||
|
||
await enterCommentMode(page) | ||
await placeCommentOnCanvas(page, 'hello comments', 500, 500) | ||
|
||
const closeCommentButton = await page.waitForSelector('div[data-testid="close-comment"]') | ||
await closeCommentButton!.click() | ||
|
||
// Check that the comment popup is closed but the indicator is still there | ||
const commentPopups = await page.$$('div[data-testid="comment-popup"]') | ||
expect(commentPopups).toHaveLength(0) | ||
|
||
const commentIndicators = await page.$$('div[data-testid="comment-indicator"]') | ||
expect(commentIndicators).toHaveLength(1) | ||
}, | ||
TIMEOUT, | ||
) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would deserve a more specific name, e.g.
initBrowserTest