Commit b00a2d34 authored by Eric Rosenbaum's avatar Eric Rosenbaum

Merge branch 'develop' of https://github.com/LLK/scratch-www into transfer-modal3

parents 5fd180b5 d23e4d6c
This diff is collapsed.
......@@ -131,6 +131,8 @@
"studio.activityBecomeCurator": "{newCuratorProfileLink} accepted an invitation from {inviterProfileLink} to curate this studio",
"studio.activityRemoveCurator": "{removerProfileLink} removed the curator {removedProfileLink}",
"studio.activityBecomeOwner": "{promotedProfileLink} was promoted to manager by {promotorProfileLink}",
"studio.activityBecomeHost": "{newHostProfileLink} was made the studio host by {actorProfileLink}",
"studio.activityBecomeHostAdminActor": "{newHostProfileLink} was made the studio host by a Scratch Team member",
"studio.lastUpdated": "Updated {lastUpdatedDate, date, medium}",
"studio.followerCount": "{followerCount} followers",
......
......@@ -61,6 +61,7 @@
overflow-wrap: break-word;
height: 90px;
padding: 0.5rem;
white-space: pre-wrap;
}
.studio-report-title-text {
......
......@@ -166,6 +166,44 @@ const getComponentForItem = item => {
/>
</SocialMessage>
);
case 'becomehoststudio':
return (
<SocialMessage
datetime={item.datetime_created}
iconSrc="/svgs/studio/activity-curator.svg"
iconAlt="curator activity icon"
imgClassName="studio-activity-icon"
key={item.id}
>
{item.admin_actor ?
<FormattedMessage
id="studio.activityBecomeHostAdminActor"
values={{
newHostProfileLink: (
<a href={`/users/${item.recipient_username}`}>
{item.recipient_username}
</a>
)
}}
/> :
<FormattedMessage
id="studio.activityBecomeHost"
values={{
newHostProfileLink: (
<a href={`/users/${item.recipient_username}`}>
{item.recipient_username}
</a>
),
actorProfileLink: (
<a href={`/users/${item.recipient_username}`}>
{item.actor_username}
</a>
)
}}
/>
}
</SocialMessage>
);
}
};
......
// these tests do not sign in as a user
const SeleniumHelper = require('./selenium-helpers.js');
const {
......
// these tests do not sign in as a user
const SeleniumHelper = require('./selenium-helpers.js');
const {
......
// these tests do not sign in as a user
const SeleniumHelper = require('./selenium-helpers.js');
const {
......
// These tests sign in as user #1
const SeleniumHelper = require('./selenium-helpers.js');
const {
......@@ -89,23 +91,53 @@ describe('www-integration my_stuff', () => {
await expect(dropDownVisible).toBe(true);
});
test('+ New Project button should open the editor', async () =>{
await driver.get(myStuffURL);
await clickText('+ New Project');
let gf = await findByXpath('//img[@class="green-flag_green-flag_1kiAo"]');
let gfVisible = await gf.isDisplayed();
await expect(gfVisible).toBe(true);
});
test('+ New Studio button should take you to the studio page', async ()=>{
await driver.get(rateLimitCheck);
await driver.get(myStuffURL);
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
await driver.sleep(500);
// my stuff also has an element with the id tabs
let tabs = await findByXpath('//div[@class="studio-tabs"]');
let tabsVisible = await tabs.isDisplayed();
expect(tabsVisible).toBe(true);
});
test('+ New Project button should open the editor', async () =>{
test('New studio rate limited to five', async () =>{
await driver.get(rateLimitCheck);
// 1st studio
await driver.get(myStuffURL);
await clickText('+ New Project');
let gf = await findByXpath('//img[@class="green-flag_green-flag_1kiAo"]');
let gfVisible = await gf.isDisplayed();
await expect(gfVisible).toBe(true);
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
await findByXpath('//div[@class="studio-tabs"]');
// 2nd studio
await driver.get(myStuffURL);
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
await findByXpath('//div[@class="studio-tabs"]');
// 3rd studio
await driver.get(myStuffURL);
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
await findByXpath('//div[@class="studio-tabs"]');
// 4th studio
await driver.get(myStuffURL);
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
await findByXpath('//div[@class="studio-tabs"]');
// 5th studio
await driver.get(myStuffURL);
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
await findByXpath('//div[@class="studio-tabs"]');
// 6th studio should fail
await driver.get(myStuffURL);
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
let alertMessage = await findByXpath('//div[contains(@class, "alert-error")]');
let errVisible = await alertMessage.isDisplayed();
await expect(errVisible).toBe(true);
await driver.get(rateLimitCheck);
});
});
// These tests do not sign in as a user
const SeleniumHelper = require('./selenium-helpers.js');
const {
......
// These tests do not sign in with a user
const SeleniumHelper = require('./selenium-helpers.js');
const {
......@@ -35,7 +37,7 @@ describe('www-integration project-page signed out', () => {
afterAll(async () => await driver.quit());
// LOGGED OUT TESTS
test('Find fullscreen button', async () => {
await clickXpath('//div[starts-with(@class, "stage_green-flag-overlay")]');
await clickXpath('//img[contains(@alt, "Enter full screen mode")]');
......
......@@ -29,6 +29,7 @@ class SeleniumHelper {
'getDriver',
'getLogs',
'getSauceDriver',
'signIn',
'urlMatches',
'waitUntilGone'
]);
......@@ -148,6 +149,18 @@ class SeleniumHelper {
});
}
// must be used on a www page
async signIn (username, password, driver) {
await this.clickXpath('//li[@class="link right login-item"]/a');
let name = await this.findByXpath('//input[@id="frc-username-1088"]');
await name.sendKeys(username);
let word = await this.findByXpath('//input[@id="frc-password-1088"]');
await word.sendKeys(password);
await driver.sleep(500);
await this.clickXpath('//button[contains(@class, "button") and ' +
'contains(@class, "submit-button") and contains(@class, "white")]');
}
urlMatches (regex) {
return this.driver.wait(until.urlMatches(regex), 1000 * 5);
}
......
// These tests sign in with user #0 (no number for the username)
const SeleniumHelper = require('./selenium-helpers.js');
const {
......
// These tests sign in with user #2 and user #3
import SeleniumHelper from './selenium-helpers.js';
const {
findByXpath,
buildDriver
buildDriver,
clickXpath,
clickText,
signIn
} = new SeleniumHelper();
let remote = process.env.SMOKE_REMOTE || false;
let rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
let studioId = process.env.TEST_STUDIO_ID || 10004360;
let studioUrl = rootUrl + '/studios/' + studioId;
let myStuffURL = rootUrl + '/mystuff';
let rateLimitCheck = process.env.RATE_LIMIT_CHECK || rootUrl;
// 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.
let username2 = process.env.SMOKE_USERNAME + '2';
let username3 = process.env.SMOKE_USERNAME + '3';
let password = process.env.SMOKE_PASSWORD;
let promoteStudioURL;
let curatorTab;
if (remote){
jest.setTimeout(60000);
jest.setTimeout(70000);
} else {
jest.setTimeout(20000);
}
......@@ -52,5 +68,83 @@ describe('studio page while signed out', () => {
let descriptionText = await studioDescription.getText();
await expect(descriptionText).toEqual('a description');
});
});
describe('studio management', () => {
// These tests all start on the curators tab of a studio and signed out
beforeAll(async () => {
driver = await buildDriver('www-integration studio management');
await driver.get(rootUrl);
// create a studio for tests
await signIn(username2, password, driver);
await findByXpath('//span[contains(@class, "profile-name")]');
await driver.get(rateLimitCheck);
await driver.get(myStuffURL);
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
await findByXpath('//div[@class="studio-tabs"]');
promoteStudioURL = await driver.getCurrentUrl();
curatorTab = promoteStudioURL + 'curators';
});
beforeEach(async () => {
await clickXpath('//a[contains(@class, "user-info")]');
await clickText('Sign out');
await driver.get(curatorTab);
await findByXpath('//div[@class="studio-tabs"]');
});
afterAll(async () => await driver.quit());
test('invite a curator', async () => {
// sign in as user2
await signIn(username2, password, driver);
await findByXpath('//span[contains(@class, "profile-name")]');
// invite user3 to curate
let inviteBox = await findByXpath('//div[@class="studio-adder-row"]/input');
await inviteBox.sendKeys(username3);
await clickXpath('//div[@class="studio-adder-row"]/button');
let inviteAlert = await findByXpath('//div[@class="alert-msg"]'); // the confirm alert
let alertText = await inviteAlert.getText();
let successText = `Curator invite sent to "${username3}"`;
await expect(alertText).toMatch(successText);
});
test('accept curator invite', async () => {
// Sign in user3
await signIn(username3, password, driver);
await findByXpath('//span[contains(@class, "profile-name")]');
// accept the curator invite
await clickXpath('//button[@class="studio-invitation-button button"]');
let acceptSuccess = await findByXpath('//div[contains(@class,"studio-info-box-success")]');
let acceptSuccessVisible = await acceptSuccess.isDisplayed();
await expect(acceptSuccessVisible).toBe(true);
});
test('promote to manager', async () => {
// sign in as user2
await signIn(username2, password, driver);
await findByXpath('//span[contains(@class, "profile-name")]');
// for some reason the user isn't showing up without reloading the page
await driver.get(curatorTab);
// promote user3
let user3href = '/users/' + username3;
// click kebab menu on the user tile
let kebabMenuXpath = `//a[@href = "${user3href}"]/` +
'following-sibling::div[@class="overflow-menu-container"]';
await clickXpath(kebabMenuXpath + '/button[@class="overflow-menu-trigger"]');
// click promote
// await clickXpath('//button[@class="promote-menu-button"]'); //<-- I think this will do it
await clickXpath(kebabMenuXpath + '/ul/li/button/span[contains(text(), "Promote")]/..');
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")]/..');
let promoteSuccess = await findByXpath('//div[contains(@class, "alert-success")]');
let promoteSuccessVisible = await promoteSuccess.isDisplayed();
await expect(promoteSuccessVisible).toBe(true);
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment