ocket8888 commented on code in PR #6805:
URL: https://github.com/apache/trafficcontrol/pull/6805#discussion_r864221318


##########
experimental/traffic-portal/src/app/core/ds-card/ds-card.component.html:
##########
@@ -57,7 +57,7 @@ <h3 *ngIf="deliveryService.exampleURLs">URLs</h3>
                </div>
        </mat-card-content>
        <mat-card-actions *ngIf="open">
-               <a mat-raised-button color="accent" class="view-details" 
routerLink="/core/deliveryservice/{{deliveryService.id}}" title="View Details" 
aria-label="View Details">
+               <a id="{{deliveryService.xmlId}}Details" mat-raised-button 
color="accent" class="view-details" 
routerLink="/core/deliveryservice/{{deliveryService.id}}" title="View Details" 
aria-label="View Details">

Review Comment:
   I have a similar complaint here; the equivalent selector being 
`mat-card#XMLID mat-card-actions > a`.



##########
experimental/traffic-portal/src/app/core/ds-card/ds-card.component.html:
##########
@@ -11,15 +11,15 @@
 See the License for the specific language governing permissions and
 limitations under the License.
 -->
-<mat-card [ngClass]="{'inactive': !deliveryService.active, 'open': open, 
'first': first, 'last': last}">
+<mat-card id="{{deliveryService.xmlId}}" [ngClass]="{'inactive': 
!deliveryService.active, 'open': open, 'first': first, 'last': last}">
        <mat-card-title-group (click)="toggle()">
                
<mat-card-title>{{deliveryService.displayName}}{{deliveryService.active ? '' : 
' (inactive)'}}
                        <a href="{{deliveryService.infoUrl}}" 
*ngIf="deliveryService.infoUrl" class="color-accent-inverted info" 
rel="noopener" target="_blank" title="More Information"><fa-icon 
[icon]="infoIcon"></fa-icon></a>
                </mat-card-title>
                <mat-card-subtitle>{{deliveryService.type ? 
deliveryService.type : ''}}</mat-card-subtitle>
        </mat-card-title-group>
        <mat-card-content class="card-content" *ngIf="open" [@enterAnimation]>
-               <div>
+               <div id="{{deliveryService.xmlId}}Content">

Review Comment:
   I don't feel good about adding classes and IDs just for testing to look for 
- I think the card having an ID overall is actually kinda a good idea in 
general so that maybe people could link to a specific DS (although I imagine in 
general they'd link to a page where the search filters down to just that DS, 
but still) but this one doesn't seem to have any utility beyond just being 
shorter to type than `mat-card#XMLID mat-card-content > div`.



##########
experimental/traffic-portal/nightwatch/tests/_bootstrap.spec.ts:
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import * as https from "https";
+
+import axios from "axios";
+import {AugmentedBrowser} from "nightwatch/globals/globals";
+import {
+       CDN,
+       GeoLimit, GeoProvider, LoginRequest,
+       Protocol,
+       RequestDeliveryService,
+       ResponseCDN,
+       ResponseDeliveryService
+} from "trafficops-types";
+
+/**
+ * Creates data necessary for the e2e tests, currently just a CDN, and a DS
+ *
+ * @param augBrowser The browser object
+ * @returns Created Delivery Service
+ */
+async function createData(augBrowser: AugmentedBrowser): 
Promise<ResponseDeliveryService> {
+       const apiUrl = 
`${augBrowser.globals.trafficOpsURL}/api/${augBrowser.globals.apiVersion}`;
+       const client = axios.create({
+               httpsAgent: new https.Agent({
+                       rejectUnauthorized: false
+               })
+       });
+       let accessToken = "";
+       const loginReq: LoginRequest = {
+               p: augBrowser.globals.adminPass,
+               u: augBrowser.globals.adminUser
+       };
+       try {
+               const resp = await client.post(`${apiUrl}/user/login`, 
JSON.stringify(loginReq));
+               if(resp.headers["set-cookie"]) {
+                       for (const cookie of resp.headers["set-cookie"]) {
+                               if(cookie.indexOf("access_token") > -1) {
+                                       accessToken = cookie;
+                                       break;
+                               }
+                       }
+               }
+       } catch (e) {
+               return Promise.reject(e);
+       }
+       if(accessToken === "") {
+               return Promise.reject("Access token is not set");
+       }
+       client.defaults.headers.common = { Cookie: accessToken };
+
+       const cdn: CDN = {
+               dnssecEnabled: false, domainName: "tests.com", name: "testCDN"
+       };
+       let respCDN: ResponseCDN;
+       try {
+               let resp = await client.post(`${apiUrl}/cdns`, 
JSON.stringify(cdn));
+               respCDN = resp.data.response;
+
+               const ds: RequestDeliveryService = {
+                       active: false,
+                       cacheurl: null,
+                       cdnId: respCDN.id,
+                       displayName: "test DS",
+                       dscp: 0,
+                       ecsEnabled: false,
+                       edgeHeaderRewrite: null,
+                       fqPacingRate: null,
+                       geoLimit: GeoLimit.NONE,
+                       geoProvider: GeoProvider.MAX_MIND,
+                       httpBypassFqdn: null,
+                       infoUrl: null,
+                       initialDispersion: 1,
+                       ipv6RoutingEnabled: false,
+                       logsEnabled: false,
+                       maxOriginConnections: 0,
+                       maxRequestHeaderBytes: 0,
+                       midHeaderRewrite: null,
+                       missLat: 0,
+                       missLong: 0,
+                       multiSiteOrigin: false,
+                       orgServerFqdn: "http://test.com";,
+                       profileId: 1,
+                       protocol: Protocol.HTTP,
+                       qstringIgnore: 0,
+                       rangeRequestHandling: 0,
+                       regionalGeoBlocking: false,
+                       remapText: null,
+                       routingName: "test",
+                       signed: false,
+                       tenantId: 1,
+                       typeId: 1,
+                       xmlId: "testDS"
+               };
+               resp = await client.post(`${apiUrl}/deliveryservices`, 
JSON.stringify(ds));
+               const respDS: ResponseDeliveryService = resp.data.response[0];
+
+               return Promise.resolve(respDS);
+       } catch(e) {
+               return Promise.reject(e);
+       }
+}
+
+describe("Bootstrap Spec", () => {
+       it("Create Data", async (): Promise<void> => {
+               const augBrowser = browser as AugmentedBrowser;
+               await createData(augBrowser).then(ds => {
+                       console.log(`Successfully created DS 
'${ds.displayName}'`);
+               }).catch(err => {
+                       augBrowser.assert.fail(err, null, "Exception occurred 
while creating data");
+               }).finally(() => {
+                       augBrowser.end();
+               });
+       });
+});

Review Comment:
   Should this be in nightwatch's global `before` to run before all specs?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to