admin test
This commit is contained in:
parent
c4e0d4a52e
commit
6636986904
Binary file not shown.
|
|
@ -10,7 +10,7 @@ use PHPUnit\TextUI\DefaultResultPrinter;
|
|||
|
||||
$suite = new TestSuite();
|
||||
// 向测试套件中添加测试用例
|
||||
//后台
|
||||
//前台
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\front\RegisterFirst.php');//先注册一个账户
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\front\RegisterTest.php');//场景注册
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\front\LoginTest.php'); //前台登录场景
|
||||
|
|
@ -21,6 +21,9 @@ use PHPUnit\TextUI\DefaultResultPrinter;
|
|||
$suite->addTestFile('.\tests\Browser\dusktest\page\front\RemoveWishlistTest.php');//移除喜欢
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\front\WishlistTest.php');//加入喜欢
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\front\EditUserInfo.php');//修改个人信息
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\front\CartCheckoutTest.php');//从购物车结账
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\front\ChangePayMethodTest.php');//下单时更改支付方式
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\front\OrderTest.php');//下单
|
||||
//后台
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\admin\AdminLoginTest.php'); //后台登录
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\admin\AdminSignOutTest.php'); //后台退出
|
||||
|
|
@ -44,10 +47,14 @@ use PHPUnit\TextUI\DefaultResultPrinter;
|
|||
|
||||
|
||||
//前后台联测
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\combine\AlterOrderStationTest.php');//商订单状态修改
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\combine\AlterOrderStationTest.php');//订单状态修改 已支付-已发货-一已完成
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\combine\CancelOrderTest.php');//取消商品订单
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\combine\CloseVisiterCheckoutTest.php');//禁用游客结账
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\combine\OpenVisiterCheckoutTest.php');//开启游客结账
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\combine\CreateCategoriesTest.php');//添加商品分类
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\combine\EnableProductTest.php');//启用商品
|
||||
$suite->addTestFile('.\tests\Browser\dusktest\page\combine\DisableProductTest.php');//禁用商品
|
||||
|
||||
// 运行测试套件
|
||||
$result = $suite->run();
|
||||
// 输出测试结果
|
||||
|
|
|
|||
|
|
@ -8,7 +8,11 @@ const product_top = [
|
|||
"origin_price"=>"skus[0][origin_price]",//原价
|
||||
"cost_price"=>"skus[0][cost_price]",//成本价
|
||||
"quantity"=>"skus[0][quantity]",//数量
|
||||
"Enable"=>"#active-1",
|
||||
"Disable"=>"#active-0",
|
||||
"save_btn"=>"#content > div.page-title-box.py-1.d-flex.align-items-center.justify-content-between > div > button",//保存
|
||||
|
||||
];
|
||||
const product_assert = [
|
||||
"Disable_text" =>".text-danger",//商品禁用后显示的文本class
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ const customer_group = [
|
|||
//创建客户组
|
||||
"cre_cus_group"=>"#customer-app > div.card-body > div.d-flex.justify-content-between.mb-4 > button",
|
||||
//编辑客户组
|
||||
"edit_cus_group" =>"#customer-app > div.card-body > div.table-push > table > tbody > tr:nth-child(1) > td:nth-child(6) > button.btn.btn-outline-secondary.btn-sm",
|
||||
"edit_cus_group" =>".btn.btn-outline-secondary.btn-sm",
|
||||
//删除客户组
|
||||
"del_cus_group" =>"#customer-app > div.card-body > div.table-push > table > tbody > tr:nth-child(1) > td:nth-child(6) > button.btn.btn-outline-danger.btn-sm.ml-1",
|
||||
"get_assert"=>"#customer-app > div.card-body > div.table-push > table > tbody > tr:nth-child(1) > td:nth-child(2)",
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@ const checkout = [
|
|||
//订单号
|
||||
'order_num'=>'.fw-bold',
|
||||
'view_order'=>'View Order ',
|
||||
///
|
||||
'method_pay'=>'.radio-line-item',
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class AdminSignOutTest extends DuskTestCase
|
|||
->press(admin_login['login_btn'])
|
||||
->pause(2000)
|
||||
//2.退出
|
||||
->clickLink(admin_top['root'])
|
||||
->click(admin_top['root'])
|
||||
->pause(2000)
|
||||
->click(admin_top['sign_out'])
|
||||
->pause(10000)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class DelCustomerTest extends DuskTestCase
|
|||
|
||||
//场景1 email不合法
|
||||
|
||||
public function testEditProduct()
|
||||
public function testDelCustomer()
|
||||
{
|
||||
|
||||
$this->browse(function (Browser $browser)
|
||||
|
|
@ -34,7 +34,7 @@ class DelCustomerTest extends DuskTestCase
|
|||
->press(admin_login['login_btn'])
|
||||
->pause(2000)
|
||||
//2.点击客户管理
|
||||
->clickLink(admin_top['mg_customers']);
|
||||
->click(admin_top['mg_customers']);
|
||||
$customer_text=$browser->text(customer_list['get_assert']);
|
||||
echo $customer_text;
|
||||
$browser->press(customer_list['del_customer'])
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class EditCusGroupTest extends DuskTestCase
|
|||
->pause(3000)
|
||||
//4.点击客户组
|
||||
->clickLink(customer_left['customer_group'])
|
||||
//5.点击创建客户组
|
||||
//5.点击编辑客户组
|
||||
->press(customer_group['edit_cus_group'])
|
||||
//4.填写客户组信息
|
||||
->type(cre_cus_group['ch_group_name'], alter_cus_group_info['ch_group_name'])
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class GoCatalogTest extends DuskTestCase
|
|||
->press(admin_login['login_btn'])
|
||||
->pause(2000)
|
||||
//2.去往前台
|
||||
->clicklink(admin_top['root'])
|
||||
->click(admin_top['root'])
|
||||
->pause(3000)
|
||||
->click(admin_top['go_catalog'])
|
||||
->pause(2000)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class LanguageSwitchTest extends DuskTestCase
|
|||
* A basic browser test example.
|
||||
* @return void
|
||||
*/
|
||||
public function testGoVip()
|
||||
public function testLanguageSwitch()
|
||||
{
|
||||
|
||||
$this->browse(function (Browser $browser)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class CancelOrderTest extends DuskTestCase
|
|||
->press(admin_login['login_btn'])
|
||||
->pause(2000)
|
||||
//去往前台
|
||||
->clicklink(admin_top['root'])
|
||||
->click(admin_top['root'])
|
||||
->pause(3000)
|
||||
->click(admin_top['go_catalog'])
|
||||
->pause(2000)
|
||||
|
|
@ -67,7 +67,7 @@ class CancelOrderTest extends DuskTestCase
|
|||
//打印订单号
|
||||
echo $order_num;
|
||||
$browser->clickLink(checkout['view_order'])
|
||||
//进入后台,修改订单状态为已支付
|
||||
//进入后台,修改订单状态为已取消
|
||||
->driver->switchTo()->window($browser->driver->getWindowHandles()[0]);
|
||||
//点击订单管理按钮
|
||||
$browser->click(admin_top['mg_order'])
|
||||
|
|
@ -81,7 +81,7 @@ class CancelOrderTest extends DuskTestCase
|
|||
//点击状态栏下拉按钮
|
||||
->pause(2000)
|
||||
->press(order_details['pull_btn'])
|
||||
//修改状态为已支付
|
||||
//修改状态为已取消
|
||||
->pause(2000)
|
||||
->click(order_details['cancel'])
|
||||
->press(order_details['alter_btn'])
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Tests\DuskTestCase;
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../data/admin/login.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/admin/login_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/admin/admin_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/catalog/index_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/admin/product_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/admin/cre_product_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/admin/cre_product.php');
|
||||
class DisableProductTest extends DuskTestCase
|
||||
{
|
||||
/**
|
||||
* A basic browser test example.
|
||||
* @return void
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//启用商品
|
||||
|
||||
public function testDisableProduct()
|
||||
{
|
||||
|
||||
$this->browse(function (Browser $browser)
|
||||
{
|
||||
$browser->visit(admin_login['login_url'])
|
||||
//登录
|
||||
->type(admin_login['login_email'], admin_true_login['email'])
|
||||
->type(admin_login['login_pwd'], admin_true_login['password'])
|
||||
->press(admin_login['login_btn'])
|
||||
->pause(2000)
|
||||
->click(admin_top['mg_product']);
|
||||
$product1_text=$browser->text(products_top['get_name']);
|
||||
echo $product1_text;
|
||||
//编辑商品
|
||||
$browser->press(products_top['edit_product'])
|
||||
//启用商品
|
||||
->click(product_top['Disable'])
|
||||
//点击保存
|
||||
->press(product_top['save_btn'])
|
||||
->pause(3000)
|
||||
//点击商品,跳转前台
|
||||
->clickLink($product1_text)
|
||||
->pause(2000)
|
||||
->driver->switchTo()->window($browser->driver->getWindowHandles()[1]);
|
||||
//断言是否有下架提示
|
||||
$browser->assertVisible(product_assert['Disable_text'])
|
||||
->pause(3000)
|
||||
|
||||
|
||||
;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Tests\DuskTestCase;
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../data/admin/login.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/admin/login_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/admin/admin_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/catalog/index_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/admin/product_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/admin/cre_product_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/admin/cre_product.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/catalog/product_1.php');
|
||||
class EnableProductTest extends DuskTestCase
|
||||
{
|
||||
/**
|
||||
* A basic browser test example.
|
||||
* @return void
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//启用商品
|
||||
|
||||
public function testEnableProduct()
|
||||
{
|
||||
|
||||
$this->browse(function (Browser $browser)
|
||||
{
|
||||
$browser->visit(admin_login['login_url'])
|
||||
//登录
|
||||
->type(admin_login['login_email'], admin_true_login['email'])
|
||||
->type(admin_login['login_pwd'], admin_true_login['password'])
|
||||
->press(admin_login['login_btn'])
|
||||
->pause(2000)
|
||||
->click(admin_top['mg_product']);
|
||||
$product1_text=$browser->text(products_top['get_name']);
|
||||
echo $product1_text;
|
||||
//编辑商品
|
||||
$browser->press(products_top['edit_product'])
|
||||
//启用商品
|
||||
->click(product_top['Enable'])
|
||||
//点击保存
|
||||
->press(product_top['save_btn'])
|
||||
->pause(3000)
|
||||
//点击商品,跳转前台
|
||||
->clickLink($product1_text)
|
||||
->driver->switchTo()->window($browser->driver->getWindowHandles()[1]);
|
||||
//断言页面是否有购买按钮
|
||||
$browser->assertVisible(product['product_1'])
|
||||
->pause(3000)
|
||||
|
||||
|
||||
;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ class CartCheckoutTest extends DuskTestCase
|
|||
->press(product['add_cart'])
|
||||
->pause(3000)
|
||||
//6.点击购物车按钮
|
||||
->clickLink(index_cart['cart_icon'])
|
||||
->click(index_cart['cart_icon'])
|
||||
->pause(3000)
|
||||
//7.点击结账按钮
|
||||
->press(index_cart['cart_Checkout'])
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
namespace Tests\Browser;
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Tests\DuskTestCase;
|
||||
use App\Http\Controllers\By;
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../data/catalog/login.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/catalog/login_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/catalog/account_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/catalog/product_1.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/catalog/index_page.php');
|
||||
require_once(dirname(__FILE__) . '/../../data/catalog/checkout_page.php');
|
||||
|
||||
//已注册客户且有地址,在下单时更换支付方式购买
|
||||
class ChangePayMethodTest extends DuskTestCase
|
||||
{
|
||||
public function testChangePayMethod()
|
||||
{
|
||||
$this->browse(function (Browser $browser)
|
||||
{
|
||||
$browser->visit(login['login_url'])
|
||||
//1.用户登录
|
||||
->type(login['login_email'], true_login['email'])
|
||||
->type(login['login_pwd'], true_login['password'])
|
||||
->press(login['login_btn'])
|
||||
->pause(5000)
|
||||
//当前网址断言
|
||||
->assertPathIs(account['url'])
|
||||
//2.点击home跳转到首页
|
||||
->click(account['go_index'])
|
||||
//3.向下滑动页面直到找到元素
|
||||
->scrollIntoView(index['product_img'])
|
||||
->pause(2000)
|
||||
//点击要购买的商品
|
||||
->press(index['product_img'])
|
||||
//4.点击购买按钮
|
||||
->press(product['product_1'])
|
||||
->pause(5000)
|
||||
//点击第二种支付方式
|
||||
|
||||
->elements(checkout['method_pay'])[1]->click();
|
||||
$browser->pause(5000)
|
||||
//5.点击确认按钮
|
||||
->press(checkout['submit'])
|
||||
->pause(5000)
|
||||
//6.断言
|
||||
->assertSee(checkout['assert']);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue