2021-09-17 14:40:11 -04:00
|
|
|
// These tests sign in with user #4 and user #5
|
|
|
|
|
|
|
|
import SeleniumHelper from './selenium-helpers.js';
|
|
|
|
|
|
|
|
const {
|
|
|
|
buildDriver,
|
|
|
|
clickText,
|
2021-11-29 16:35:18 -05:00
|
|
|
clickXpath,
|
2021-10-20 10:11:33 -04:00
|
|
|
containsClass,
|
2021-11-29 16:35:18 -05:00
|
|
|
findByXpath,
|
2023-09-25 11:34:30 -04:00
|
|
|
navigate,
|
2021-09-17 14:40:11 -04:00
|
|
|
signIn
|
|
|
|
} = new SeleniumHelper();
|
|
|
|
|
|
|
|
// Using 1 and 2 here. Hopefully this is not confusing.
|
2023-10-24 14:22:28 -04:00
|
|
|
const username1 = `${process.env.SMOKE_USERNAME}4`;
|
|
|
|
const username2 = `${process.env.SMOKE_USERNAME}5`;
|
|
|
|
const password = process.env.SMOKE_PASSWORD;
|
|
|
|
const rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
2021-09-17 14:40:11 -04:00
|
|
|
|
|
|
|
// project for comments (owned by username2)
|
2023-10-24 14:22:28 -04:00
|
|
|
const projectId = process.env.COMMENT_PROJECT_ID || 1300008409;
|
|
|
|
const projectUrl = `${rootUrl}/projects/${projectId}`;
|
2021-09-17 14:40:11 -04:00
|
|
|
|
|
|
|
// profile for comments (username2)
|
2023-10-24 14:22:28 -04:00
|
|
|
const profileUrl = `${rootUrl}/users/${username2}`;
|
2021-09-17 14:40:11 -04:00
|
|
|
|
|
|
|
// studio for comments (hosted by username2) comments tab
|
2023-10-24 14:22:28 -04:00
|
|
|
const studioId = process.env.COMMENT_STUDIO_ID || 10005646;
|
|
|
|
const studioUrl = `${rootUrl}/studios/${studioId}/comments`;
|
2021-09-17 14:40:11 -04:00
|
|
|
|
2021-10-01 14:42:25 -04:00
|
|
|
// setup comments to leave
|
2023-10-24 14:22:28 -04:00
|
|
|
const date = new Date();
|
|
|
|
const dateString = `Y:${date.getFullYear()} - M:${date.getMonth() + 1} - D:${date.getDate()} ` +
|
2021-10-20 10:06:28 -04:00
|
|
|
`: ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
|
2023-10-24 14:22:28 -04:00
|
|
|
const buildNumber = process.env.CIRCLE_BUILD_NUM || dateString;
|
|
|
|
const projectComment = `${buildNumber} project`;
|
|
|
|
const profileComment = `${buildNumber} profile`;
|
|
|
|
const studioComment = `${buildNumber} studio`;
|
2021-10-01 14:42:25 -04:00
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
const projectReply = `${projectComment} reply`;
|
|
|
|
const profileReply = `${profileComment} reply`;
|
|
|
|
const studioReply = `${studioComment} reply`;
|
2021-10-26 12:02:25 -04:00
|
|
|
|
2021-12-03 09:14:25 -05:00
|
|
|
jest.setTimeout(60000);
|
2021-09-17 14:40:11 -04:00
|
|
|
|
|
|
|
let driver;
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
describe('comment tests', () => {
|
2021-09-17 14:40:11 -04:00
|
|
|
beforeAll(async () => {
|
|
|
|
driver = await buildDriver('www-integration project comments');
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(rootUrl);
|
2021-09-17 14:40:11 -04:00
|
|
|
});
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
afterAll(() => driver.quit());
|
2021-10-01 14:43:36 -04:00
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
describe('leave comments', () => {
|
2021-10-20 10:09:32 -04:00
|
|
|
beforeAll(async () => {
|
2021-11-19 09:38:23 -05:00
|
|
|
await signIn(username1, password);
|
2021-10-20 10:09:32 -04:00
|
|
|
await findByXpath('//span[contains(@class, "profile-name")]');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(rootUrl);
|
2021-10-20 10:09:32 -04:00
|
|
|
await clickXpath('//a[contains(@class, "user-info")]');
|
|
|
|
await clickText('Sign out');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('leave comment on project', async () => {
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(projectUrl);
|
2021-10-20 10:09:32 -04:00
|
|
|
|
|
|
|
// leave the comment
|
2023-10-24 14:22:28 -04:00
|
|
|
const commentBox = await findByXpath('//textArea[@name="compose-comment"]');
|
2021-10-20 10:09:32 -04:00
|
|
|
await commentBox.sendKeys(projectComment);
|
|
|
|
await findByXpath(`//textarea[contains(text(), "${projectComment}")]`);
|
|
|
|
await clickXpath('//button[@class="button compose-post"]');
|
|
|
|
|
|
|
|
// find the comment
|
2023-10-24 14:22:28 -04:00
|
|
|
const commentXpath = `//div[@class="comment-bubble"]/span/span[contains(text(), "${projectComment}")]`;
|
|
|
|
const postedComment = await findByXpath(commentXpath);
|
|
|
|
const commentVisible = await postedComment.isDisplayed();
|
|
|
|
expect(commentVisible).toBe(true);
|
2021-10-20 10:09:32 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('leave comment on a profile', async () => {
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(profileUrl);
|
2021-10-20 10:09:32 -04:00
|
|
|
|
|
|
|
// leave the comment
|
2023-10-24 14:22:28 -04:00
|
|
|
const commentXpath = '//form[@id="main-post-form"]/div/textArea';
|
|
|
|
const commentArea = await findByXpath(commentXpath);
|
2021-10-20 10:09:32 -04:00
|
|
|
await commentArea.sendKeys(profileComment);
|
|
|
|
await clickXpath('//div[@class="button small"]/a[contains(text(), "Post")]');
|
|
|
|
|
|
|
|
// find the comment
|
2023-10-24 14:22:28 -04:00
|
|
|
const newComment = await findByXpath(`//div[@class="comment "]/div/div[contains(text(),` +
|
2021-10-26 12:05:38 -04:00
|
|
|
` "${profileComment}")]`);
|
2023-10-24 14:22:28 -04:00
|
|
|
const commentVisible = await newComment.isDisplayed();
|
|
|
|
expect(commentVisible).toBe(true);
|
2021-10-20 10:09:32 -04:00
|
|
|
|
|
|
|
// return to homepage to sign out with www
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(rootUrl);
|
2021-10-20 10:09:32 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('leave comment on studio', async () => {
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(studioUrl);
|
2021-10-20 10:09:32 -04:00
|
|
|
|
|
|
|
// leave the comment
|
2023-10-24 14:22:28 -04:00
|
|
|
const commentBox = await findByXpath('//textArea[@name="compose-comment"]');
|
2021-10-20 10:09:32 -04:00
|
|
|
await commentBox.sendKeys(studioComment);
|
|
|
|
await findByXpath(`//textarea[contains(text(), "${studioComment}")]`);
|
|
|
|
await clickXpath('//button[@class="button compose-post"]');
|
|
|
|
|
|
|
|
// find the comment
|
2023-10-24 14:22:28 -04:00
|
|
|
const commentXpath = `//div[@class="comment-bubble"]/span/span[contains(text(), "${studioComment}")]`;
|
|
|
|
const postedComment = await findByXpath(commentXpath);
|
|
|
|
const commentVisible = await postedComment.isDisplayed();
|
|
|
|
expect(commentVisible).toBe(true);
|
2021-10-20 10:09:32 -04:00
|
|
|
});
|
2021-10-01 14:43:36 -04:00
|
|
|
});
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
describe('second user tests', () => {
|
2021-10-20 10:11:33 -04:00
|
|
|
beforeAll(async () => {
|
2021-11-19 09:38:23 -05:00
|
|
|
await signIn(username2, password);
|
2021-10-20 10:11:33 -04:00
|
|
|
await findByXpath('//span[contains(@class, "profile-name")]');
|
|
|
|
});
|
|
|
|
|
|
|
|
// get notifications
|
|
|
|
test('get notification badge for comments', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const messages = await findByXpath('//span[@class = "message-count show"]');
|
|
|
|
const messagesVisible = await messages.isDisplayed();
|
|
|
|
expect(messagesVisible).toBe(true);
|
2021-10-20 10:11:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('click notifications for comments', async () => {
|
|
|
|
await clickXpath('//li[@class="link right messages"]');
|
2023-10-24 14:22:28 -04:00
|
|
|
const messages = await findByXpath('//ul[@class="messages-social-list"]');
|
|
|
|
const messagesVisible = await messages.isDisplayed();
|
|
|
|
expect(messagesVisible).toBe(true);
|
2021-10-20 10:11:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('project comment message visible', async () => {
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(`${rootUrl}/messages`);
|
2021-10-20 10:11:33 -04:00
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
const projectMessageXpath = '//p[@class="emoji-text mod-comment" ' +
|
2021-10-20 10:11:33 -04:00
|
|
|
`and contains(text(), "${projectComment}")]`;
|
2023-10-24 14:22:28 -04:00
|
|
|
const projectMessage = await findByXpath(projectMessageXpath);
|
|
|
|
const projectMessageVisible = await projectMessage.isDisplayed();
|
|
|
|
expect(projectMessageVisible).toBe(true);
|
2021-10-20 10:11:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('profile comment message visible', async () => {
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(`${rootUrl}/messages`);
|
2021-10-20 10:11:33 -04:00
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
const profileMessageXpath = '//p[@class="emoji-text mod-comment" ' +
|
2021-10-20 10:11:33 -04:00
|
|
|
`and contains(text(), "${profileComment}")]`;
|
2023-10-24 14:22:28 -04:00
|
|
|
const profileMessage = await findByXpath(profileMessageXpath);
|
|
|
|
const profileMessageVisible = await profileMessage.isDisplayed();
|
|
|
|
expect(profileMessageVisible).toBe(true);
|
2021-10-20 10:11:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
// studio comments do not send a notification
|
|
|
|
|
|
|
|
test('project message links you to project page', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const projectLinkXpath = '//p[@class="emoji-text mod-comment" ' +
|
2021-10-20 10:11:33 -04:00
|
|
|
`and contains(text(), "${projectComment}")]/../../../p[@class = "comment-message-info"]/span/a[2]`;
|
|
|
|
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(`${rootUrl}/messages`);
|
2021-10-20 10:11:33 -04:00
|
|
|
await clickXpath(projectLinkXpath);
|
|
|
|
|
|
|
|
// find green flag overlay
|
2023-10-24 14:22:28 -04:00
|
|
|
const gfOverlay = await findByXpath('//div[@class="stage-wrapper_stage-wrapper_2bejr box_box_2jjDp"]');
|
2021-10-20 10:11:33 -04:00
|
|
|
await gfOverlay.isDisplayed();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('project comment is on project page', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const projectLinkXpath = '//p[@class="emoji-text mod-comment" ' +
|
2021-10-20 10:11:33 -04:00
|
|
|
`and contains(text(), "${projectComment}")]/../../../p[@class = "comment-message-info"]/span/a[2]`;
|
|
|
|
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(`${rootUrl}/messages`);
|
2021-10-20 10:11:33 -04:00
|
|
|
await clickXpath(projectLinkXpath);
|
2021-10-01 14:43:36 -04:00
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
const commentXpath = `//span[contains(text(), "${projectComment}")]`;
|
|
|
|
const singleComment = await findByXpath(commentXpath);
|
|
|
|
const commentVisible = await singleComment.isDisplayed();
|
|
|
|
expect(commentVisible).toBe(true);
|
2021-10-20 10:11:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('project comment is highlighted', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const projectLinkXpath = '//p[@class="emoji-text mod-comment" ' +
|
2021-10-20 10:11:33 -04:00
|
|
|
`and contains(text(), "${projectComment}")]/../../../p[@class = "comment-message-info"]/span/a[2]`;
|
2023-10-24 14:22:28 -04:00
|
|
|
const containerXpath = `//span[contains(text(), "${projectComment}")]/../../../..`;
|
2021-10-20 10:11:33 -04:00
|
|
|
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(`${rootUrl}/messages`);
|
2021-10-20 10:11:33 -04:00
|
|
|
await clickXpath(projectLinkXpath);
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
const commentContainer = await findByXpath(containerXpath);
|
|
|
|
const isHighlighted = await containsClass(commentContainer, 'highlighted-comment');
|
|
|
|
expect(isHighlighted).toBe(true);
|
2021-10-20 10:11:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('profile message links you to profile page', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const profileLinkXpath = '//p[@class="emoji-text mod-comment" ' +
|
2021-10-20 10:11:33 -04:00
|
|
|
`and contains(text(), "${profileComment}")]/../../../` +
|
2023-10-24 14:22:28 -04:00
|
|
|
'p[@class = "comment-message-info"]/span/a[2]';
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(`${rootUrl}/messages`);
|
2021-10-20 10:11:33 -04:00
|
|
|
await clickXpath(profileLinkXpath);
|
|
|
|
|
|
|
|
// find profile data
|
2023-10-24 14:22:28 -04:00
|
|
|
const profileDataXpath = '//div[@id="profile-data"]';
|
|
|
|
const pathToUsername = '/div[@class="box-head"]/div[@class="header-text"]/h2';
|
2021-10-20 10:11:33 -04:00
|
|
|
await findByXpath(profileDataXpath);
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
const header = await findByXpath(profileDataXpath + pathToUsername);
|
|
|
|
const uname = await header.getText();
|
|
|
|
expect(uname).toBe(username2);
|
2021-10-20 10:11:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('profile comment is on profile page', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const profileLinkXpath = '//p[@class="emoji-text mod-comment" ' +
|
2021-10-20 10:11:33 -04:00
|
|
|
`and contains(text(), "${profileComment}")]/../../../` +
|
2023-10-24 14:22:28 -04:00
|
|
|
'p[@class = "comment-message-info"]/span/a[2]';
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(`${rootUrl}/messages`);
|
2021-10-20 10:11:33 -04:00
|
|
|
await clickXpath(profileLinkXpath);
|
|
|
|
|
|
|
|
// find comment
|
2023-10-24 14:22:28 -04:00
|
|
|
const commentXpath = `//div[contains(text(), "${profileComment}")]`;
|
|
|
|
const leftComment = await findByXpath(commentXpath);
|
|
|
|
const commentVisible = await leftComment.isDisplayed();
|
|
|
|
expect(commentVisible).toBe(true);
|
2021-10-20 10:11:33 -04:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
test('profile comment is highlighted', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const profileLinkXpath = '//p[@class="emoji-text mod-comment" ' +
|
2021-10-20 10:11:33 -04:00
|
|
|
`and contains(text(), "${profileComment}")]/../../../` +
|
2023-10-24 14:22:28 -04:00
|
|
|
'p[@class = "comment-message-info"]/span/a[2]';
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(`${rootUrl}/messages`);
|
2021-10-20 10:11:33 -04:00
|
|
|
await clickXpath(profileLinkXpath);
|
|
|
|
|
|
|
|
// comment highlighted?
|
2023-10-24 14:22:28 -04:00
|
|
|
const containerXpath = `//div[contains(text(), "${profileComment}")]/../../..`;
|
|
|
|
const commentContainer = await findByXpath(containerXpath);
|
|
|
|
const isHighlighted = await containsClass(commentContainer, 'highlighted');
|
|
|
|
expect(isHighlighted).toBe(true);
|
2021-10-20 10:11:33 -04:00
|
|
|
});
|
2021-10-26 12:02:25 -04:00
|
|
|
|
|
|
|
test('project: reply to comment', async () => {
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(projectUrl);
|
2023-10-24 14:22:28 -04:00
|
|
|
const commentXpath = `//span[contains(text(), "${projectComment}")]/../..`;
|
|
|
|
const replyXpath = `${commentXpath}//span[@class = "comment-reply"]`;
|
2021-10-26 12:02:25 -04:00
|
|
|
await clickXpath(replyXpath);
|
|
|
|
|
|
|
|
// type reply
|
2023-10-24 14:22:28 -04:00
|
|
|
const replyRow = '//div[contains(@class, "comment-reply-row")]';
|
|
|
|
const replyComposeXpath = `${replyRow}//textArea[@class = "inplace-textarea"]`;
|
|
|
|
const composeBox = await findByXpath(replyComposeXpath);
|
2021-10-26 12:02:25 -04:00
|
|
|
await composeBox.sendKeys(projectReply);
|
|
|
|
|
|
|
|
// click post
|
2023-09-21 18:44:03 -04:00
|
|
|
await clickXpath(`${replyRow}//button[@class = "button compose-post"]`);
|
2021-10-26 12:02:25 -04:00
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
const postedReply = await findByXpath(`//span[contains(text(), "${projectReply}")]`);
|
|
|
|
const commentVisible = await postedReply.isDisplayed();
|
|
|
|
expect(commentVisible).toBe(true);
|
2021-10-26 12:02:25 -04:00
|
|
|
});
|
2021-10-29 16:18:18 -04:00
|
|
|
|
2021-11-08 10:53:44 -05:00
|
|
|
test('profile reply to comment', async () => {
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(profileUrl);
|
2021-11-08 10:53:44 -05:00
|
|
|
// find the comment and click reply
|
2023-10-24 14:22:28 -04:00
|
|
|
const commentXpath = `//div[contains(text(), "${profileComment}")]/..`;
|
|
|
|
await clickXpath(`${commentXpath}//a[@class = "reply"]`);
|
2021-11-08 10:53:44 -05:00
|
|
|
|
|
|
|
// select reply box and type reply
|
2023-10-24 14:22:28 -04:00
|
|
|
const replyComposeBox = await findByXpath(`${commentXpath}//textArea`);
|
2021-11-08 10:53:44 -05:00
|
|
|
await replyComposeBox.sendKeys(profileReply);
|
|
|
|
|
|
|
|
// click post
|
2023-10-24 14:22:28 -04:00
|
|
|
await clickXpath(`${commentXpath}//a[contains(text(), "Post")]`);
|
2021-11-08 10:53:44 -05:00
|
|
|
|
|
|
|
// The reply wasn't findable by xpath after several attempts, but it seems
|
|
|
|
// better to have this much of a test
|
|
|
|
});
|
|
|
|
|
2021-10-29 16:18:18 -04:00
|
|
|
test('studio: reply to comment', async () => {
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(studioUrl);
|
2021-10-29 16:18:18 -04:00
|
|
|
|
|
|
|
// find the comment and click reply
|
2023-10-24 14:22:28 -04:00
|
|
|
const commentXpath = `//span[contains(text(), "${studioComment}")]/../..`;
|
|
|
|
await clickXpath(`${commentXpath}//span[@class = "comment-reply"]`);
|
2021-10-29 16:18:18 -04:00
|
|
|
|
|
|
|
// type reply
|
2023-10-24 14:22:28 -04:00
|
|
|
const replyRow = '//div[contains(@class, "comment-reply-row")]';
|
|
|
|
const replyComposeXpath = `${replyRow}//textArea[@class = "inplace-textarea"]`;
|
|
|
|
const composeBox = await findByXpath(replyComposeXpath);
|
2021-10-29 16:18:18 -04:00
|
|
|
await composeBox.sendKeys(studioReply);
|
|
|
|
|
|
|
|
// click post
|
2023-10-24 14:22:28 -04:00
|
|
|
const postButton = await findByXpath(`${replyRow}//button[@class = "button compose-post"]`);
|
2021-10-29 16:18:18 -04:00
|
|
|
await postButton.click();
|
|
|
|
|
2021-12-02 16:26:23 -05:00
|
|
|
// find reply
|
2023-10-24 14:22:28 -04:00
|
|
|
const postedReply = await findByXpath(`//span[contains(text(), "${studioReply}")]`);
|
|
|
|
const commentVisible = await postedReply.isDisplayed();
|
|
|
|
expect(commentVisible).toBe(true);
|
2021-10-29 16:18:18 -04:00
|
|
|
});
|
2021-10-20 10:11:33 -04:00
|
|
|
});
|
2021-09-17 14:40:11 -04:00
|
|
|
});
|