mirror of
https://github.com/wassname/talk.git
synced 2026-07-19 11:28:50 +08:00
Refactor 2
This commit is contained in:
+127
-21
@@ -7,33 +7,139 @@ module.exports = {
|
||||
return this
|
||||
.waitForElementVisible('body');
|
||||
},
|
||||
login(user) {
|
||||
openDrawer() {
|
||||
this
|
||||
.waitForElementVisible('@loginLayout')
|
||||
.waitForElementVisible('@signInForm')
|
||||
.setValue('@emailInput', user.email)
|
||||
.setValue('@passwordInput', user.password)
|
||||
.waitForElementVisible('@signInButton')
|
||||
.click('@signInButton')
|
||||
.waitForElementVisible('@moderationContainer');
|
||||
.waitForElementVisible('@drawerButton')
|
||||
.click('@drawerButton');
|
||||
this.expect.section('@drawer').to.be.present;
|
||||
return this.section.drawer;
|
||||
},
|
||||
goToStories() {
|
||||
this
|
||||
.click('@storiesNav')
|
||||
.expect.section('@stories').to.be.present;
|
||||
return this.section.stories;
|
||||
},
|
||||
goToCommunity() {
|
||||
this
|
||||
.click('@communityNav')
|
||||
.expect.section('@community').to.be.present;
|
||||
return this.section.community;
|
||||
},
|
||||
logout() {
|
||||
this
|
||||
.waitForElementVisible('@settingsButton')
|
||||
.click('@settingsButton')
|
||||
.waitForElementVisible('@signOutButton')
|
||||
.click('@signOutButton');
|
||||
},
|
||||
}],
|
||||
elements: {
|
||||
'loginLayout': '.talk-admin-login',
|
||||
'signInForm': '.talk-admin-login-sign-in',
|
||||
'emailInput': '.talk-admin-login-sign-in #email',
|
||||
'passwordInput': '.talk-admin-login-sign-in #password',
|
||||
'signInButton': '.talk-admin-login-sign-in-button',
|
||||
'storiesNav': '.talk-admin-nav-stories',
|
||||
'storiesDrawerNav': '.talk-admin-drawer-nav .talk-admin-nav-stories',
|
||||
'storiesSection': '.talk-admin-stories',
|
||||
'communityNav': '.talk-admin-nav-community',
|
||||
'communityDrawerNav': '.talk-admin-drawer-nav .talk-admin-nav-community',
|
||||
'communitySection': '.talk-admin-community',
|
||||
'moderationContainer': '.talk-admin-moderation-container',
|
||||
'drawerButton': '.mdl-layout__drawer-button',
|
||||
'drawerOverlay': 'div.mdl-layout__obfuscator.is-visible',
|
||||
'storiesNav': '.talk-admin-nav-stories',
|
||||
'communityNav': '.talk-admin-nav-community',
|
||||
'settingsButton': '.talk-admin-header-settings-button',
|
||||
'signOutButton': '.talk-admin-header-sign-out',
|
||||
}
|
||||
},
|
||||
sections: {
|
||||
moderate: {
|
||||
selector: '.talk-admin-moderation-container',
|
||||
},
|
||||
stories: {
|
||||
selector: '.talk-admin-stories',
|
||||
},
|
||||
community: {
|
||||
selector: '.talk-admin-community',
|
||||
commands: [{
|
||||
url: function() {
|
||||
return `${this.api.launchUrl}/admin/community`;
|
||||
},
|
||||
ready() {
|
||||
return this
|
||||
.waitForElementVisible('body');
|
||||
},
|
||||
goToPeople() {
|
||||
this
|
||||
.click('@peopleNav')
|
||||
.expect.section('@people').to.be.present;
|
||||
return this.section.people;
|
||||
},
|
||||
}],
|
||||
elements: {
|
||||
peopleNav: '.talk-admin-nav-people',
|
||||
flaggedAccountsNav: '.talk-admin-nav-flagged-accounts',
|
||||
flaggedAccountsContainer: '.talk-adnin-community-flagged-accounts',
|
||||
flaggedUser:'.talk-admin-community-flagged-user',
|
||||
flaggedUserApproveButton: '.talk-admin-flagged-user-approve-button',
|
||||
flaggedUserRejectButton: '.talk-admin-flagged-user-reject-button',
|
||||
usernameDialog: '.talk-reject-username-dialog',
|
||||
usernameDialogButtons: '.talk-reject-username-dialog-buttons',
|
||||
usernameDialogSuspend: '.talk-reject-username-dialog-button-k',
|
||||
usernameDialogSuspensionMessage: '.talk-reject-username-dialog-suspension-message'
|
||||
},
|
||||
sections: {
|
||||
people: {
|
||||
selector: '.talk-admin-community-people-container',
|
||||
elements: {
|
||||
firstRow: '.talk-admin-community-people-row:first-child',
|
||||
dropdownStatus: '.talk-admin-community-people-dd-status',
|
||||
dropdownRole: '.talk-admin-community-people-dd-role',
|
||||
dropdownStatusActive: '.talk-admin-community-people-dd-status .dd-list-active',
|
||||
optionActive: '.dd-option#ACTIVE',
|
||||
optionBanned: '.dd-option#BANNED',
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
drawer: {
|
||||
selector: '.talk-admin-drawer-nav',
|
||||
commands: [{
|
||||
goToStories() {
|
||||
this
|
||||
.click('@storiesButton');
|
||||
this.parent.expect.section('@stories').to.be.present;
|
||||
this.close();
|
||||
return this.parent.section.stories;
|
||||
},
|
||||
goToCommunity() {
|
||||
this
|
||||
.click('@communityButton');
|
||||
this.parent.expect.section('@community').to.be.present;
|
||||
this.close();
|
||||
return this.parent.section.stories;
|
||||
},
|
||||
close() {
|
||||
this.parent
|
||||
.click('@drawerOverlay');
|
||||
},
|
||||
}],
|
||||
elements: {
|
||||
'storiesButton': '.talk-admin-drawer-nav .talk-admin-nav-stories',
|
||||
'communityButton': '.talk-admin-drawer-nav .talk-admin-nav-community',
|
||||
},
|
||||
},
|
||||
login: {
|
||||
commands: [{
|
||||
login(user) {
|
||||
this
|
||||
.waitForElementVisible('@signInForm')
|
||||
.setValue('@emailInput', user.email)
|
||||
.setValue('@passwordInput', user.password)
|
||||
.waitForElementVisible('@signInButton')
|
||||
.click('@signInButton');
|
||||
const adminPage = this.api.page.admin();
|
||||
adminPage.expect.section('@moderate').to.be.present;
|
||||
return adminPage.section.moderate;
|
||||
},
|
||||
}],
|
||||
selector: '.talk-admin-login',
|
||||
elements: {
|
||||
'signInForm': '.talk-admin-login-sign-in',
|
||||
'emailInput': '.talk-admin-login-sign-in #email',
|
||||
'passwordInput': '.talk-admin-login-sign-in #password',
|
||||
'signInButton': '.talk-admin-login-sign-in-button',
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
module.exports = {
|
||||
commands: [{
|
||||
url: function() {
|
||||
return `${this.api.launchUrl}/admin/community`;
|
||||
},
|
||||
ready() {
|
||||
return this
|
||||
.waitForElementVisible('body');
|
||||
},
|
||||
goToPeople() {
|
||||
this
|
||||
.navigate(`${this.url()}/people`);
|
||||
},
|
||||
}],
|
||||
elements: {
|
||||
container: '.talk-admin-community',
|
||||
flaggedAccountsContainer: '.talk-adnin-community-flagged-accounts',
|
||||
flaggedUser:'.talk-admin-community-flagged-user',
|
||||
flaggedUserApproveButton: '.talk-admin-flagged-user-approve-button',
|
||||
flaggedUserRejectButton: '.talk-admin-flagged-user-reject-button',
|
||||
usernameDialog: '.talk-reject-username-dialog',
|
||||
usernameDialogButtons: '.talk-reject-username-dialog-buttons',
|
||||
usernameDialogSuspend: '.talk-reject-username-dialog-button-k',
|
||||
usernameDialogSuspensionMessage: '.talk-reject-username-dialog-suspension-message'
|
||||
},
|
||||
sections: {
|
||||
people: {
|
||||
selector: '.talk-admin-community-people-container',
|
||||
elements: {
|
||||
firstRow: '.talk-admin-community-people-row:first-child',
|
||||
dropdownStatus: '.talk-admin-community-people-dd-status',
|
||||
dropdownRole: '.talk-admin-community-people-dd-role',
|
||||
dropdownStatusActive: '.talk-admin-community-people-dd-status .dd-list-active',
|
||||
optionActive: '.dd-option#ACTIVE',
|
||||
optionBanned: '.dd-option#BANNED',
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -64,8 +64,8 @@ module.exports = {
|
||||
this.api.switchWindow(handles[1]);
|
||||
});
|
||||
|
||||
const login = this.api.page.login().ready();
|
||||
callback(login);
|
||||
const popup = this.api.page.popup().ready();
|
||||
callback(popup);
|
||||
|
||||
// Give a tiny bit of time to let popup close.
|
||||
this.api.pause(50);
|
||||
@@ -80,7 +80,7 @@ module.exports = {
|
||||
// Focusing on the Embed Window
|
||||
windowHandler.windowHandles((handles) => {
|
||||
this.api.switchWindow(handles[0]);
|
||||
this.api.page.embedStream().switchToIframe();
|
||||
this.parent.switchToIframe();
|
||||
});
|
||||
},
|
||||
logout() {
|
||||
|
||||
Reference in New Issue
Block a user