public void RT08030_ItemReferenceToIbeaconApp2()
        {
            Place place1 = null, place2 = null, place3 = null;
            Item  item1 = null, item2 = null, item3 = null;

            Parallel.Invoke(
                () => place1 = AddPlaceIbeacon(PlaceStatus.Any, pageToBeOpened: 0, isCreateNewPlace: true),
                () => place2 = AddPlaceIbeacon(PlaceStatus.Any, pageToBeOpened: 0, isCreateNewPlace: true),
                () => place3 = AddPlaceIbeacon(PlaceStatus.Deleted, pageToBeOpened: 0),
                () => AddAppIbeacon(TestConfig.IbeaconAppVersions[1], true),
                () => ItemApi.DeleteItems(ItemType.Poi, CurrentTenant)
                );
            Parallel.Invoke(
                () => item1 = AddItem(ItemType.PorscheCar, isAddNew: true),
                () => item2 = AddItem(ItemType.UsedCar, isAssignImage: true, isAddNew: true),
                () => AddItem(ItemType.EmailTemplate, isAddNew: true),
                () => item3 = AddItem(ItemType.Poi)
                );
            ItemApi.DeleteItem(item3.Id);
            TestStart();

            OpenEntityPage(place1);
            EditForm();
            MouseOver(PageFooter.AddPlaceSubMenu);
            Click(PageFooter.AddAppInPlacesButton);
            Click(AppsPage.TableCellIbeaconApp);
            ClickUntilShown(PlacesPage.AppsSectionTableRowDetailsPoiDropDown, CommonElement.DropDownInput);
            SendText(CommonElement.DropDownInput, item3.LangJsonData.EnJson.Title);
            Assert.IsTrue(IsElementNotFoundQuickly(CommonElement.DropDownOptionList),
                          $@"Apps: Deleted item '{item3.LangJsonData.EnJson.Title}' is displayed in POI field dropdown list");

            Click(PlacesPage.Title);
            Click(PlacesPage.AppsSectionTableRowDetailsPoiDetailsButton);
            Assert.IsTrue(IsElementFoundQuickly(PlacesPage.NoItemsToBeAddedDialog),
                          @"Dialog 'No items to be added' should be displayed");

            Click(PlacesPage.OkButton);
            Click(PlacesPage.AppsSectionTableRowDetailsCarDetailsButton);
            Assert.IsTrue(IsElementFound(string.Format(ItemsPage.TableRowByTitle, item1.LangJsonData.EnJson.Title)) &&
                          IsElementFoundQuickly(string.Format(ItemsPage.TableRowByTitle, item2.LangJsonData.EnJson.Title)),
                          $"Items {item1.LangJsonData.EnJson.Title} and {item2.LangJsonData.EnJson.Title} should be in list");

            Click(string.Format(ItemsPage.TableRowByTitle, item2.LangJsonData.EnJson.Title));

            SubmitForm();
            OpenEntityPage(item2);
            Assert.IsTrue(IsElementFound(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place1.Title)),
                          $"References: Field Places should contain place {place1.Title}");

            Assert.IsTrue(IsElementNotFound(ItemsPage.AssignedPlacesPlaceReadOnly),
                          "Assigned places: section should be empty");

            EditForm();
            ClickUntilShown(ItemsPage.AssignedPlacesAddButton, ItemsPage.AssignedPlacesPlaceDropDown);
            ClickUntilShown(ItemsPage.AssignedPlacesPlaceDropDown, CommonElement.DropDownOptionList);
            Assert.IsTrue(IsElementNotFoundQuickly(string.Format(CommonElement.DropDownOption, place1.Title)),
                          $"Place {place1.Title} should not be available in dropdown");
            Assert.IsTrue(IsElementFoundQuickly(string.Format(CommonElement.DropDownOption, place2.Title)),
                          $"Place {place2.Title} should be available in dropdown");

            DropDownSelect(ItemsPage.AssignedPlacesPlaceDropDown, place2.Title);

            Click(ItemsPage.PicturesSectionAddButton);
            Click(ItemsPage.PicturesSectionUploadButton);
            FileManager.Upload(TestConfig.ImageCar);
            SubmitForm();
            Assert.IsTrue(IsElementFound(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place1.Title)) &&
                          IsElementFoundQuickly(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place2.Title)),
                          $"References: Field Places should contain places {place1.Title} and {place2.Title}");

            Click(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place1.Title));
            EditForm();
            Click(PlacesPage.AppsSectionTableRow1);
            Click(PlacesPage.AppsSectionTableRow1DeleteButton);
            SubmitForm();
            OpenEntityPage(item2);
            Assert.IsTrue(IsElementNotFound(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place1.Title)),
                          $"References: Field Places should not contain place {place1.Title}");
            Assert.IsTrue(IsElementNotFoundQuickly(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place3.Title)),
                          $"References: Field Places should not contain place {place3.Title}");
            Assert.IsTrue(IsElementFoundQuickly(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place2.Title)),
                          $"References: Field Places should contain place {place2.Title}");

            OpenEntityPage(item1);
            EditForm();
            ClickUntilShown(ItemsPage.AssignedPlacesAddButton, ItemsPage.AssignedPlacesPlaceDropDown);
            ClickUntilShown(ItemsPage.AssignedPlacesPlaceDropDown, CommonElement.DropDownOptionList);
            Assert.IsTrue(IsElementFound(string.Format(CommonElement.DropDownOption, place1.Title)) &&
                          IsElementFoundQuickly(string.Format(CommonElement.DropDownOption, place2.Title)),
                          $"Assigned places: Place dropdown should contain places {place1.Title} and {place2.Title}");

            DropDownSelect(ItemsPage.AssignedPlacesPlaceDropDown, place2.Title);
            SubmitForm();
            OpenEntityPage(place2);
            Assert.IsTrue(
                IsElementFound(string.Format(PlacesPage.ItemsSectionItemByTitle, item1.LangJsonData.EnJson.Title)),
                $"Items: Should contain item {item1.LangJsonData.EnJson.Title}");
            Assert.IsTrue(
                IsElementFoundQuickly(string.Format(PlacesPage.ItemsSectionItemByTitle, item2.LangJsonData.EnJson.Title)),
                $"Items: Should contain item {item2.LangJsonData.EnJson.Title}");

            EditForm();
            MouseOver(PageFooter.AddPlaceSubMenu);
            Click(PageFooter.AddAppInPlacesButton);
            Click(AppsPage.TableRowIbeaconApp);
            ClickUntilShown(PlacesPage.AppsSectionTableRowDetailsCarDetailsButton, PlacesPage.SelectItemDialog);
            Assert.IsTrue(
                IsElementFoundQuickly(string.Format(ItemsPage.TableRowByTitle, item1.LangJsonData.EnJson.Title)),
                $"Item list: Should contain item {item1.LangJsonData.EnJson.Title}");
            Assert.IsTrue(
                IsElementFoundQuickly(string.Format(ItemsPage.TableRowByTitle, item2.LangJsonData.EnJson.Title)),
                $"Item list: Should contain item {item2.LangJsonData.EnJson.Title}");

            Click(string.Format(ItemsPage.TableRowByTitle, item1.LangJsonData.EnJson.Title));
            SubmitForm();
            Click(PageFooter.DuplicateButton);
            var title = $"Auto test {RandomNumber}";

            SendText(ItemsPage.Title, title);
            SubmitForm();
            Assert.IsTrue(
                IsElementFoundQuickly(string.Format(PlacesPage.ItemsSectionItemByTitle, item1.LangJsonData.EnJson.Title)),
                $"Items: Should contain item {item1.LangJsonData.EnJson.Title}");
            Assert.IsTrue(
                IsElementFoundQuickly(string.Format(PlacesPage.ItemsSectionItemByTitle, item2.LangJsonData.EnJson.Title)),
                $"Items: Should contain item {item2.LangJsonData.EnJson.Title}");
            Click(PlacesPage.AppsSectionTableRow1);
            Assert.IsTrue(
                AreElementsContainText(PlacesPage.AppsSectionTableRowDetailsCarReadOnly, item1.LangJsonData.EnJson.Title),
                $"Apps section: Car field should contain item {item1.LangJsonData.EnJson.Title}");

            OpenEntityPage(item2);
            Assert.IsTrue(AreElementsContainText(ItemsPage.AssignedPlacesPlaceReadOnly, place2.Title) &&
                          AreElementsContainText(ItemsPage.AssignedPlacesPlaceReadOnly, title),
                          $"Assigned places: should contain both {place2.Title} and its duplicate {title}");
            Assert.IsTrue(AreElementsContainText(ItemsPage.ReferencesSectionPlaces, place2.Title) &&
                          AreElementsContainText(ItemsPage.ReferencesSectionPlaces, title),
                          $"References: Field Places should contain both {place2.Title} and its duplicate {title}");
        }
        // daily report emails send at 8:00 AM (Europe/Kiev),
        // this test needs some time to prepare environment, so run it before 7:59 AM
        public void RT07310_FollowItemsEmailReport()
        {
            if (DateTime.Now.TimeOfDay > new TimeSpan(07, 59, 00))
            {
                Assert.Inconclusive("Canceled run. The test should be started before 07:59 AM");
            }
            CurrentTenant = TenantTitle.reportitems;
            var userProperties = UserDirectoryApi.GetUserData(TestConfig.NewUser);

            if (userProperties == null)
            {
                AccountApi.CreateNewAccount(TestConfig.NewUser);
                UserDirectoryApi.SetUserStatus(TestConfig.NewUser, UserStatus.Active);
                UserDirectoryApi.AssignRolesToUser(TestConfig.NewUser,
                                                   new [] { UserRole.CxmAdmin });
                userProperties = UserDirectoryApi.GetUserData(TestConfig.NewUser);
            }
            CurrentUser = TestConfig.NewUser;
            const string itemTitle = "Daily report template";
            var          itemsReportEmailSubject = $"Items report {CurrentTenantCode}";
            Item         item = null, custItem1 = null, custItem2 = null;
            var          app       = AddAppIbeacon(TestConfig.IbeaconAppVersions[1], true);

            Parallel.Invoke(
                () => item = ItemApi.SearchItem(itemTitle),
                () => AddPlaceNoType(PlaceStatus.NoDevice, isAddChild: false, pageToBeOpened: 0,
                                     isCreateNewPlace: true),
                () => AddItem(ItemType.Employee),
                () => AddItem(ItemType.CustomerProfile, isAddNew: true),
                () => AddItem(ItemType.Car),
                () => custItem1 = AddItem(ItemType.CustomerProfile, isAddNew: true),
                () => custItem2 = AddItem(ItemType.CustomerProfile, isAddNew: true),
                () => ItemApi.FollowItems(ItemType.CustomerProfile),
                () => ItemApi.FollowItems(ItemType.Car),
                () => ItemApi.FollowItems(ItemType.Employee)
                );
            Assert.IsNotNull(item,
                             $@"Item '{itemTitle}' not found. Is iBeacon app imported and available on tenant " +
                             $"{CurrentTenantCode}?");
            AddItemToIbeaconApp(app, "$.texts.emails.itemsFollowReportTemplate", item);

            Parallel.Invoke(
                () => _mm.InboxHousekeeping(_mm.ClientCxM),
                () => ItemApi.DeleteItem(custItem1.Id),
                () => ItemApi.SaveItem(custItem2),
                () => AddItem(ItemType.PorscheCar, isAddNew: true),
                () => AddItem(ItemType.CustomerProfile, isAddNew: true),
                () => AddItem(ItemType.UsedCar, isAddNew: true),
                () => AddItem(ItemType.ServiceBooking, isAddNew: true)
                );

            // it's time to start checking mail box
            WaitForTimeOfDay(new TimeSpan(08, 00, 00));
            // expects a new email within 600 seconds
            var gotNewMail         = WaitForNewMail(_mm.ClientCxM, 600);

            Assert.IsTrue(gotNewMail, $"There is no new daily report found in mailbox {TestConfig.MailServerLogin}");

            var hasUserName        = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                $"{userProperties.GivenName} {userProperties.FamilyName}");

            Assert.IsTrue(hasUserName, "Item report email has no user firstname or lastname");

            var tenantTitle        = CurrentTenant.ToString();
            var hasTenantTitle     = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                tenantTitle);

            Assert.IsTrue(hasTenantTitle, $@"Item report email has no tenant title '{tenantTitle}'");

            var custProfileContent = $"{ItemTypeCustomerProfile}: 1 new {ItemTypeCustomerProfile}, " +
                                     $"1 updated {ItemTypeCustomerProfile}, 1 deleted {ItemTypeCustomerProfile}";
            var hasCustProfileInfo = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                custProfileContent);

            Assert.IsTrue(hasCustProfileInfo, $@"Item report email has no text: '{custProfileContent}'");

            var hasPorscheCarsAndUsedCars = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                $"{ItemTypePorscheCar}s, {ItemTypeUsedCar}s");

            Assert.IsTrue(hasPorscheCarsAndUsedCars,
                          "Item report email has no info about updated item types: " +
                          $@"'{ItemTypePorscheCar}s, {ItemTypeUsedCar}s'");

            var hasPorscheCarsInfo = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                $"{ItemTypePorscheCar}: 1 new {ItemTypePorscheCar}");

            Assert.IsTrue(hasPorscheCarsInfo,
                          $@"Item report email has no info about followed item: '{ItemTypePorscheCar}: 1 new " +
                          $@"{ItemTypePorscheCar}'");

            var hasUsedCarsInfo = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                $"{ItemTypeUsedCar}: 1 new {ItemTypeUsedCar}");

            Assert.IsTrue(hasUsedCarsInfo,
                          $@"Item report email has no info about followed item: '{ItemTypeUsedCar}: 1 new " +
                          $@"{ItemTypeUsedCar}'");

            var hasNoEmployeeInfo = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                ItemTypeEmployee);

            Assert.IsTrue(hasNoEmployeeInfo,
                          $"Item report email must contain no {ItemTypeEmployee} items info");

            var hasNoServiceBookingInfo = _mm.IsMailBodyContainsText(
                _mm.ClientCxM,
                itemsReportEmailSubject,
                ItemTypeServiceBooking);

            Assert.IsTrue(hasNoServiceBookingInfo,
                          $"Item report email must contain no {ItemTypeServiceBooking} items info");
        }