Merge "Adding a few tests in the EI part of the frontend"
diff --git a/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.spec.ts b/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.spec.ts
index 927ab9d..7ccb80d 100644
--- a/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.spec.ts
+++ b/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.spec.ts
@@ -417,6 +417,77 @@
         });
         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", () => {
@@ -459,7 +530,6 @@
               });
             });
         });
-
         discardPeriodicTasks();
       }));
     });
diff --git a/webapp-frontend/src/app/ei-coordinator/producers-list/producers-list.component.spec.ts b/webapp-frontend/src/app/ei-coordinator/producers-list/producers-list.component.spec.ts
index f67939e..77f1cb8 100644
--- a/webapp-frontend/src/app/ei-coordinator/producers-list/producers-list.component.spec.ts
+++ b/webapp-frontend/src/app/ei-coordinator/producers-list/producers-list.component.spec.ts
@@ -198,6 +198,49 @@
         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);
+      });
     });
   });
 });