diff --git a/test/ui/ui_bug_test.go b/test/ui/ui_bug_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7427ec3efc0d2e56ad9dc397bc43e115877ff8d0 --- /dev/null +++ b/test/ui/ui_bug_test.go @@ -0,0 +1,64 @@ +package script + +import ( + "testing" + + ztfTestHelper "github.com/easysoft/zentaoatf/test/helper/ztf" + plwHelper "github.com/easysoft/zentaoatf/test/ui/helper" + "github.com/ozontech/allure-go/pkg/framework/provider" + "github.com/ozontech/allure-go/pkg/framework/runner" + playwright "github.com/playwright-community/playwright-go" +) + +var bugBrowser playwright.Browser + +func ScriptBug(t provider.T) { + t.ID("5747") + t.AddParentSuite("查看bug列表") + + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + ztfTestHelper.SelectSite(webpage) + ztfTestHelper.ExpandWorspace(webpage) + ztfTestHelper.RunScript(webpage, "1_string_match.php") + ztfTestHelper.SubmitResult(webpage) + locator := webpage.Locator(".tree-node", playwright.PageLocatorOptions{HasText: "单元测试工作目录"}) + locator.Click() + scriptLocator := webpage.Locator(".tree-node-title:has-text('1_string_match.php')") + scriptLocator.Click() + webpage.WaitForTimeout(200) + webpage.Click(".statistic>>span>>nth=3") + elements := webpage.QuerySelectorAll("#bugsModal>>tr") + + bugTimesInt := len(elements.ElementHandles) + if bugTimesInt < 2 { + t.Error("statistic error") + t.FailNow() + } +} + +func ScriptsBug(t provider.T) { + t.ID("5748") + t.AddParentSuite("查看bug列表") + + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + webpage.WaitForSelector("#mainContent .tree") + locator := webpage.Locator(".tree-node", playwright.PageLocatorOptions{HasText: "单元测试工作目录"}) + locator.Click() + webpage.Click(`[title="批量选择"]`) + webpage.Click(".tree-node-item:has-text('1_string_match.php')>>.tree-node-check") + webpage.Click(".tree-node-item:has-text('2_webpage_extract.php')>>.tree-node-check") + webpage.Click(`[title="禅道BUG"]`) + elements := webpage.QuerySelectorAll("#bugsModal>>tr") + + bugTimesInt := len(elements.ElementHandles) + if bugTimesInt < 2 { + t.Error("statistic error") + t.FailNow() + } +} +func TestUiBug(t *testing.T) { + runner.Run(t, "客户端-查看单个脚本bug列表", ScriptBug) + runner.Run(t, "客户端-查看选中脚本bug列表", ScriptsBug) +} diff --git a/test/ui/ui_interpreter_test.go b/test/ui/ui_interpreter_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7ef1da334aea003419c04c7b08050e5aa0ec2c83 --- /dev/null +++ b/test/ui/ui_interpreter_test.go @@ -0,0 +1,73 @@ +package script + +import ( + "testing" + + plwConf "github.com/easysoft/zentaoatf/test/ui/conf" + plwHelper "github.com/easysoft/zentaoatf/test/ui/helper" + "github.com/ozontech/allure-go/pkg/framework/provider" + "github.com/ozontech/allure-go/pkg/framework/runner" + playwright "github.com/playwright-community/playwright-go" +) + +func CreateInterpreter(t provider.T) { + t.ID("5744") + t.AddParentSuite("管理解析器") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + webpage.Click("#navbar>>[title=\"设置\"]") + webpage.Click("#proxyTable>>tr:has-text('本地节点')>>button:has-text('运行环境')") + webpage.Click("text=新建运行环境") + locator := webpage.Locator("#interpreterFormModal select") + locator.Click() + locator.SelectNth(0, playwright.SelectOptionValues{Values: &[]string{"python"}}) + webpage.WaitForTimeout(200) + locator.SelectNth(1, playwright.SelectOptionValues{Indexes: &[]int{1}}) + webpage.Click("#interpreterFormModal>>text=确定") + _ = webpage.Locator("#settingModal .z-tbody-td", playwright.PageLocatorOptions{HasText: "Python"}) +} + +func EditInterpreter(t provider.T) { + t.ID("5745") + t.AddParentSuite("管理解析器") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + webpage.Click("#navbar>>[title=\"设置\"]") + webpage.Click("#proxyTable>>tr:has-text('本地节点')>>button:has-text('运行环境')") + locator := webpage.Locator("#settingModal .z-tbody-tr:has-text('Python')>>text=编辑") + locator.Click() + locator = webpage.Locator("#interpreterFormModal select") + locator.SelectNth(0, playwright.SelectOptionValues{Values: &[]string{"python"}}) + webpage.WaitForTimeout(200) + locator.SelectNth(1, playwright.SelectOptionValues{Indexes: &[]int{1}}) + webpage.Click("#interpreterFormModal>>text=确定") + locator = webpage.Locator("#settingModal .z-tbody-td", playwright.PageLocatorOptions{HasText: "Python"}) +} + +func DeleteInterpreter(t provider.T) { + t.ID("5465") + t.AddParentSuite("管理解析器") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + webpage.Click("#navbar>>[title=\"设置\"]") + webpage.Click("#proxyTable>>tr:has-text('本地节点')>>button:has-text('运行环境')") + locator := webpage.Locator("#settingModal .z-tbody-tr", playwright.PageLocatorOptions{HasText: "Python"}) + locator = locator.Locator("text=删除") + locator.Click() + webpage.Click(":nth-match(.modal-action > button, 1)") + webpage.WaitForTimeout(1000) + plwConf.DisableErr() + locator = webpage.Locator("#settingModal .z-tbody-tr", playwright.PageLocatorOptions{HasText: "Python"}) + c := locator.Count() + if c > 0 { + t.Errorf("Delete interpreter fail") + t.FailNow() + } + plwConf.EnableErr() +} + +func TestUiInterpreter(t *testing.T) { + runner.Run(t, "客户端-创建语言解析器", CreateInterpreter) + runner.Run(t, "客户端-编辑语言解析器", EditInterpreter) + runner.Run(t, "客户端-删除语言解析器", DeleteInterpreter) +} diff --git a/test/ui/ui_language_test.go b/test/ui/ui_language_test.go new file mode 100644 index 0000000000000000000000000000000000000000..72f19ee30e552504a089597ee9afc3609cb1f307 --- /dev/null +++ b/test/ui/ui_language_test.go @@ -0,0 +1,41 @@ +package script + +import ( + "testing" + + plwHelper "github.com/easysoft/zentaoatf/test/ui/helper" + "github.com/ozontech/allure-go/pkg/framework/provider" + "github.com/ozontech/allure-go/pkg/framework/runner" +) + +func SwitchLanguage(t provider.T) { + t.ID("5464") + t.AddParentSuite("设置界面语言") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + webpage.Click("#navbar>>[title=\"设置\"]") + webpage.Click(`input[type="radio"]>>nth=1`) + locator := webpage.Locator(".t-card-toolbar div>>nth=2") + interpreterTitle := locator.InnerText() + if interpreterTitle != "Remote Server" { + t.Error("Switch language fail, find interpreter fail") + t.FailNow() + } + locator = webpage.Locator(".t-card-toolbar button") + CreateInterpreterTitle := locator.InnerText() + if CreateInterpreterTitle != "Create Remote Server" { + t.Error("Switch language fail, find create remote server btn fail") + t.FailNow() + } + locator = webpage.Locator("#settingModal .modal-title") + modalTitle := locator.InnerText() + if modalTitle != "Settings" { + t.Error("Switch language fail, find modalTitle fail") + t.FailNow() + } + webpage.Click(`input[type="radio"]>>nth=0`) +} + +func TestUiLanguage(t *testing.T) { + runner.Run(t, "设置界面语言", SwitchLanguage) +} diff --git a/test/ui/ui_log_test.go b/test/ui/ui_log_test.go new file mode 100644 index 0000000000000000000000000000000000000000..02ef5aaa967b2bc51f6e60600d56abb015bd7e0d --- /dev/null +++ b/test/ui/ui_log_test.go @@ -0,0 +1,63 @@ +package script + +import ( + "testing" + + plwConf "github.com/easysoft/zentaoatf/test/ui/conf" + plwHelper "github.com/easysoft/zentaoatf/test/ui/helper" + "github.com/ozontech/allure-go/pkg/framework/provider" + "github.com/ozontech/allure-go/pkg/framework/runner" + playwright "github.com/playwright-community/playwright-go" +) + +func CollapseLog(t provider.T) { + t.ID("5502") + t.AddParentSuite("脚本执行日志") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + webpage.WaitForSelector(".tree-node") + locator := webpage.Locator(".tree-node", playwright.PageLocatorOptions{HasText: "单元测试工作目录"}) + locator.Click() + scriptLocator := locator.Locator("text=1_string_match.php") + scriptLocator.Click() + webpage.Click(".tabs-nav-toolbar>>[title=\"Run\"]") + webpage.WaitForSelector("#log-list>>.msg-span>>:has-text('执行1个用例,耗时')") + webpage.Click(".btn[title=\"展开所有\"]") + locator = webpage.Locator("#log-list>>.show-detail>>:has-text('[Expect]')") + webpage.WaitForTimeout(100) + webpage.Click(".btn[title=\"折叠所有\"]") + plwConf.DisableErr() + defer plwConf.EnableErr() + locator = webpage.Locator("#log-list>>.show-detail>>:has-text('[Expect]')") + count := locator.Count() + if count > 0 { + t.Error("Find Collapsed log fail") + t.FailNow() + } +} + +func FullScreenLog(t provider.T) { + t.ID("5749") + t.AddParentSuite("脚本执行日志") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + webpage.WaitForSelector(".tree-node") + locator := webpage.Locator(".tree-node", playwright.PageLocatorOptions{HasText: "单元测试工作目录"}) + locator.Click() + scriptLocator := locator.Locator("text=1_string_match.php") + scriptLocator.Click() + webpage.Click(".tabs-nav-toolbar>>[title=\"Run\"]") + webpage.WaitForSelector("#log-list>>.msg-span>>:has-text('执行1个用例,耗时')") + webpage.Click(".btn[title=\"向上展开\"]") + webpage.WaitForTimeout(100) + isHidden := webpage.IsHidden("#tabsPane") + if !isHidden { + t.Errorf("Check Full Screen fail") + t.FailNow() + } +} + +func TestUiLog(t *testing.T) { + runner.Run(t, "客户端-展开折叠执行日志", CollapseLog) + runner.Run(t, "客户端-最大化脚本执行日志", FullScreenLog) +} diff --git a/test/ui/ui_product_test.go b/test/ui/ui_product_test.go new file mode 100644 index 0000000000000000000000000000000000000000..516b21b7010501bf3b888bca36acc2c59473bf8e --- /dev/null +++ b/test/ui/ui_product_test.go @@ -0,0 +1,37 @@ +package script + +import ( + "testing" + + plwHelper "github.com/easysoft/zentaoatf/test/ui/helper" + "github.com/ozontech/allure-go/pkg/framework/provider" + "github.com/ozontech/allure-go/pkg/framework/runner" +) + +func SwitchProduct(t provider.T) { + t.ID("5496") + t.AddParentSuite("切换禅道产品") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + webpage.WaitForSelector(".tree-node") + locator := webpage.Locator("#siteMenuToggle") + locator.Click() + webpage.WaitForSelector("#navbar .list-item") + webpage.Click(".list-item-title>>text=单元测试站点") + webpage.Click("#productMenuToggle") + webpage.WaitForSelector("#navbar .list-item") + webpage.Click("#navbar .list-item>>text=企业内部工时管理系统") + webpage.WaitForTimeout(100) + productName := webpage.InnerText("#productMenuToggle>>span") + if productName != "企业内部工时管理系统" { + t.Error("Switch product fail") + t.FailNow() + } + webpage.Click("#productMenuToggle") + webpage.WaitForSelector("#navbar .list-item") + webpage.Click("#navbar .list-item>>text=公司企业网站建设") +} + +func TestUiProduct(t *testing.T) { + runner.Run(t, "客户端-切换禅道产品", SwitchProduct) +} diff --git a/test/ui/ui_result_test.go b/test/ui/ui_result_test.go new file mode 100644 index 0000000000000000000000000000000000000000..fd01f572db158c349d87c033324c4f3de5d2d9a9 --- /dev/null +++ b/test/ui/ui_result_test.go @@ -0,0 +1,100 @@ +package script + +import ( + "strings" + "testing" + + ztfTest "github.com/easysoft/zentaoatf/test/helper/ztf" + ztfTestHelper "github.com/easysoft/zentaoatf/test/helper/ztf" + plwHelper "github.com/easysoft/zentaoatf/test/ui/helper" + "github.com/ozontech/allure-go/pkg/framework/provider" + "github.com/ozontech/allure-go/pkg/framework/runner" + playwright "github.com/playwright-community/playwright-go" +) + +func Detail(t provider.T) { + t.ID("5489") + t.AddParentSuite("测试结果") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + ztfTest.SelectSite(webpage) + ztfTest.ExpandWorspace(webpage) + ztfTest.RunScript(webpage, "1_string_match.php") + webpage.Click("#rightPane .result-list-item .list-item-title>>nth=0") + webpage.WaitForSelector(".result-action .btn:has-text('提交结果到禅道')") + locator := webpage.Locator(".page-result .single small") + result := locator.InnerText() + if result != "通过 0.00%" { + t.Error("Detail result error") + t.FailNow() + } + locator = webpage.Locator(".result-step-checkpoint code") + expectVal := locator.InnerText() + if strings.TrimSpace(expectVal) != "~c:!=2~" { + t.Error("Detail expect error") + t.FailNow() + } + locator = webpage.Locator(".result-step-checkpoint code>>nth=1") + actualVal := locator.InnerText() + if strings.TrimSpace(actualVal) != "2" { + t.Error("Detail actual error") + t.FailNow() + } +} + +func SubmitResult(t provider.T) { + t.ID("5499") + t.AddParentSuite("测试结果") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + ztfTestHelper.SelectSite(webpage) + webpage.Click("#rightPane .result-list-item .list-item-title>>nth=0") + webpage.Click(".result-action .btn:has-text('提交结果到禅道')") + + webpage.WaitForSelector("#syncToZentaoModal") + titleInput := webpage.Locator("#syncToZentaoModal>>.form-item:has-text('或输入新测试单标题')>>input") + titleInput.Fill("单元测试测试单") + webpage.Click("#syncToZentaoModal>>text=确定") + webpage.WaitForSelectorByOptions("#syncToZentaoModal", playwright.PageWaitForSelectorOptions{State: playwright.WaitForSelectorStateHidden}) + webpage.Locator(".toast-notification-container:has-text('提交成功')") +} + +func SubmitBug(t provider.T) { + t.ID("5500") + t.AddParentSuite("测试结果") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + ztfTestHelper.SelectSite(webpage) + webpage.Click("#rightPane .result-list-item .list-item-title>>nth=0") + webpage.Click(".page-result .btn:has-text('提交缺陷到禅道')") + webpage.WaitForSelector("#submitBugModal") + webpage.Click("#submitBugModal>>text=确定") + webpage.WaitForSelectorByOptions("#submitBugModal", playwright.PageWaitForSelectorOptions{State: playwright.WaitForSelectorStateHidden}) + webpage.Locator(".toast-notification-container", playwright.PageLocatorOptions{HasText: "提交成功"}) +} + +func SubmitBugTwoStep(t provider.T) { + t.ID("5500") + t.AddParentSuite("测试结果") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + ztfTestHelper.SelectSite(webpage) + ztfTestHelper.ExpandWorspace(webpage) + ztfTest.RunScript(webpage, "1_string_match.php") + webpage.Click("#rightPane .result-list-item .list-item-title>>nth=0") + + webpage.Click(".page-result .btn:has-text('提交缺陷到禅道')") + + webpage.WaitForSelector("#submitBugModal") + webpage.Click("#cbox0") + webpage.Click("#submitBugModal>>text=确定") + webpage.WaitForSelectorByOptions("#submitBugModal", playwright.PageWaitForSelectorOptions{State: playwright.WaitForSelectorStateHidden}) + webpage.Locator(".toast-notification-container", playwright.PageLocatorOptions{HasText: "提交成功"}) +} + +func TestUiResult(t *testing.T) { + runner.Run(t, "客户端-查看测试结果详情", Detail) + runner.Run(t, "客户端-提交禅道用例脚本测试结果", SubmitResult) + runner.Run(t, "客户端-提交禅道失败用例为缺陷", SubmitBug) + runner.Run(t, "客户端-提交禅道部分失败用例为缺陷", SubmitBugTwoStep) +} diff --git a/test/ui/ui_run_from_result_test.go b/test/ui/ui_run_from_result_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6fa94387f0816affbda399407328f7aeaeb76dc3 --- /dev/null +++ b/test/ui/ui_run_from_result_test.go @@ -0,0 +1,84 @@ +package script + +import ( + "strings" + "testing" + + ztfTestHelper "github.com/easysoft/zentaoatf/test/helper/ztf" + plwHelper "github.com/easysoft/zentaoatf/test/ui/helper" + "github.com/ozontech/allure-go/pkg/framework/provider" + "github.com/ozontech/allure-go/pkg/framework/runner" +) + +func RunReExecFailCase(t provider.T) { + t.ID("5491") + t.AddParentSuite("测试结果页面执行脚本") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + locator := webpage.Locator("#siteMenuToggle") + locator.Click() + webpage.WaitForSelector("#navbar .list-item") + webpage.Click(".list-item-title>>text=单元测试站点") + webpage.Click("#rightPane .result-list-item .list-item-title>>nth=0") + webpage.Click(".result-action .btn:has-text('重新执行失败用例')") + webpage.WaitForSelector("#log-list>>.msg-span>>:has-text('执行1个用例,耗时')") + locator = webpage.Locator("#log-list>>code:has-text('执行1个用例,耗时')") + innerText := locator.InnerText() + if !strings.Contains(innerText, "0(0.0%) 通过,1(100.0%) 失败") { + t.Errorf("Exec failed case fail") + t.FailNow() + } + resultTitle := webpage.InnerText("#rightPane .result-list-item .list-item-title") + if resultTitle != "1_string_match.php" { + t.Errorf("Find result in rightPane fail") + t.FailNow() + } + timeElement := locator.Locator(".time>>span") + if resultTitle != "1_string_match.php" { + t.Errorf("Find log time element in logPane fail") + t.FailNow() + } + logTime := timeElement.InnerText() + resultTime := webpage.InnerText("#rightPane .result-list-item .list-item-trailing-text") + if logTime[:5] != resultTime { + t.Errorf("Find result in rightPane fail") + t.FailNow() + } +} + +func RunReExecAllCase(t provider.T) { + t.ID("5750") + t.AddParentSuite("测试结果页面执行脚本") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + locator := webpage.Locator("#siteMenuToggle") + locator.Click() + webpage.WaitForSelector("#navbar .list-item") + webpage.Click(".list-item-title>>text=单元测试站点") + ztfTestHelper.RunScript(webpage, "1_string_match.php") + webpage.Click("#rightPane .result-list-item .list-item-title>>nth=0") + webpage.Click(".result-action .btn:has-text('重新执行所有用例')") + webpage.WaitForSelector("#log-list>>.msg-span>>:has-text('执行1个用例,耗时')") + locator = webpage.Locator("#log-list>>code:has-text('执行1个用例,耗时')") + innerText := locator.InnerText() + if !strings.Contains(innerText, "0(0.0%) 通过,1(100.0%) 失败") { + t.Errorf("Exec failed case fail") + t.FailNow() + } + resultTitle := webpage.InnerText("#rightPane .result-list-item .list-item-title") + if resultTitle != "1_string_match.php" { + t.Errorf("Find result in rightPane fail") + t.FailNow() + } + timeElement := locator.Locator(".time>>span") + logTime := timeElement.InnerText() + resultTime := webpage.InnerText("#rightPane .result-list-item .list-item-trailing-text") + if logTime[:5] != resultTime { + t.Errorf("Find result in rightPane fail") + t.FailNow() + } +} +func TestUiRunFromResult(t *testing.T) { + runner.Run(t, "客户端-结果中重新执行所有脚本", RunReExecAllCase) + runner.Run(t, "客户端-结果中重新执行失败脚本", RunReExecFailCase) +} diff --git a/test/ui/ui_run_statistic_test.go b/test/ui/ui_run_statistic_test.go new file mode 100644 index 0000000000000000000000000000000000000000..05c31f921ba2a71b442a2272793dc8df4ae5b0f7 --- /dev/null +++ b/test/ui/ui_run_statistic_test.go @@ -0,0 +1,104 @@ +package script + +import ( + "strconv" + "testing" + + plwHelper "github.com/easysoft/zentaoatf/test/ui/helper" + "github.com/ozontech/allure-go/pkg/framework/provider" + "github.com/ozontech/allure-go/pkg/framework/runner" + playwright "github.com/playwright-community/playwright-go" +) + +var runStatisticPage playwright.Page + +func RunFailStatistic(t provider.T) { + t.ID("5487") + t.AddParentSuite("执行脚本") + + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + webpage.WaitForSelector(".tree-node") + locator := webpage.Locator(".tree-node", playwright.PageLocatorOptions{HasText: "单元测试工作目录"}) + locator.Click() + scriptLocator := locator.Locator("text=1_string_match.php") + scriptLocator.Click() + elements := webpage.QuerySelectorAll(".statistic>>span") + runTimes := elements.InnerText(0) + failTimes := elements.InnerText(2) + runTimesInt, _ := strconv.Atoi(runTimes) + failTimesInt, _ := strconv.Atoi(failTimes) + webpage.Click(".tabs-nav-toolbar>>[title=\"Run\"]") + webpage.WaitForSelector("#log-list>>.msg-span>>:has-text('执行1个用例,耗时')") + webpage.WaitForTimeout(200) + elements = webpage.QuerySelectorAll(".statistic>>span") + runTimes2 := elements.InnerText(0) + failTimes2 := elements.InnerText(2) + runTimes2Int, _ := strconv.Atoi(runTimes2) + failTimes2Int, _ := strconv.Atoi(failTimes2) + if runTimes2Int-runTimesInt != 1 || failTimes2Int-failTimesInt != 1 { + t.Error("statistic error") + t.FailNow() + } +} + +func RunSuccessStatistic(t provider.T) { + t.ID("5487") + t.AddParentSuite("执行脚本") + + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + webpage.WaitForSelector(".tree-node") + locator := webpage.Locator(".tree-node", playwright.PageLocatorOptions{HasText: "单元测试工作目录"}) + locator.Click() + scriptLocator := locator.Locator("text=3_http_interface_call.php") + scriptLocator.Click() + elements := webpage.QuerySelectorAll(".statistic>>span") + runTimes := elements.InnerText(0) + succTimes := elements.InnerText(1) + runTimesInt, _ := strconv.Atoi(runTimes) + succTimesInt, _ := strconv.Atoi(succTimes) + webpage.Click(".tabs-nav-toolbar>>[title=\"Run\"]") + webpage.WaitForSelector("#log-list>>.msg-span>>:has-text('执行1个用例,耗时')") + webpage.WaitForTimeout(200) + elements = webpage.QuerySelectorAll(".statistic>>span") + runTimes2 := elements.InnerText(0) + succTimes2 := elements.InnerText(1) + runTimes2Int, _ := strconv.Atoi(runTimes2) + succTimes2Int, _ := strconv.Atoi(succTimes2) + if runTimes2Int-runTimesInt != 1 || succTimes2Int-succTimesInt != 1 { + t.Error("statistic error") + t.FailNow() + } +} + +func RunBugStatistic(t provider.T) { + t.ID("5487") + t.AddParentSuite("执行脚本") + + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + webpage.WaitForSelector(".tree-node") + locator := webpage.Locator(".tree-node", playwright.PageLocatorOptions{HasText: "单元测试工作目录"}) + locator.Click() + scriptLocator := locator.Locator("text=1_string_match.php") + scriptLocator.Click() + webpage.WaitForTimeout(200) + elements := webpage.QuerySelectorAll(".statistic>>span") + bugTimes := elements.InnerText(3) + bugTimesInt, _ := strconv.Atoi(bugTimes) + webpage.Click(".statistic>>span>>nth=3") + elements = webpage.QuerySelectorAll("#bugsModal>>tr") + + bugTimes2Int := len(elements.ElementHandles) + if bugTimes2Int-1 != bugTimesInt { + t.Error("statistic error") + t.FailNow() + } +} + +func TestUiRunStatistic(t *testing.T) { + runner.Run(t, "客户端-确认执行统计成功数据", RunSuccessStatistic) + runner.Run(t, "客户端-确认执行统计失败数据", RunFailStatistic) + runner.Run(t, "客户端-确认执行统计bug数据", RunBugStatistic) +} diff --git a/test/ui/ui_script_test.go b/test/ui/ui_script_test.go new file mode 100644 index 0000000000000000000000000000000000000000..4fb8dc58d696bf241a53ee63902d81375b1631e4 --- /dev/null +++ b/test/ui/ui_script_test.go @@ -0,0 +1,57 @@ +package script + +import ( + "testing" + + ztfTestHelper "github.com/easysoft/zentaoatf/test/helper/ztf" + plwHelper "github.com/easysoft/zentaoatf/test/ui/helper" + "github.com/ozontech/allure-go/pkg/framework/provider" + "github.com/ozontech/allure-go/pkg/framework/runner" + playwright "github.com/playwright-community/playwright-go" +) + +func SaveScript(t provider.T) { + t.ID("5470") + t.AddParentSuite("禅道站点脚本") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + ztfTestHelper.SelectSite(webpage) + ztfTestHelper.ExpandWorspace(webpage) + webpage.Click(".tree-node-title:has-text('1_string_match.php')") + locator := webpage.Locator(".view-line>>text=title=check string matches pattern") + var positionX, positionY float64 = 400, 0 + force := true + locator.Click(playwright.PageClickOptions{Force: &force, Position: &playwright.PageClickOptionsPosition{X: &positionX, Y: &positionY}}) + locator.Type("-test") + webpage.Click(".tabs-nav-toolbar>>[title=\"Save\"]") + webpage.WaitForSelector(".toast-notification-close") + locator = webpage.Locator(".toast-notification-container", playwright.PageLocatorOptions{HasText: "保存成功"}) + locator.Click() + webpage.Click(".tree-node-title>>text=1_string_match.php") + + locator = webpage.Locator(".view-line>>:has-text('title=check string matches pattern')") + locator.Click(playwright.PageClickOptions{Force: &force, Position: &playwright.PageClickOptionsPosition{X: &positionX, Y: &positionY}}) + locator.Press("Backspace") + locator.Press("Backspace") + locator.Press("Backspace") + locator.Press("Backspace") + locator.Press("Backspace") + webpage.Click(".tabs-nav-toolbar>>[title=\"Save\"]") +} + +func ViewScript(t provider.T) { + t.ID("5469") + t.AddParentSuite("禅道站点脚本") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + ztfTestHelper.SelectSite(webpage) + ztfTestHelper.ExpandWorspace(webpage) + scriptLocator := webpage.Locator(".tree-node-title:has-text('1_string_match.php')") + scriptLocator.Click() + webpage.Locator(".view-line>>text=title=check string matches pattern") +} + +func TestUiScript(t *testing.T) { + runner.Run(t, "客户端-编辑保存禅道站点脚本", SaveScript) + runner.Run(t, "客户端-显示禅道站点脚本", ViewScript) +} diff --git a/test/ui/ui_site_test.go b/test/ui/ui_site_test.go new file mode 100644 index 0000000000000000000000000000000000000000..838af65a89c707af08da628fd4fe572adbb5617d --- /dev/null +++ b/test/ui/ui_site_test.go @@ -0,0 +1,90 @@ +package script + +import ( + "testing" + + plwConf "github.com/easysoft/zentaoatf/test/ui/conf" + plwHelper "github.com/easysoft/zentaoatf/test/ui/helper" + "github.com/ozontech/allure-go/pkg/framework/provider" + "github.com/ozontech/allure-go/pkg/framework/runner" + playwright "github.com/playwright-community/playwright-go" +) + +func CreateSite(t provider.T) { + t.ID("5466") + t.AddParentSuite("配置禅道站点") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + locator := webpage.Locator("#siteMenuToggle") + locator.Click() + webpage.WaitForSelector("#navbar .list-item") + webpage.Click("text=禅道站点管理") + webpage.Click("text=新建站点") + locator = webpage.Locator("#siteFormModal input") + locator.FillNth(0, "单元测试站点") + locator.FillNth(1, "http://127.0.0.1:8081/") + locator.FillNth(2, "admin") + locator.FillNth(3, "Test123456.") + webpage.Click("text=确定") + webpage.WaitForSelector(".list-item-content span:has-text('单元测试站点')") + locator = webpage.Locator(".list-item-content span", playwright.PageLocatorOptions{HasText: "单元测试站点"}) +} +func EditSite(t provider.T) { + t.ID("5466") + t.AddParentSuite("配置禅道站点") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + locator := webpage.Locator("#siteMenuToggle") + locator.Click() + webpage.WaitForSelector("#navbar .list-item") + webpage.Click("text=禅道站点管理") + plwConf.DisableErr() + locator = webpage.Locator(".list-item", playwright.PageLocatorOptions{HasText: "单元测试站点"}) + c := locator.Count() + if c == 0 { + CreateSite(t) + EditSite(t) + plwConf.EnableErr() + return + } + plwConf.EnableErr() + locator = webpage.Locator(".list-item", playwright.PageLocatorOptions{HasText: "单元测试站点"}) + webpage.Click("text=编辑") + locator = webpage.Locator("#siteFormModal input") + locator.FillNth(0, "单元测试站点-update") + locator.FillNth(1, "http://127.0.0.1:8081/") + locator.FillNth(2, "admin") + locator.FillNth(3, "Test123456.") + webpage.Click("#siteFormModal>>.modal-action>>span:has-text(\"确定\")") + webpage.WaitForSelector(".list-item-content span:has-text('单元测试站点-update')") + locator = webpage.Locator(".list-item-content span", playwright.PageLocatorOptions{HasText: "单元测试站点-update"}) +} +func DeleteSite(t provider.T) { + t.ID("5466") + t.AddParentSuite("配置禅道站点") + webpage, _ := plwHelper.OpenUrl("http://127.0.0.1:8000/", t) + defer webpage.Close() + locator := webpage.Locator("#siteMenuToggle") + locator.Click() + webpage.WaitForSelector("#navbar .list-item") + webpage.Click("text=禅道站点管理") + locator = webpage.Locator(".list-item:has-text('单元测试站点')") + webpage.Click("text=删除") + webpage.WaitForTimeout(1000) + webpage.Click(":nth-match(.modal-action > button, 1)") + webpage.WaitForSelector(".list-item-content span:has-text('单元测试站点')", playwright.PageWaitForSelectorOptions{State: playwright.WaitForSelectorStateDetached}) + plwConf.DisableErr() + defer plwConf.EnableErr() + locator = webpage.Locator(".list-item-content:has-text('单元测试站点')") + c := locator.Count() + if c > 0 { + t.Errorf("Delete site fail") + t.FailNow() + } +} + +func TestUiSite(t *testing.T) { + runner.Run(t, "客户端-编辑禅道站点", EditSite) + runner.Run(t, "客户端-删除禅道站点", DeleteSite) + runner.Run(t, "客户端-创建禅道站点", CreateSite) +}