Commit 704fd2df authored by YuShijiaCode's avatar YuShijiaCode

update login user

parent 9e2128c3
......@@ -121,6 +121,26 @@ class MerchantPlanPage {
}
selectAddOn = async function (driver, name){
console.log("select addon name: " , name);
await baseStep.scrollIntoView(driver, this.add_ons);
await baseStep.click(driver, this.add_ons);
await baseStep.click(driver, "//*[contains(text(),'"+name+"')]");
await baseStep.wait(driver, 1000);
await baseStep.click(driver, this.Custom_data_label);
await baseStep.wait(driver, 1000);
}
selectOneTimePayment = async function (driver, name){
console.log("select addon name: " , name);
await baseStep.scrollIntoView(driver, this.onetimeAddonIds);
await baseStep.click(driver, this.onetimeAddonIds);
await baseStep.click(driver, "//*[contains(text(),'"+name+"')]");
await baseStep.wait(driver, 1000);
await baseStep.click(driver, this.Custom_data_label);
await baseStep.wait(driver, 1000);
}
}
module.exports = new MerchantPlanPage();
const baseStep = require("../../CommonStep/Web/Web_Common_Step");
const webdriver = require('selenium-webdriver');
const By = webdriver.By;
const Key = webdriver.Key;
const {expect} = require("chai");
class MerchantSubscriptionPage {
......@@ -31,7 +32,16 @@ class MerchantSubscriptionPage {
sub_payment_gateway = '//*[text()="Payment Gateway"]/following-sibling::div[1]'
end_subscription = '//*[text()="End Subscription"]'
end_immediately = '//*[text()="immediately"]'
end_OK_btn = '(//*[@type = "button"]/span[text()="OK"])[2]'
end_OK_btn = '//*[@type = "button"]/span[text()="OK"]'
change_sub_btn = '//*[text()="Change Plan"]'
plan_selector = '//input[@type="search"]/../..'
change_OK_btn = '//*[@type = "button"]/span[text()="OK"]'
change_confirm = '//span[text()="Confirm"]'
due_date = '(//*[@placeholder="Select date"])[2]'
due_date_OK_btn = '//*[@type = "button"]/span[text()="OK"]'
change_due_date_info = '//*[@class="ant-picker-input"]/../following-sibling::span'
checkRecordSubList = async function(driver, planName="", description="", amount="", status="", user= "", record = 1){
......@@ -66,10 +76,25 @@ class MerchantSubscriptionPage {
selectSubByPlanName = async function(driver, planName){
console.log("select sub by plan name: ", planName);
await baseStep.click(driver, "(//span[text()="+planName+"])[1]");
await baseStep.click(driver, "(//span[text()='"+planName+"'])[1]");
await baseStep.wait(driver, 1000);
}
selectTargetPlan = async function (driver, Plan){
console.log("select Plan name: " , Plan);
await baseStep.click(driver, this.plan_selector);
await baseStep.click(driver, "//*[contains(text(),'"+Plan+"')]");
await baseStep.wait(driver, 1000);
}
setDueDate = async function (driver, days){
console.log("set " + days + " days later");
let current = new Date(new Date().setMonth(new Date().getMonth()+1));
let expect = baseStep.getDateFormat(new Date(new Date(current).setDate(new Date(current).getDate()+days)), "YYYY-MMM-DD");
await baseStep.inputWithClear(driver, this.due_date, expect);
await driver.findElement(By.xpath(this.due_date)).sendKeys(Key.ENTER);
}
}
module.exports = new MerchantSubscriptionPage();
\ No newline at end of file
......@@ -10,7 +10,7 @@ class MerchantUserListPage {
filter_email = '//*[@id="email"]'
clear_btn = '//*[text()="Clear"]'
search_btn = '//*[text()="Search"]'
add_new_btn = '//*[text()="Add New"]'
add_new_btn = '//*[@aria-label="user-add"]'
info_first_name = '//*[text()="First Name"]/../following-sibling::div[1]'
info_last_name = '//*[text()="Last Name"]/../following-sibling::div[1]'
info_email = '//*[text()="Email"]/../following-sibling::div[1]/a'
......@@ -20,35 +20,61 @@ class MerchantUserListPage {
info_payment_method = '//*[text()="Payment Method"]/../following-sibling::div[1]'
info_vat_number = '//*[text()="VAT Number"]/../following-sibling::div[1]'
account_tab = '//*[@data-node-key="AccountInfo"]'
subscription_tab = '//*[@data-node-key="Subscription"]'
subscription_tab = '//*[@id="rc-tabs-0-tab-subscription"]'
invoice_tab = '//*[@data-node-key="Invoice"]'
transaction_tab = '//*[@data-node-key="Transaction"]'
new_email = '(//*[@id="email"])[2]'
new_ex_user_id = '//*[@id="externalUserId"]'
new_first_name = '(//*[@id="firstName"])[2]'
new_last_name = '(//*[@id="lastName"])[2]'
new_phone = '//*[@id="phone"]'
new_address = '//*[@id = "address"]'
new_OK_btn = '//*[text()="OK"]'
suspend_btn = '//*[text()="Suspend"]'
suspend_confirm_btn = '(//*[text()=\'Suspend\'])[2]'
assign_sub_btn = '//*[text()="Assign Subscription"]'
plan_selector = '(//input[@type="search"]/../..)[2]'
assign_OK_btn = '//*[text()="OK"]'
current_text = '(//*[@class="ant-divider-inner-text"])[6]'
current_plan = "(//*[text()='Plan'])[2]/following-sibling::div[1]"
current_plan_des = "(//*[text()='Plan Description'])[1]/following-sibling::div[1]"
current_status= "(//*[text()='Status'])[3]//following-sibling::div[1]/span"
checkRecordUserList = async function(driver, firstName="", lastName="", email="", status="",record = 1){
await baseStep.waitUntilElement(driver, "//*[@class='ant-table-cell' and text()='First Name']", 20000);
await baseStep.wait(driver,10000);
checkRecordUserList = async function(driver, name = "", email="", status="",record = 1){
await baseStep.waitUntilElement(driver, "//*[@class='ant-table-cell' and text()='Email']", 20000);
await baseStep.wait(driver,5000);
let table = await driver.findElement(By.xpath("//*[@class='ant-table-tbody']"));
let rows = await table.findElements({ tagName: 'tr' })
console.log("rows.length: ",rows.length)
let cells = await rows[record-1].findElements({ tagName: 'td' });
if (firstName !== ""){
expect(await cells[0].getText()).to.equal(firstName);
}
if (lastName!== ""){
expect(await cells[1].getText()).to.equal(lastName);
if (name !== ""){
expect(await cells[0].getText()).to.equal(name);
}
if (email !== ""){
expect(await cells[2].getText()).to.equal(email);
expect(await cells[1].getText()).to.equal(email);
}
if (status !== ""){
expect(await cells[7].getText()).to.equal(status);
expect(await cells[6].getText()).to.equal(status);
}
await baseStep.click(driver, '//*[@id="root"]/div/div/main/div/div/div[3]/div/div/div/div/div/table/tbody/tr[1]/td[1]');
await baseStep.wait(driver,1000);
}
selectTargetPlan = async function (driver, Plan){
console.log("select Plan name: " , Plan);
await baseStep.click(driver, this.plan_selector);
await baseStep.click(driver, "//*[contains(text(),'"+Plan+"')]");
await baseStep.wait(driver, 1000);
}
......
......@@ -94,7 +94,7 @@ describe('Cancel the subscription', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -119,7 +119,7 @@ describe('Cancel the subscription', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......
......@@ -137,6 +137,7 @@ describe('Login failed with wrong password in Merchant Portal=> Success', functi
await baseStep.input(Driver,loginPage.password, '123123');
await baseStep.click(Driver, loginPage.submitBtn);
await baseStep.wait(Driver, 2000);
await baseStep.screenShot(Driver,savaPath + '/03_Wrong_password.jpeg');
expect("Login Failed, Password Not Match").to.equal(await baseStep.getText(Driver,loginPage.error_message));
await baseStep.wait(Driver, 2000);
done();
......@@ -206,6 +207,7 @@ describe('Login failed with wrong email in Merchant Portal=> Success', function(
await baseStep.wait(Driver, 2000);
await baseStep.input(Driver,loginPage.password, '123123');
await baseStep.click(Driver, loginPage.submitBtn);
await baseStep.screenShot(Driver,savaPath + '/04_Wrong_Email.jpeg');
await baseStep.wait(Driver, 2000);
expect("Email Not Found").to.equal(await baseStep.getText(Driver,loginPage.error_message));
await baseStep.wait(Driver, 2000);
......@@ -277,6 +279,7 @@ describe('Login failed with empty email and password in Merchant Portal=> Succes
await baseStep.input(Driver,loginPage.password, '');
await baseStep.click(Driver, loginPage.submitBtn);
await baseStep.wait(Driver, 2000);
await baseStep.screenShot(Driver,savaPath + '/05_empty_Email.jpeg');
expect("Please input your Email!").to.equal(await baseStep.getText(Driver,loginPage.email_empty_error));
expect("Please input valid email address.").to.equal(await baseStep.getText(Driver,loginPage.email_invalid_error));
expect("Please input your password!").to.equal(await baseStep.getText(Driver,loginPage.password_empty_error));
......
......@@ -477,7 +477,7 @@ describe('case05: create a new plan in Merchant Portal, Allow Trial = True bill
});
describe('case05: create a add on in Merchant Portal, => Success', function() {
describe('case06: create a add on in Merchant Portal, => Success', function() {
this.timeout(100000);
beforeEach(function () {
......@@ -563,7 +563,7 @@ describe('case05: create a add on in Merchant Portal, => Success', function() {
});
describe('case06: create a one time payment on in Merchant Portal, => Success', function() {
describe('case07: create a one time payment on in Merchant Portal, => Success', function() {
this.timeout(100000);
beforeEach(function () {
......@@ -650,6 +650,99 @@ describe('case06: create a one time payment on in Merchant Portal, => Success',
});
describe('case08: create a new plan in Merchant Portal, associated with add-on and one time payment=> Success', function() {
this.timeout(100000);
beforeEach(function () {
response = null;
addContext(this, {
title: 'StartTime',
value: {
StartTime: timeStamp = new Date()
}
});
});
afterEach(function () {
if (response) {
addContext(this, {
title: 'Request',
value: {
Request: request
}
});
addContext(this, {
title: 'Response',
value: {
Response: response
}
});
addContext(this, {
title: 'EndTime',
value: {
EndTime: timeStamp = new Date()
}
});
}
});
it('TC001 - create a new plan, associated with add-on and one time payment => Success ', (done) => {
(async () => {
try {
// login
Driver = driver.getDriver(webdriver, 'chrome');
// Check Url
await loginPage.openMerchantUrl(Driver);
const currentUrl = await Driver.getCurrentUrl();
console.log('当前网址:', currentUrl);
await loginPage.loginMerchant(Driver)
await baseStep.wait(Driver, 1000);
await baseStep.screenShot(Driver,savaPath + '/01_Menu.jpeg');
await baseStep.waitUntilElement(Driver, planPage.menu_plan);
await baseStep.click(Driver, planPage.menu_plan);
await baseStep.wait(Driver, 1000);
await baseStep.click(Driver, planPage.new_plan_btn);
await baseStep.input(Driver, planPage.plan_name, "AutomationTest" + new Date().getTime() );
await baseStep.input(Driver, planPage.plan_description, "AutomationTest description");
await planPage.selectCurrency(Driver,"EUR")
await baseStep.wait(Driver, 1000); // aria-activedescendant
await baseStep.input(Driver, planPage.price, "20");
await planPage.inputIntervalCount(Driver, 2);
await baseStep.scrollIntoView(Driver, planPage.add_ons);
await baseStep.wait(Driver, 1000);
await planPage.selectAddOn(Driver, "addonforAuto");
await planPage.selectOneTimePayment(Driver, "oneTimeForAuto");
await baseStep.scrollIntoView(Driver, planPage.save_btn);
await baseStep.click(Driver, planPage.save_btn);
await baseStep.screenShot(Driver,savaPath + '/02_save.jpeg');
await baseStep.wait(Driver, 2000);
await baseStep.click(Driver, planPage.delete_btn);
await baseStep.screenShot(Driver,savaPath + '/03_delete.jpeg');
await baseStep.wait(Driver, 1000);
await baseStep.click(Driver, planPage.confirm_delete_btn);
await baseStep.wait(Driver, 1000);
done();
}
catch (e) {
done(e);
}finally {
await Driver.quit();
}
})();
});
it('Delay 5 seconds ', (done) => {
setTimeout(() => {// TODO Need wait about syncTimeAPI second after last operation
done();
}, 5000);
});
});
......
......@@ -12,7 +12,7 @@ const baseStep = require('../../../CommonStep/Web/Web_Common_Step');
const API_Object = require("../../../CommonStep/API/API_Object");
const API_Env = require("../../../CommonStep/API/API_Env");
const ApiReq = new API_Object("http://localhost:8088");
const ApiReq = new API_Object("http://api.unibee.top");
const addContext = require('mochawesome/addContext');
const {expect} = require("chai");
......@@ -94,7 +94,7 @@ describe('TS001: Invoice with Paid=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// // API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -119,7 +119,7 @@ describe('TS001: Invoice with Paid=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// // API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -325,7 +325,7 @@ describe('TS002: Invoice with Processing and paid (wire transfer)=> Success', fu
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -350,7 +350,7 @@ describe('TS002: Invoice with Processing and paid (wire transfer)=> Success', fu
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -559,7 +559,7 @@ describe('TS003: Invoice with cancelled=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -584,7 +584,7 @@ describe('TS003: Invoice with cancelled=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -782,7 +782,7 @@ describe('TS004: refund with stripe=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -807,7 +807,7 @@ describe('TS004: refund with stripe=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -1015,7 +1015,7 @@ describe('TS005: refund with wire transfer=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -1040,7 +1040,7 @@ describe('TS005: refund with wire transfer=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......
......@@ -12,7 +12,7 @@ const baseStep = require('../../../CommonStep/Web/Web_Common_Step');
const API_Object = require("../../../CommonStep/API/API_Object");
const API_Env = require("../../../CommonStep/API/API_Env");
const ApiReq = new API_Object("http://localhost:8088");
const ApiReq = new API_Object("http://api.unibee.top");
const addContext = require('mochawesome/addContext');
const {expect} = require("chai");
......@@ -95,7 +95,7 @@ describe('TS001: Transaction with Succeeded=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -120,7 +120,7 @@ describe('TS001: Transaction with Succeeded=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -190,7 +190,7 @@ describe('TS001: Transaction with Succeeded=> Success', function() {
await baseStep.click(Driver, userPlanPage.OK_btn);
await baseStep.wait(Driver,5000);
await baseStep.switchWindow(Driver);
await baseStep.waitUntilElement(Driver, userPlanPage.change_card_btn,200000);
await baseStep.waitUntilElement(Driver, userPlanPage.change_card_btn,2000);
await baseStep.click(Driver, userPlanPage.change_card_btn);
await baseStep.input(Driver,userPlanPage.card_number, '4242424242424242');
await baseStep.input(Driver,userPlanPage.card_expiry, '1234');
......@@ -317,7 +317,7 @@ describe('TS002: Transaction with Pending=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -342,7 +342,7 @@ describe('TS002: Transaction with Pending=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -534,7 +534,7 @@ describe('TS003: Transaction with Failed=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -559,7 +559,7 @@ describe('TS003: Transaction with Failed=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -753,7 +753,7 @@ describe('TS004: Transaction with refund => Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -778,7 +778,7 @@ describe('TS004: Transaction with refund => Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......
This diff is collapsed.
let loginPage = require("../../PageObject/LoginPage");
let userPlanPage = require("../../PageObject/UserPlanPage");
let userListPage = require("../../PageObject/MerchantUserListPage")
const urlencoded = require('urlencode');
const webdriver = require('selenium-webdriver');
const By = webdriver.By;
const driver = require('../../../CommonStep/Web/seleniumWebDriver');
const baseStep = require('../../../CommonStep/Web/Web_Common_Step');
const API_Object = require("../../../CommonStep/API/API_Object");
const API_Env = require("../../../CommonStep/API/API_Env");
const ApiReq = new API_Object("http://localhost:8088");
const addContext = require('mochawesome/addContext');
const {expect} = require("chai");
const {wait} = require("../../../CommonStep/Web/Web_Common_Step");
const merchantInvoicePage = require("../../PageObject/MerchantInvoicePage");
const discountCodePage = require("../../PageObject/MerchantDiscountCodePage");
let request;
let response;
let timeStamp = new Date();
let Driver;
let savaPath = __dirname + "/../../Report/Web/ScreenShot/09_user_list/" + baseStep.getDateFormat(new Date(),"YYYY-MM-DD_HH:mm:ss");
let testData = [];
let testUser = "[email protected]";
describe('TS001: add user in user list=> Success', function() {
this.timeout(9000000);
beforeEach(function () {
response = null;
addContext(this, {
title: 'StartTime',
value: {
StartTime: timeStamp = new Date()
}
});
});
afterEach(function () {
if (response) {
addContext(this, {
title: 'Request',
value: {
Request: request
}
});
addContext(this, {
title: 'Response',
value: {
Response: response
}
});
addContext(this, {
title: 'EndTime',
value: {
EndTime: timeStamp = new Date()
}
});
}
});
it('case 01 - add a new user => Success ', (done) => {
(async () => {
try {
// login
Driver = driver.getDriver(webdriver, 'chrome');
// Check Url
await loginPage.openMerchantUrl(Driver, "http://unibee:123456@localhost/plan/list/");
const currentUrl = await Driver.getCurrentUrl();
console.log('当前网址:', currentUrl);
await baseStep.waitUntilElement(Driver, loginPage.email,20000);
await loginPage.loginMerchant(Driver, "[email protected]", "changeme")
await baseStep.wait(Driver, 1000);
await baseStep.waitUntilElement(Driver, userListPage.menu_user_list);
await baseStep.click(Driver, userListPage.menu_user_list);
await baseStep.wait(Driver,2000);
await baseStep.click(Driver, userListPage.add_new_btn);
await baseStep.wait(Driver,2000);
let time = new Date().getTime();
await baseStep.input(Driver, userListPage.new_email, "Auto"+ time + "@test.com");
await baseStep.input(Driver, userListPage.new_ex_user_id, time);
await baseStep.input(Driver, userListPage.new_first_name, "Testing");
await baseStep.input(Driver, userListPage.new_last_name, "QA" + time);
await baseStep.input(Driver, userListPage.new_phone, "15642543250");
await baseStep.input(Driver, userListPage.new_address, "Test Address");
await baseStep.screenShot(Driver, savaPath + "/01_add_user");
await baseStep.click(Driver, userListPage.new_OK_btn);
await baseStep.wait(Driver,1000);
await baseStep.screenShot(Driver, savaPath + "/02_user_list");
await userListPage.checkRecordUserList(Driver, "Testing QA"+time, "Auto"+ time + "@test.com","Active");
await baseStep.scrollIntoView(Driver,userListPage.suspend_btn);
await baseStep.click(Driver, userListPage.suspend_btn);
await baseStep.screenShot(Driver, savaPath + "/03_suspend_user");
await baseStep.click(Driver, userListPage.suspend_confirm_btn);
await baseStep.click(Driver, userListPage.menu_user_list);
await baseStep.wait(Driver,2000);
await baseStep.screenShot(Driver, savaPath + "/04_suspend_result");
await userListPage.checkRecordUserList(Driver, "Testing QA"+time, "Auto"+ time + "@test.com","Suspended");
done();
}
catch (e) {
done(e);
}finally {
await Driver.quit();
}
})();
});
it('Delay 5 seconds ', (done) => {
setTimeout(() => {// TODO Need wait about syncTimeAPI second after last operation
done();
}, 5000);
});
});
describe('TS002: Assign subscription in user list=> Success', function() {
this.timeout(9000000);
beforeEach(function () {
response = null;
addContext(this, {
title: 'StartTime',
value: {
StartTime: timeStamp = new Date()
}
});
});
afterEach(function () {
if (response) {
addContext(this, {
title: 'Request',
value: {
Request: request
}
});
addContext(this, {
title: 'Response',
value: {
Response: response
}
});
addContext(this, {
title: 'EndTime',
value: {
EndTime: timeStamp = new Date()
}
});
}
});
it('case 01 - Assign a sub => Success ', (done) => {
(async () => {
try {
// login
Driver = driver.getDriver(webdriver, 'chrome');
// Check Url
await loginPage.openMerchantUrl(Driver, "http://unibee:123456@localhost/plan/list/");
const currentUrl = await Driver.getCurrentUrl();
console.log('当前网址:', currentUrl);
await baseStep.waitUntilElement(Driver, loginPage.email,20000);
await loginPage.loginMerchant(Driver, "[email protected]", "changeme")
await baseStep.wait(Driver, 1000);
await baseStep.waitUntilElement(Driver, userListPage.menu_user_list);
await baseStep.click(Driver, userListPage.menu_user_list);
await baseStep.wait(Driver,2000);
await baseStep.click(Driver, userListPage.add_new_btn);
await baseStep.wait(Driver,2000);
let time = new Date().getTime();
await baseStep.input(Driver, userListPage.new_email, "Auto"+ time + "@test.com");
await baseStep.input(Driver, userListPage.new_ex_user_id, time);
await baseStep.input(Driver, userListPage.new_first_name, "Testing");
await baseStep.input(Driver, userListPage.new_last_name, "QA" + time);
await baseStep.input(Driver, userListPage.new_phone, "15642543250");
await baseStep.input(Driver, userListPage.new_address, "Test Address");
await baseStep.screenShot(Driver, savaPath + "/05_add_user");
await baseStep.click(Driver, userListPage.new_OK_btn);
await baseStep.wait(Driver,1000);
await baseStep.screenShot(Driver, savaPath + "/06_user_list");
await userListPage.checkRecordUserList(Driver, "Testing QA"+time, "Auto"+ time + "@test.com","Active");
await baseStep.click(Driver, userListPage.subscription_tab);
await baseStep.wait(Driver,1000);
await baseStep.click(Driver, userListPage.assign_sub_btn);
await baseStep.wait(Driver,1000);
await userListPage.selectTargetPlan(Driver, "Month Plan");
await baseStep.wait(Driver,1000);
await baseStep.screenShot(Driver, savaPath + "/07_assign_sub");
await baseStep.click(Driver, userListPage.assign_OK_btn);
await baseStep.wait(Driver,3000);
await baseStep.screenShot(Driver, savaPath + "/08_assign_result");
await baseStep.compareText(Driver, userListPage.current_text, "Current Subscription");
await baseStep.compareText(Driver, userListPage.current_plan, "Month Plan");
await baseStep.compareText(Driver, userListPage.current_plan_des, "Month Plan");
await baseStep.compareText(Driver, userListPage.current_status, "Incomplete");
done();
}
catch (e) {
done(e);
}finally {
await Driver.quit();
}
})();
});
it('Delay 5 seconds ', (done) => {
setTimeout(() => {// TODO Need wait about syncTimeAPI second after last operation
done();
}, 5000);
});
});
......@@ -10,7 +10,7 @@ const baseStep = require('../../../CommonStep/Web/Web_Common_Step');
const API_Object = require("../../../CommonStep/API/API_Object");
const API_Env = require("../../../CommonStep/API/API_Env");
const ApiReq = new API_Object("http://localhost:8088");
const ApiReq = new API_Object("http://api.unibee.top");
const addContext = require('mochawesome/addContext');
const {expect} = require("chai");
......@@ -92,7 +92,7 @@ describe('Cancel the subscription', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -117,7 +117,7 @@ describe('Cancel the subscription', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -237,7 +237,7 @@ describe('TS001: Purchase plan with credit card=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -262,7 +262,7 @@ describe('TS001: Purchase plan with credit card=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -430,7 +430,7 @@ describe('TS002: Purchase plan with wire transfer and not finish=> Success', fun
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -455,7 +455,7 @@ describe('TS002: Purchase plan with wire transfer and not finish=> Success', fun
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -615,7 +615,7 @@ describe('TS003: Purchase plan with wire transfer and finished=> Success', funct
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -640,7 +640,7 @@ describe('TS003: Purchase plan with wire transfer and finished=> Success', funct
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......
......@@ -12,7 +12,7 @@ const baseStep = require('../../../CommonStep/Web/Web_Common_Step');
const API_Object = require("../../../CommonStep/API/API_Object");
const API_Env = require("../../../CommonStep/API/API_Env");
const ApiReq = new API_Object("http://localhost:8088");
const ApiReq = new API_Object("http://api.unibee.top");
const addContext = require('mochawesome/addContext');
const {expect} = require("chai");
......
......@@ -11,7 +11,7 @@ const baseStep = require('../../../CommonStep/Web/Web_Common_Step');
const API_Object = require("../../../CommonStep/API/API_Object");
const API_Env = require("../../../CommonStep/API/API_Env");
const ApiReq = new API_Object("http://localhost:8088");
const ApiReq = new API_Object("http://api.unibee.top");
const addContext = require('mochawesome/addContext');
const {expect} = require("chai");
......@@ -94,7 +94,7 @@ describe('TS001: Invoice with Paid=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -119,7 +119,7 @@ describe('TS001: Invoice with Paid=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -300,7 +300,7 @@ describe('TS001: Invoice with Processing=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -325,7 +325,7 @@ describe('TS001: Invoice with Processing=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -496,7 +496,7 @@ describe('TS001: Invoice with cancelled=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -521,7 +521,7 @@ describe('TS001: Invoice with cancelled=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......
......@@ -12,7 +12,7 @@ const baseStep = require('../../../CommonStep/Web/Web_Common_Step');
const API_Object = require("../../../CommonStep/API/API_Object");
const API_Env = require("../../../CommonStep/API/API_Env");
const ApiReq = new API_Object("http://localhost:8088");
const ApiReq = new API_Object("http://api.unibee.top");
const addContext = require('mochawesome/addContext');
const {expect} = require("chai");
......@@ -95,7 +95,7 @@ describe('TS001: Transaction with Succeeded=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -120,7 +120,7 @@ describe('TS001: Transaction with Succeeded=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -190,7 +190,7 @@ describe('TS001: Transaction with Succeeded=> Success', function() {
await baseStep.click(Driver, userPlanPage.OK_btn);
await baseStep.wait(Driver,5000);
await baseStep.switchWindow(Driver);
await baseStep.waitUntilElement(Driver, userPlanPage.change_card_btn,200000);
await baseStep.waitUntilElement(Driver, userPlanPage.change_card_btn,2000);
await baseStep.click(Driver, userPlanPage.change_card_btn);
await baseStep.input(Driver,userPlanPage.card_number, '4242424242424242');
await baseStep.input(Driver,userPlanPage.card_expiry, '1234');
......@@ -295,7 +295,7 @@ describe('TS002: Transaction with Pending=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -320,7 +320,7 @@ describe('TS002: Transaction with Pending=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -486,7 +486,7 @@ describe('TS002: Transaction with Failed=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -511,7 +511,7 @@ describe('TS002: Transaction with Failed=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......
......@@ -13,7 +13,7 @@ const baseStep = require('../../../CommonStep/Web/Web_Common_Step');
const API_Object = require("../../../CommonStep/API/API_Object");
const API_Env = require("../../../CommonStep/API/API_Env");
const ApiReq = new API_Object("http://localhost:8088");
const ApiReq = new API_Object("http://api.unibee.top");
const addContext = require('mochawesome/addContext');
const {expect} = require("chai");
......
......@@ -11,7 +11,7 @@ const baseStep = require('../../../CommonStep/Web/Web_Common_Step');
const API_Object = require("../../../CommonStep/API/API_Object");
const API_Env = require("../../../CommonStep/API/API_Env");
const ApiReq = new API_Object("http://localhost:8088");
const ApiReq = new API_Object("http://api.unibee.top");
const addContext = require('mochawesome/addContext');
const {expect} = require("chai");
......@@ -94,7 +94,7 @@ describe('TS001: purchase with a vat number=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -119,7 +119,7 @@ describe('TS001: purchase with a vat number=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -283,7 +283,7 @@ describe('TS002: Check the different taxes under different countries=> Success',
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -308,7 +308,7 @@ describe('TS002: Check the different taxes under different countries=> Success',
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......@@ -495,7 +495,7 @@ describe('TS001: purchase with a discount code=> Success', function() {
it('Case 02: Get User List => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getUserList(API_Env.get().headerSet,urlencoded(testUser),(res, url, header) => {
request = {
URL: url,
......@@ -520,7 +520,7 @@ describe('TS001: purchase with a discount code=> Success', function() {
it('Case 03: Get subscription => Success', (done) => {
try {
setTimeout(() => {//Wait syncTimeAPI*1000 seconds
API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
// API_Env.get().headerSet.Authorization = "Bearer " + testData["token"];
ApiReq.getSubscription(API_Env.get().headerSet, testData['id'],(res, url, header) => {
request = {
URL: url,
......
......@@ -4,7 +4,8 @@ Env = {
url: "https://api.unibee.top"
},
headerSet: {
'Authorization': '',
// 'Authorization': 'Bearer iioMWSTNd1qOtdAhxExnjWzQLcv976TT', // joshua.yu+8
'Authorization': 'Bearer b38Q1SbncYQJJYyTTTPtyoNSVVNj6dsO', // local
'Content-Type': 'application/json'
}
}
......
......@@ -68,6 +68,14 @@ exports.compareText = async function (driver, xpath, expectText) {
await expect(actualText).to.equal(expectText);
};
exports.compareValueText = async function (driver, xpath, expectText){
let element = await driver.findElement(By.xpath(xpath));
let actualText = await element.getAttribute('value');
console.log("Actual Text: " + actualText);
console.log("Expect Text: " + expectText);
await expect(actualText).to.equal(expectText);
}
getTitle = async function (driver) {
let title = await driver.getTitle();
await console.log('Title <' + title + '>');
......
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