Skip to content

Commit 2160eca

Browse files
authored
Action Center: Actions on System Aggregate Results (#5703)
1 parent af9cacf commit 2160eca

File tree

12 files changed

+1348
-130
lines changed

12 files changed

+1348
-130
lines changed

clients/admin-ui/cypress/e2e/action-center.cy.ts

+127-15
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ describe("Action center", () => {
119119
beforeEach(() => {
120120
cy.visit(`${ACTION_CENTER_ROUTE}/${webMonitorKey}`);
121121
cy.wait("@getSystemAggregateResults");
122+
cy.getByTestId("page-breadcrumb").should("contain", webMonitorKey); // little hack to make sure the webMonitorKey is available before proceeding
122123
});
123124
it("should display a breadcrumb", () => {
124125
cy.getByTestId("page-breadcrumb").within(() => {
@@ -137,8 +138,7 @@ describe("Action center", () => {
137138
// cy.getByTestId("column-data_use").should("exist");
138139
cy.getByTestId("column-locations").should("exist");
139140
cy.getByTestId("column-domains").should("exist");
140-
// TODO: [HJ-343] uncomment when actions column is implemented
141-
// cy.getByTestId("column-actions").should("exist");
141+
cy.getByTestId("column-actions").should("exist");
142142
cy.getByTestId("row-0-col-system_name").within(() => {
143143
cy.getByTestId("change-icon").should("exist"); // new result
144144
cy.contains("Uncategorized assets").should("exist");
@@ -165,6 +165,39 @@ describe("Action center", () => {
165165
"contain",
166166
"analytics.google.com",
167167
);
168+
cy.getByTestId("row-0-col-actions").within(() => {
169+
cy.getByTestId("add-btn").should("be.disabled");
170+
});
171+
});
172+
it("should ignore all assets in an uncategorized system", () => {
173+
cy.getByTestId("row-0-col-actions").within(() => {
174+
cy.getByTestId("ignore-btn").click({ force: true });
175+
});
176+
cy.wait("@ignoreMonitorResultUncategorizedSystem");
177+
cy.getByTestId("success-alert").should(
178+
"contain",
179+
"108 uncategorized assets have been ignored and will not appear in future scans.",
180+
);
181+
});
182+
it("should add all assets in a categorized system", () => {
183+
cy.getByTestId("row-1-col-actions").within(() => {
184+
cy.getByTestId("add-btn").click({ force: true });
185+
});
186+
cy.wait("@addMonitorResultSystem");
187+
cy.getByTestId("success-alert").should(
188+
"contain",
189+
"10 assets from Google Tag Manager have been added to the system inventory.",
190+
);
191+
});
192+
it("should ignore all assets in a categorized system", () => {
193+
cy.getByTestId("row-1-col-actions").within(() => {
194+
cy.getByTestId("ignore-btn").click({ force: true });
195+
});
196+
cy.wait("@ignoreMonitorResultSystem");
197+
cy.getByTestId("success-alert").should(
198+
"contain",
199+
"10 assets from Google Tag Manager have been ignored and will not appear in future scans.",
200+
);
168201
});
169202
it("should navigate to table view on row click", () => {
170203
cy.getByTestId("row-1").click();
@@ -179,18 +212,70 @@ describe("Action center", () => {
179212
});
180213
});
181214

182-
describe("Action center system assets results", () => {
215+
describe("Action center assets uncategorized results", () => {
216+
const webMonitorKey = "my_web_monitor_1";
217+
const systemId = "[undefined]";
218+
beforeEach(() => {
219+
cy.visit(`${ACTION_CENTER_ROUTE}/${webMonitorKey}/${systemId}`);
220+
cy.wait("@getSystemAssetsUncategorized");
221+
cy.getByTestId("page-breadcrumb").should("contain", "Uncategorized");
222+
});
223+
it("should render uncategorized asset results view", () => {
224+
cy.getByTestId("search-bar").should("exist");
225+
cy.getByTestId("pagination-btn").should("exist");
226+
cy.getByTestId("bulk-actions-menu").should("be.disabled");
227+
cy.getByTestId("add-all").should("be.disabled");
228+
229+
// table columns
230+
cy.getByTestId("column-select").should("exist");
231+
cy.getByTestId("column-name").should("exist");
232+
cy.getByTestId("column-resource_type").should("exist");
233+
cy.getByTestId("column-system").should("exist");
234+
// TODO: [HJ-369] uncomment when data use column is implemented
235+
// cy.getByTestId("column-data_use").should("exist");
236+
cy.getByTestId("column-locations").should("exist");
237+
cy.getByTestId("column-domain").should("exist");
238+
// TODO: [HJ-344] uncomment when Discovery column is implemented
239+
/* cy.getByTestId("column-with_consent").should("exist");
240+
cy.getByTestId("row-4-col-with_consent")
241+
.contains("Without consent")
242+
.realHover();
243+
cy.get(".ant-tooltip-inner").should("contain", "January"); */
244+
cy.getByTestId("column-actions").should("exist");
245+
cy.getByTestId("row-0-col-actions").within(() => {
246+
cy.getByTestId("add-btn").should("be.disabled");
247+
cy.getByTestId("ignore-btn").should("exist");
248+
});
249+
});
250+
it("should allow adding a system on uncategorized assets", () => {
251+
cy.getByTestId("row-0-col-system").within(() => {
252+
cy.getByTestId("add-system-btn").click();
253+
});
254+
cy.wait("@getSystemsPaginated");
255+
cy.getByTestId("system-select").antSelect("Fidesctl System");
256+
cy.wait("@setAssetSystem");
257+
cy.getByTestId("system-select").should("not.exist");
258+
cy.getByTestId("success-alert").should(
259+
"contain",
260+
'Browser Request "0d22c925-3a81-4f10-bfdc-69a5d67e93bc" has been assigned to Fidesctl System.',
261+
);
262+
});
263+
});
264+
265+
describe("Action center assets categorized results", () => {
183266
const webMonitorKey = "my_web_monitor_1";
184267
const systemId = "system_key-8fe42cdb-af2e-4b9e-9b38-f75673180b88";
185268
beforeEach(() => {
186269
cy.visit(`${ACTION_CENTER_ROUTE}/${webMonitorKey}/${systemId}`);
187270
cy.wait("@getSystemAssetResults");
271+
cy.getByTestId("page-breadcrumb").should("contain", systemId); // little hack to make sure the systemId is available before proceeding
188272
});
189273
it("should render asset results view", () => {
190274
cy.getByTestId("page-breadcrumb").should("contain", systemId);
191275
cy.getByTestId("search-bar").should("exist");
192276
cy.getByTestId("pagination-btn").should("exist");
193277
cy.getByTestId("bulk-actions-menu").should("be.disabled");
278+
cy.getByTestId("add-all").should("exist");
194279

195280
// table columns
196281
cy.getByTestId("column-select").should("exist");
@@ -213,18 +298,18 @@ describe("Action center", () => {
213298
cy.getByTestId("ignore-btn").should("exist");
214299
});
215300
});
216-
it.skip("should allow adding a system on uncategorized assets", () => {
217-
// TODO: uncategorized assets are not yet available for testing
218-
});
219301
it("should allow editing a system on categorized assets", () => {
220-
cy.getByTestId("page-breadcrumb").should("contain", systemId); // little hack to make sure the systemId is available before proceeding
221302
cy.getByTestId("row-3-col-system").within(() => {
222303
cy.getByTestId("system-badge").click();
223304
});
224305
cy.wait("@getSystemsPaginated");
225306
cy.getByTestId("system-select").antSelect("Fidesctl System");
226307
cy.wait("@setAssetSystem");
227308
cy.getByTestId("system-select").should("not.exist");
309+
cy.getByTestId("success-alert").should(
310+
"contain",
311+
'Browser Request "destination" has been assigned to Fidesctl System.',
312+
);
228313

229314
// Wait for previous UI animations to reset or Cypress chokes on the next part
230315
// eslint-disable-next-line cypress/no-unnecessary-waiting
@@ -243,20 +328,30 @@ describe("Action center", () => {
243328
cy.wait("@setAssetSystem");
244329
cy.getByTestId("success-alert").should("exist");
245330
cy.getByTestId("system-select").should("not.exist");
331+
cy.getByTestId("success-alert").should(
332+
"contain",
333+
'Browser Request "collect" has been assigned to Demo Marketing System.',
334+
);
246335
});
247336
it("should add individual assets", () => {
248337
cy.getByTestId("row-0-col-actions").within(() => {
249338
cy.getByTestId("add-btn").click({ force: true });
250339
});
251340
cy.wait("@addAssets");
252-
cy.getByTestId("success-alert").should("exist");
341+
cy.getByTestId("success-alert").should(
342+
"contain",
343+
'Browser Request "11020051272" has been added to the system inventory.',
344+
);
253345
});
254346
it("should ignore individual assets", () => {
255347
cy.getByTestId("row-0-col-actions").within(() => {
256348
cy.getByTestId("ignore-btn").click({ force: true });
257349
});
258350
cy.wait("@ignoreAssets");
259-
cy.getByTestId("success-alert").should("exist");
351+
cy.getByTestId("success-alert").should(
352+
"contain",
353+
'Browser Request "11020051272" has been ignored and will not appear in future scans.',
354+
);
260355
});
261356
it("should bulk add assets", () => {
262357
cy.getByTestId("bulk-actions-menu").should("be.disabled");
@@ -268,7 +363,10 @@ describe("Action center", () => {
268363
cy.getByTestId("bulk-actions-menu").click();
269364
cy.getByTestId("bulk-add").click();
270365
cy.wait("@addAssets");
271-
cy.getByTestId("success-alert").should("exist");
366+
cy.getByTestId("success-alert").should(
367+
"contain",
368+
"3 assets from Google Tag Manager have been added to the system inventory.",
369+
);
272370
});
273371
it("should bulk ignore assets", () => {
274372
cy.getByTestId("bulk-actions-menu").should("be.disabled");
@@ -280,15 +378,29 @@ describe("Action center", () => {
280378
cy.getByTestId("bulk-actions-menu").click();
281379
cy.getByTestId("bulk-ignore").click();
282380
cy.wait("@ignoreAssets");
283-
cy.getByTestId("success-alert").should("exist");
381+
cy.getByTestId("success-alert").should(
382+
"contain",
383+
"3 assets from Google Tag Manager have been ignored and will not appear in future scans.",
384+
);
284385
});
285-
it.skip("should add all assets", () => {
286-
// TODO: [HJ-343] unskip when add all is implemented
386+
it("should add all assets", () => {
387+
cy.intercept(
388+
"POST",
389+
"/api/v1/plus/discovery-monitor/*/promote*",
390+
(req) => {
391+
req.on("response", (res) => {
392+
res.setDelay(100); // slight delay allows us to check for the loading state below
393+
});
394+
},
395+
).as("slowRequest");
287396
cy.getByTestId("add-all").click();
288397
cy.getByTestId("add-all").should("have.class", "ant-btn-loading");
289-
cy.wait("@addAssets");
398+
cy.wait("@slowRequest");
290399
cy.url().should("not.contain", systemId);
291-
cy.getByTestId("success-alert").should("exist");
400+
cy.getByTestId("success-alert").should(
401+
"contain",
402+
"11 assets from Google Tag Manager have been added to the system inventory.",
403+
);
292404
});
293405
});
294406
});

0 commit comments

Comments
 (0)