Adding a few tests in the EI part of the frontend 95/5995/1
authormaximesson <maxime.bonneau@est.tech>
Tue, 4 May 2021 08:18:23 +0000 (10:18 +0200)
committermaximesson <maxime.bonneau@est.tech>
Tue, 4 May 2021 08:18:27 +0000 (10:18 +0200)
Change-Id: I60df9d915c1242726cd7d4f739665226a183d789
Issue-ID: NONRTRIC-505
Signed-off-by: maximesson <maxime.bonneau@est.tech>
webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.spec.ts
webapp-frontend/src/app/ei-coordinator/producers-list/producers-list.component.spec.ts

index 927ab9d..7ccb80d 100644 (file)
@@ -417,6 +417,77 @@ describe("JobsListComponent", () => {
         });
         discardPeriodicTasks();
       }));
         });
         discardPeriodicTasks();
       }));
+
+      it("should not sort when clicking on filtering box", fakeAsync(() => {
+        setServiceSpy();
+        component.ngOnInit();
+        tick(0);
+
+        loader
+          .getHarness(MatTableHarness.with({ selector: "#jobsTable" }))
+          .then((loadTable) => {
+            loadTable.getRows().then((jobRows) => {
+              let jobIds, jobTypeIds, jobOwner, jobTargetUri: String[];
+              for (let i = 0; i < jobRows.length; i++) {
+                jobRows[i].getCellTextByColumnName().then((value) => {
+                  jobIds.push(value[0]);
+                  jobTypeIds.push(value[2]);
+                  jobOwner.push(value[3]);
+                  jobTargetUri.push(value[4]);
+                });
+              };
+              loader
+                .getHarness(MatInputHarness.with({ selector: "#jobIdFilter"}))
+                .then((idFilter) => {
+                  let unfilteredJobIds: String[];
+                  idFilter.setValue("");
+                  for (let i = 0; i < jobRows.length; i++) {
+                    jobRows[i].getCellTextByColumnName().then((value) => {
+                      unfilteredJobIds.push(value[0]);
+                    });
+                  };
+                  expect(unfilteredJobIds).toBe(jobIds);
+                });
+              loader
+                .getHarness(MatInputHarness.with({ selector: "#jobTypeIdFilter"}))
+                .then((idFilter) => {
+                  let unfilteredJobTypeIds: String[];
+                  idFilter.setValue("");
+                  for (let i = 0; i < jobRows.length; i++) {
+                    jobRows[i].getCellTextByColumnName().then((value) => {
+                      unfilteredJobTypeIds.push(value[2]);
+                    });
+                  };
+                  expect(unfilteredJobTypeIds).toBe(jobTypeIds);
+                });
+              loader
+                .getHarness(MatInputHarness.with({ selector: "#jobOwnerFilter"}))
+                .then((idFilter) => {
+                  let unfilteredJobOwner: String[];
+                  idFilter.setValue("");
+                  for (let i = 0; i < jobRows.length; i++) {
+                    jobRows[i].getCellTextByColumnName().then((value) => {
+                      unfilteredJobOwner.push(value[3]);
+                    });
+                  };
+                  expect(unfilteredJobOwner).toBe(jobOwner);
+                });
+              loader
+                .getHarness(MatInputHarness.with({ selector: "#jobTargetUriFilter"}))
+                .then((idFilter) => {
+                  let unfilteredJobTargetUri: String[];
+                  idFilter.setValue("");
+                  for (let i = 0; i < jobRows.length; i++) {
+                    jobRows[i].getCellTextByColumnName().then((value) => {
+                      unfilteredJobTargetUri.push(value[4]);
+                    });
+                  };
+                  expect(unfilteredJobTargetUri).toBe(jobTargetUri);
+                });
+            });
+          });
+          discardPeriodicTasks();
+      }));
     });
 
     describe("#paging", () => {
     });
 
     describe("#paging", () => {
@@ -459,7 +530,6 @@ describe("JobsListComponent", () => {
               });
             });
         });
               });
             });
         });
-
         discardPeriodicTasks();
       }));
     });
         discardPeriodicTasks();
       }));
     });
index f67939e..77f1cb8 100644 (file)
@@ -198,6 +198,49 @@ describe('ProducersListComponent', () => {
         prodRows = await producersTable.getRows();
         expect(await prodRows[prodRows.length - 1].getCellTextByColumnName()).toEqual(expectedProducer1Row);
       });
         prodRows = await producersTable.getRows();
         expect(await prodRows[prodRows.length - 1].getCellTextByColumnName()).toEqual(expectedProducer1Row);
       });
+
+      it('should not sort when clicking on the filter input field', async () => {
+        setServiceSpy();
+        let producersTable = await loader.getHarness(MatTableHarness.with({ selector: '#producersTable' }));
+        let producerRows = await producersTable.getRows();
+        let producerIdFilter = await loader.getHarness(MatInputHarness.with({ selector: '#producerIdFilter'}));
+        let producerTypesFilter = await loader.getHarness(MatInputHarness.with({ selector: '#producerTypesFilter'}));
+        let producerStatusFilter = await loader.getHarness(MatInputHarness.with({ selector: '#producerStatusFilter'}));
+        let producerIds, producerTypes, producerStatuses: String[];
+        let unfilteredProducerIds, unfilteredProducerTypes, unfilteredProducerStatuses: String[];
+
+        for (let i = 0; i < producerRows.length; i++) {
+          producerRows[i].getCellTextByColumnName().then((value) => {
+            producerIds.push(value[0]);
+            producerTypes.push(value[1]);
+            producerStatuses.push(value[2]);
+          });
+        };
+
+        producerIdFilter.setValue("");
+        for (let i = 0; i < producerRows.length; i++) {
+          producerRows[i].getCellTextByColumnName().then((value) => {
+            unfilteredProducerIds.push(value[0]);
+          });
+        };
+        expect(unfilteredProducerIds).toBe(producerIds);
+
+        producerTypesFilter.setValue("");
+        for (let i = 0; i < producerRows.length; i++) {
+          producerRows[i].getCellTextByColumnName().then((value) => {
+            unfilteredProducerTypes.push(value[1]);
+          });
+        };
+        expect(unfilteredProducerTypes).toBe(producerTypes);
+
+        producerStatusFilter.setValue("");
+        for (let i = 0; i < producerRows.length; i++) {
+          producerRows[i].getCellTextByColumnName().then((value) => {
+            unfilteredProducerStatuses.push(value[2]);
+          });
+        };
+        expect(unfilteredProducerStatuses).toBe(producerStatuses);
+      });
     });
   });
 });
     });
   });
 });