@@ -11,87 +11,105 @@ import { getTestAlertData, getTestActionData } from '../../lib/get_test_data';
1111
1212export default ( { getPageObjects, getService } : FtrProviderContext ) => {
1313 const testSubjects = getService ( 'testSubjects' ) ;
14+ const security = getService ( 'security' ) ;
1415 const pageObjects = getPageObjects ( [ 'common' , 'triggersActionsUI' , 'header' ] ) ;
1516 const log = getService ( 'log' ) ;
1617 const browser = getService ( 'browser' ) ;
1718 const supertest = getService ( 'supertest' ) ;
1819 const objectRemover = new ObjectRemover ( supertest ) ;
1920
2021 describe ( 'Home page' , function ( ) {
21- before ( async ( ) => {
22- await pageObjects . common . navigateToApp ( 'triggersActions' ) ;
23- } ) ;
22+ describe ( 'Loads the app with limited privileges' , ( ) => {
23+ before ( async ( ) => {
24+ await security . testUser . setRoles ( [ 'alerts_and_actions_role' ] , true ) ;
25+ } ) ;
26+ after ( async ( ) => {
27+ await security . testUser . restoreDefaults ( ) ;
28+ } ) ;
2429
25- after ( async ( ) => {
26- await objectRemover . removeAll ( ) ;
30+ it ( 'Loads the Alerts page' , async ( ) => {
31+ await pageObjects . common . navigateToApp ( 'triggersActions' ) ;
32+ const headingText = await pageObjects . triggersActionsUI . getSectionHeadingText ( ) ;
33+ expect ( headingText ) . to . be ( 'Alerts and Actions' ) ;
34+ } ) ;
2735 } ) ;
2836
29- it ( 'Loads the app' , async ( ) => {
30- await log . debug ( 'Checking for section heading to say Triggers and Actions.' ) ;
37+ describe ( 'Loads the app' , ( ) => {
38+ before ( async ( ) => {
39+ await pageObjects . common . navigateToApp ( 'triggersActions' ) ;
40+ } ) ;
3141
32- const headingText = await pageObjects . triggersActionsUI . getSectionHeadingText ( ) ;
33- expect ( headingText ) . to . be ( 'Alerts and Actions' ) ;
34- } ) ;
42+ after ( async ( ) => {
43+ await objectRemover . removeAll ( ) ;
44+ } ) ;
45+
46+ it ( 'Loads the Alerts page' , async ( ) => {
47+ await log . debug ( 'Checking for section heading to say Triggers and Actions.' ) ;
48+
49+ const headingText = await pageObjects . triggersActionsUI . getSectionHeadingText ( ) ;
50+ expect ( headingText ) . to . be ( 'Alerts and Actions' ) ;
51+ } ) ;
3552
36- describe ( 'Connectors tab' , ( ) => {
37- it ( 'renders the connectors tab' , async ( ) => {
38- // Navigate to the connectors tab
39- await pageObjects . triggersActionsUI . changeTabs ( 'connectorsTab' ) ;
53+ describe ( 'Connectors tab' , ( ) => {
54+ it ( 'renders the connectors tab' , async ( ) => {
55+ // Navigate to the connectors tab
56+ await pageObjects . triggersActionsUI . changeTabs ( 'connectorsTab' ) ;
4057
41- await pageObjects . header . waitUntilLoadingHasFinished ( ) ;
58+ await pageObjects . header . waitUntilLoadingHasFinished ( ) ;
4259
43- // Verify url
44- const url = await browser . getCurrentUrl ( ) ;
45- expect ( url ) . to . contain ( `/connectors` ) ;
60+ // Verify url
61+ const url = await browser . getCurrentUrl ( ) ;
62+ expect ( url ) . to . contain ( `/connectors` ) ;
4663
47- // Verify content
48- await testSubjects . existOrFail ( 'actionsList' ) ;
64+ // Verify content
65+ await testSubjects . existOrFail ( 'actionsList' ) ;
66+ } ) ;
4967 } ) ;
50- } ) ;
5168
52- describe ( 'Alerts tab' , ( ) => {
53- it ( 'renders the alerts tab' , async ( ) => {
54- // Navigate to the alerts tab
55- await pageObjects . triggersActionsUI . changeTabs ( 'alertsTab' ) ;
69+ describe ( 'Alerts tab' , ( ) => {
70+ it ( 'renders the alerts tab' , async ( ) => {
71+ // Navigate to the alerts tab
72+ await pageObjects . triggersActionsUI . changeTabs ( 'alertsTab' ) ;
5673
57- await pageObjects . header . waitUntilLoadingHasFinished ( ) ;
74+ await pageObjects . header . waitUntilLoadingHasFinished ( ) ;
5875
59- // Verify url
60- const url = await browser . getCurrentUrl ( ) ;
61- expect ( url ) . to . contain ( `/alerts` ) ;
76+ // Verify url
77+ const url = await browser . getCurrentUrl ( ) ;
78+ expect ( url ) . to . contain ( `/alerts` ) ;
6279
63- // Verify content
64- await testSubjects . existOrFail ( 'alertsList' ) ;
65- } ) ;
80+ // Verify content
81+ await testSubjects . existOrFail ( 'alertsList' ) ;
82+ } ) ;
6683
67- it ( 'navigates to an alert details page' , async ( ) => {
68- const { body : createdAction } = await supertest
69- . post ( `/api/actions/action` )
70- . set ( 'kbn-xsrf' , 'foo' )
71- . send ( getTestActionData ( ) )
72- . expect ( 200 ) ;
73- objectRemover . add ( createdAction . id , 'action' , 'actions' ) ;
84+ it ( 'navigates to an alert details page' , async ( ) => {
85+ const { body : createdAction } = await supertest
86+ . post ( `/api/actions/action` )
87+ . set ( 'kbn-xsrf' , 'foo' )
88+ . send ( getTestActionData ( ) )
89+ . expect ( 200 ) ;
90+ objectRemover . add ( createdAction . id , 'action' , 'actions' ) ;
7491
75- const { body : createdAlert } = await supertest
76- . post ( `/api/alerts/alert` )
77- . set ( 'kbn-xsrf' , 'foo' )
78- . send ( getTestAlertData ( ) )
79- . expect ( 200 ) ;
80- objectRemover . add ( createdAlert . id , 'alert' , 'alerts' ) ;
92+ const { body : createdAlert } = await supertest
93+ . post ( `/api/alerts/alert` )
94+ . set ( 'kbn-xsrf' , 'foo' )
95+ . send ( getTestAlertData ( ) )
96+ . expect ( 200 ) ;
97+ objectRemover . add ( createdAlert . id , 'alert' , 'alerts' ) ;
8198
82- // refresh to see alert
83- await browser . refresh ( ) ;
99+ // refresh to see alert
100+ await browser . refresh ( ) ;
84101
85- await pageObjects . header . waitUntilLoadingHasFinished ( ) ;
102+ await pageObjects . header . waitUntilLoadingHasFinished ( ) ;
86103
87- // Verify content
88- await testSubjects . existOrFail ( 'alertsList' ) ;
104+ // Verify content
105+ await testSubjects . existOrFail ( 'alertsList' ) ;
89106
90- // click on first alert
91- await pageObjects . triggersActionsUI . clickOnAlertInAlertsList ( createdAlert . name ) ;
107+ // click on first alert
108+ await pageObjects . triggersActionsUI . clickOnAlertInAlertsList ( createdAlert . name ) ;
92109
93- // Verify url
94- expect ( await browser . getCurrentUrl ( ) ) . to . contain ( `/alert/${ createdAlert . id } ` ) ;
110+ // Verify url
111+ expect ( await browser . getCurrentUrl ( ) ) . to . contain ( `/alert/${ createdAlert . id } ` ) ;
112+ } ) ;
95113 } ) ;
96114 } ) ;
97115 } ) ;
0 commit comments