2021-08-18 10:03:06 -04:00
|
|
|
// These tests sign in with user #2 and user #3
|
|
|
|
|
2021-06-25 17:33:46 -04:00
|
|
|
import SeleniumHelper from './selenium-helpers.js';
|
|
|
|
|
|
|
|
const {
|
2021-08-18 10:03:06 -04:00
|
|
|
buildDriver,
|
2021-08-18 10:22:16 -04:00
|
|
|
clickText,
|
2023-09-22 21:30:31 -04:00
|
|
|
clickXpath,
|
|
|
|
findByXpath,
|
2023-09-20 17:18:21 -04:00
|
|
|
isSignedIn,
|
2023-09-22 21:30:31 -04:00
|
|
|
navigate,
|
2021-08-18 10:22:16 -04:00
|
|
|
signIn
|
2021-06-25 17:33:46 -04:00
|
|
|
} = new SeleniumHelper();
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
const rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
|
|
|
const studioId = process.env.TEST_STUDIO_ID || 10004360;
|
|
|
|
const studioUrl = `${rootUrl}/studios/${studioId}`;
|
|
|
|
const myStuffURL = `${rootUrl}/mystuff`;
|
|
|
|
const rateLimitCheck = process.env.RATE_LIMIT_CHECK || rootUrl;
|
2021-08-18 10:03:06 -04:00
|
|
|
|
|
|
|
// since the usernames end in 2 and 3 we're using username2 and username3
|
|
|
|
// username 1 is used in other tests. Hopefully this is not confusing.
|
2023-10-24 14:22:28 -04:00
|
|
|
const username2 = `${process.env.SMOKE_USERNAME}2`;
|
|
|
|
const username3 = `${process.env.SMOKE_USERNAME}3`;
|
|
|
|
const password = process.env.SMOKE_PASSWORD;
|
2021-08-18 10:03:06 -04:00
|
|
|
|
|
|
|
let promoteStudioURL;
|
2021-08-18 10:53:42 -04:00
|
|
|
let curatorTab;
|
2021-06-25 17:33:46 -04:00
|
|
|
|
2021-12-03 09:14:25 -05:00
|
|
|
jest.setTimeout(70000);
|
2021-06-25 17:33:46 -04:00
|
|
|
|
|
|
|
let driver;
|
|
|
|
|
|
|
|
describe('studio page while signed out', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
// expect(projectUrl).toBe(defined);
|
|
|
|
driver = await buildDriver('www-integration studio-page signed out');
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
2023-09-22 21:30:31 -04:00
|
|
|
await navigate(studioUrl);
|
2023-10-24 14:22:28 -04:00
|
|
|
const studioNav = await findByXpath('//div[@class="studio-tabs"]');
|
2021-06-25 17:33:46 -04:00
|
|
|
await studioNav.isDisplayed();
|
|
|
|
});
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
afterAll(() => driver.quit());
|
2021-06-25 17:33:46 -04:00
|
|
|
|
|
|
|
test('land on projects tab', async () => {
|
2023-09-22 21:30:31 -04:00
|
|
|
await navigate(studioUrl);
|
2023-10-24 14:22:28 -04:00
|
|
|
const projectGrid = await findByXpath('//div[@class="studio-projects-grid"]');
|
|
|
|
const projectGridDisplayed = await projectGrid.isDisplayed();
|
|
|
|
expect(projectGridDisplayed).toBe(true);
|
2021-06-25 17:33:46 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('studio title', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const studioTitle = await findByXpath('//div[@class="studio-title"]');
|
|
|
|
const titleText = await studioTitle.getText();
|
|
|
|
expect(titleText).toEqual('studio for automated testing');
|
2021-06-25 17:33:46 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('studio description', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const xpath = '//div[contains(@class, "studio-description")]';
|
|
|
|
const studioDescription = await findByXpath(xpath);
|
|
|
|
const descriptionText = await studioDescription.getText();
|
|
|
|
expect(descriptionText).toEqual('a description');
|
2021-06-25 17:33:46 -04:00
|
|
|
});
|
2021-08-18 10:03:06 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('studio management', () => {
|
2021-08-18 12:04:48 -04:00
|
|
|
// These tests all start on the curators tab of a studio and signed out
|
2021-08-18 14:03:48 -04:00
|
|
|
|
2021-08-18 10:03:06 -04:00
|
|
|
beforeAll(async () => {
|
2021-08-18 10:53:42 -04:00
|
|
|
driver = await buildDriver('www-integration studio management');
|
2023-09-22 21:30:31 -04:00
|
|
|
await navigate(rootUrl);
|
2021-08-18 10:03:06 -04:00
|
|
|
|
|
|
|
// create a studio for tests
|
2021-11-19 09:38:23 -05:00
|
|
|
await signIn(username2, password);
|
2021-08-18 10:53:42 -04:00
|
|
|
await findByXpath('//span[contains(@class, "profile-name")]');
|
2023-09-22 21:30:31 -04:00
|
|
|
await navigate(rateLimitCheck);
|
|
|
|
await navigate(myStuffURL);
|
2021-08-18 10:53:42 -04:00
|
|
|
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
|
|
|
|
await findByXpath('//div[@class="studio-tabs"]');
|
|
|
|
promoteStudioURL = await driver.getCurrentUrl();
|
2023-10-24 14:22:28 -04:00
|
|
|
curatorTab = `${promoteStudioURL}curators`;
|
2021-08-18 10:53:42 -04:00
|
|
|
});
|
2021-08-18 10:03:06 -04:00
|
|
|
|
2021-08-18 10:53:42 -04:00
|
|
|
beforeEach(async () => {
|
2023-09-20 17:18:21 -04:00
|
|
|
if (await isSignedIn()) {
|
|
|
|
await clickXpath('//a[contains(@class, "user-info")]');
|
|
|
|
await clickText('Sign out');
|
|
|
|
}
|
2021-08-18 10:03:06 -04:00
|
|
|
});
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
afterAll(() => driver.quit());
|
2021-06-25 17:33:46 -04:00
|
|
|
|
2021-08-18 12:04:48 -04:00
|
|
|
test('invite a curator', async () => {
|
2021-08-18 10:03:06 -04:00
|
|
|
// sign in as user2
|
2021-11-19 09:38:23 -05:00
|
|
|
await signIn(username2, password);
|
2023-09-22 21:30:31 -04:00
|
|
|
await navigate(curatorTab);
|
2021-08-18 10:03:06 -04:00
|
|
|
|
|
|
|
// invite user3 to curate
|
2023-10-24 14:22:28 -04:00
|
|
|
const inviteBox = await findByXpath('//div[@class="studio-adder-row"]/input');
|
2021-08-18 10:03:06 -04:00
|
|
|
await inviteBox.sendKeys(username3);
|
|
|
|
await clickXpath('//div[@class="studio-adder-row"]/button');
|
2023-10-24 14:22:28 -04:00
|
|
|
const inviteAlert = await findByXpath('//div[@class="alert-msg"]'); // the confirm alert
|
|
|
|
const alertText = await inviteAlert.getText();
|
|
|
|
const successText = `Curator invite sent to "${username3}"`;
|
|
|
|
expect(alertText).toMatch(successText);
|
2021-08-18 12:04:48 -04:00
|
|
|
});
|
2021-08-18 10:03:06 -04:00
|
|
|
|
2021-08-18 12:04:48 -04:00
|
|
|
test('accept curator invite', async () => {
|
2021-08-18 10:03:06 -04:00
|
|
|
// Sign in user3
|
2021-11-19 09:38:23 -05:00
|
|
|
await signIn(username3, password);
|
2023-09-22 21:30:31 -04:00
|
|
|
await navigate(curatorTab);
|
2021-08-18 10:03:06 -04:00
|
|
|
|
|
|
|
// accept the curator invite
|
|
|
|
await clickXpath('//button[@class="studio-invitation-button button"]');
|
2023-10-24 14:22:28 -04:00
|
|
|
const acceptSuccess = await findByXpath('//div[contains(@class,"studio-info-box-success")]');
|
|
|
|
const acceptSuccessVisible = await acceptSuccess.isDisplayed();
|
|
|
|
expect(acceptSuccessVisible).toBe(true);
|
2021-08-18 12:04:48 -04:00
|
|
|
});
|
2021-08-18 10:03:06 -04:00
|
|
|
|
2021-08-18 12:04:48 -04:00
|
|
|
test('promote to manager', async () => {
|
2021-08-18 10:03:06 -04:00
|
|
|
// sign in as user2
|
2021-11-19 09:38:23 -05:00
|
|
|
await signIn(username2, password);
|
2021-08-18 10:03:06 -04:00
|
|
|
await findByXpath('//span[contains(@class, "profile-name")]');
|
2021-11-19 09:52:41 -05:00
|
|
|
// for some reason the user isn't showing up without waiting and reloading the page
|
|
|
|
await driver.sleep(2000);
|
2023-09-22 21:30:31 -04:00
|
|
|
await navigate(curatorTab);
|
2021-08-18 10:03:06 -04:00
|
|
|
|
|
|
|
// promote user3
|
2023-10-24 14:22:28 -04:00
|
|
|
const user3href = `/users/${username3}`;
|
2021-08-18 10:03:06 -04:00
|
|
|
// click kebab menu on the user tile
|
2023-10-24 14:22:28 -04:00
|
|
|
const kebabMenuXpath = `//a[@href = "${user3href}"]/following-sibling::div[@class="overflow-menu-container"]`;
|
|
|
|
await clickXpath(`${kebabMenuXpath}/button[@class="overflow-menu-trigger"]`);
|
2021-08-18 10:03:06 -04:00
|
|
|
// click promote
|
|
|
|
// await clickXpath('//button[@class="promote-menu-button"]'); //<-- I think this will do it
|
2023-10-24 14:22:28 -04:00
|
|
|
await clickXpath(`${kebabMenuXpath}/ul/li/button/span[contains(text(), "Promote")]/..`);
|
2021-08-18 10:03:06 -04:00
|
|
|
await findByXpath('//div[@class="promote-content"]');
|
|
|
|
// await clickXpath(//button[contains(@class="promote-button")]) <-- add this selector to the button
|
|
|
|
await clickXpath('//div[@class="promote-button-row"]/button/span[contains(text(),"Promote")]/..');
|
2023-10-24 14:22:28 -04:00
|
|
|
const promoteSuccess = await findByXpath('//div[contains(@class, "alert-success")]');
|
|
|
|
const promoteSuccessVisible = await promoteSuccess.isDisplayed();
|
|
|
|
expect(promoteSuccessVisible).toBe(true);
|
2021-08-18 10:03:06 -04:00
|
|
|
});
|
2021-08-30 10:37:19 -04:00
|
|
|
|
|
|
|
test('transfer studio host', async () => {
|
|
|
|
// sign in as user2
|
2021-11-19 09:38:23 -05:00
|
|
|
await signIn(username2, password);
|
2021-08-30 10:37:19 -04:00
|
|
|
await findByXpath('//span[contains(@class, "profile-name")]');
|
|
|
|
// for some reason the user isn't showing up without reloading the page
|
2023-09-22 21:30:31 -04:00
|
|
|
await navigate(curatorTab);
|
2021-08-30 10:37:19 -04:00
|
|
|
|
|
|
|
// open kebab menu
|
2023-10-24 14:22:28 -04:00
|
|
|
const user2href = `/users/${username2}`;
|
2021-08-30 10:37:19 -04:00
|
|
|
// click kebab menu on the user tile
|
2023-10-24 14:22:28 -04:00
|
|
|
const kebabMenuXpath = `//a[@href = "${user2href}"]/following-sibling::div[@class="overflow-menu-container"]`;
|
|
|
|
await clickXpath(`${kebabMenuXpath}/button[@class="overflow-menu-trigger"]`);
|
2021-08-30 10:37:19 -04:00
|
|
|
|
|
|
|
// click transfer in dropdown
|
|
|
|
await clickXpath('//button[@class="studio-member-tile-menu-wide"]');
|
|
|
|
await findByXpath('//div[contains(@class, "transfer-info-title")]');
|
|
|
|
|
|
|
|
// click next button
|
|
|
|
await clickXpath('//button[contains(@class, "next-button")]');
|
|
|
|
await findByXpath('//div[@class="transfer-selection-heading"]');
|
|
|
|
|
|
|
|
// click user tile
|
|
|
|
await clickXpath(`//div[contains(text(), "${username3}")]`);
|
|
|
|
await findByXpath('//div[contains(@class, "transfer-host-name-selected")]');
|
|
|
|
|
|
|
|
// click next button
|
|
|
|
await clickXpath('//button[contains(@class, "next-button")]');
|
|
|
|
await findByXpath('//div[@class="transfer-outcome"]');
|
|
|
|
|
|
|
|
// enter password
|
2023-10-24 14:22:28 -04:00
|
|
|
const passwordInput = await findByXpath('//input[@class="transfer-password-input"]');
|
2021-08-30 10:37:19 -04:00
|
|
|
await passwordInput.sendKeys(password);
|
|
|
|
await findByXpath(`//input[@value="${password}"]`);
|
|
|
|
|
|
|
|
// click confirm
|
|
|
|
// await clickXpath('//button[contains(@class, "confirm-transfer-button")]')
|
|
|
|
await clickXpath('//span[contains(text(), "Confirm")]/..');
|
2023-10-27 12:08:45 -04:00
|
|
|
// findByXpath checks for both presence and visibility
|
2023-10-24 14:22:28 -04:00
|
|
|
const transferSuccess = await findByXpath('//div[contains(@class, "alert-success")]');
|
2023-10-27 12:08:45 -04:00
|
|
|
expect(transferSuccess).toBeTruthy();
|
2021-08-30 10:37:19 -04:00
|
|
|
});
|
2021-06-25 17:33:46 -04:00
|
|
|
});
|