Ejemplo n.º 1
0
 public void BeginFixtureTests()
 {
     IsEachTestInNewBrowser = false;
     _admin2 = UserDirectoryApi.GetUserData(TestConfig.AdminUser2);
     TestConfig.AdminUser2.GivenName  = _admin2.GivenName;
     TestConfig.AdminUser2.FamilyName = _admin2.FamilyName;
     TestConfig.AdminUser2.Company    = _admin2.Company;
     TestConfig.AdminUser2.Phone      = _admin2.Phone;
 }
        public void RT04450_CheckPlaceTimestamps()
        {
            TestStart();
            var place = AddPlaceNoType(PlaceStatus.Active, isCreateNewPlace: true);

            EditForm();
            Click(PlacesPage.PlaceMapUploadButton);
            FileManager.Upload(TestConfig.Image138);
            SendText(PlacesPage.PlaceWidth, "10");
            SendText(PlacesPage.ToleranceRadius, "20");
            SendText(PlacesPage.Position, "50.3333, 40.5555");
            SubmitForm();
            var positionParent        = GetValue(PlacesPage.PositionReadOnly);
            var toleranceRadiusParent = GetValue(PlacesPage.ToleranceRadiusReadOnly);

            OpenPlacesPage();
            Click(PageFooter.AddPlaceButton);
            DropDownSelect(PlacesPage.DeviceTypeDropDown, DeviceTypeIbeacon);
            var placeIbeaconTitle = $"Auto test {RandomNumber}";

            SendText(PlacesPage.Title, placeIbeaconTitle);
            DropDownSelect(PlacesPage.TimezoneDropDown, TimezoneKiev);
            OpenDevicesFromPlace();
            Click(Devices.TableRow); // any existing device
            SubmitForm();
            var created1  = GetTimestamp(PlacesPage.Created, true);
            var modified1 = GetTimestamp(PlacesPage.Modified);
            var since1    = GetTimestamp(PlacesPage.Since);

            Assert.IsTrue(Math.Abs((created1.Item1 - modified1.Item1).Seconds) <= 10,
                          "Created timestamp data should be equal to Modified field data");
            Assert.IsTrue(Math.Abs((created1.Item1 - since1.Item1).Seconds) <= 10,
                          "Since should display a timestamp that equals Created and Modified");
            var userProperties = UserDirectoryApi.GetUserData(TestConfig.AdminUser);
            var userName       = $" ({userProperties.GivenName} {userProperties.FamilyName})";

            Assert.IsTrue(created1.Item2.Contains(userName),
                          "Created should contain current user firstname and lastname");
            Assert.IsTrue(modified1.Item2.Contains(userName),
                          "Modified should contain current user firstname and lastname");

            WaitTime(2);
            EditForm();
            var newTitle = $"Auto test {RandomNumber}";

            SendText(PlacesPage.Title, newTitle);
            SubmitForm();
            var created2  = GetTimestamp(PlacesPage.Created, true);
            var modified2 = GetTimestamp(PlacesPage.Modified);
            var since2    = GetTimestamp(PlacesPage.Since);

            Assert.IsTrue(created1.Equals(created2), "Created timestamp and user data should never change");
            Assert.IsTrue(since1.Item1 == since2.Item1, "Since should not change after this submit");
            Assert.IsTrue(modified2.Item1 > modified1.Item1,
                          "After submit Modified should be equal to current time");

            WaitTime(2);
            EditForm();
            OpenDevicesFromPlace();
            Click(Devices.ClearSelectionButton);
            SubmitForm();
            var created3  = GetTimestamp(PlacesPage.Created, true);
            var modified3 = GetTimestamp(PlacesPage.Modified);
            var since3    = GetTimestamp(PlacesPage.Since);

            Assert.IsTrue(created1.Equals(created3), "Created timestamp and user data should never change");
            Assert.IsTrue(modified3.Item1 > modified2.Item1,
                          "After submit Modified should be equal to current time");
            Assert.IsTrue(Math.Abs((modified3.Item1 - since3.Item1).Seconds) <= 10,
                          "After submit Since should be equal to current time");
            Assert.IsTrue(modified3.Item2.Contains(userName),
                          "Modified should contain current user firstname and lastname");

            WaitTime(2);
            EditForm();
            OpenDevicesFromPlace();
            Click(Devices.TableRow); // any existing device
            SubmitForm();
            var created4  = GetTimestamp(PlacesPage.Created, true);
            var modified4 = GetTimestamp(PlacesPage.Modified);
            var since4    = GetTimestamp(PlacesPage.Since);

            Assert.IsTrue(created1.Equals(created4), "Created timestamp and user data should never change");
            Assert.IsTrue(modified4.Item1 > modified3.Item1,
                          "After submit Modified should be equal to current time");
            Assert.IsTrue(since4.Item1 > since3.Item1, "After submit Since should be equal to current time");
            Assert.IsTrue(modified4.Item2.Contains(userName),
                          "Modified should contain current user firstname and lastname");

            WaitTime(2);
            EditForm();
            DropDownSelect(PlacesPage.TimezoneDropDown, TimezoneLondon);
            SubmitForm();
            var since     = CleanUpString(GetValue(PlacesPage.Since, true));
            var created5  = GetTimestamp(PlacesPage.Created);
            var modified5 = GetTimestamp(PlacesPage.Modified);
            var since5    = GetTimestamp(PlacesPage.Since);
            var timeSince = ((DateTimeOffset)Convert.ToDateTime(since.Substring(since.IndexOf(' '))))
                            .ToOffset(TimeZoneInfo.Local.BaseUtcOffset.Subtract(
                                          TimeSpan.FromHours(DateTime.Now.IsDaylightSavingTime() ? 0 : 1)));

            Assert.IsTrue(created1.Equals(created5), "Created timestamp and user data should never change");
            Assert.IsTrue(modified5.Item1 > modified4.Item1, "After submit Modified should be equal to current time");
            Assert.IsTrue(Math.Abs((since5.Item1 - timeSince).Seconds) <= 10,
                          "After submit Since should be equal to London time");
            Assert.IsTrue(modified5.Item2.Contains(userName), "Modified should contain current user firstname and lastname");

            OpenEntityPage(place);
            MouseOver(PageFooter.AddPlaceSubMenu);
            Click(PageFooter.AddExistingPlaceAsChildButton);
            Click(string.Format(PlacesPage.TableRowByTitle, newTitle));
            SubmitForm();
            OpenPlacesPage();
            SetFilter(newTitle);
            Click(string.Format(PlacesPage.TableRowByTitle, newTitle));
            var created6  = GetTimestamp(PlacesPage.Created, true);
            var modified6 = GetTimestamp(PlacesPage.Modified);
            var since6    = GetTimestamp(PlacesPage.Since);

            Assert.IsTrue(created1.Equals(created6), $"Created for iBeacon place {newTitle} has changed");
            Assert.IsTrue(modified6.Item1 == modified5.Item1, $"Modified for iBeacon place {newTitle} has changed");
            Assert.IsTrue(since6.Item1 == since5.Item1, $"Since for iBeacon place {newTitle} has changed");
            Assert.IsTrue(GetValue(PlacesPage.TimezoneReadOnly).Contains(TimezoneLondon),
                          $"Timezone for iBeacon place {newTitle} has changed");

            Click(PageFooter.DuplicateButton);
            var titleDuplicate = $"Auto test {RandomNumber}";

            SendText(PlacesPage.Title, titleDuplicate);
            SubmitForm();
            since = CleanUpString(GetValue(PlacesPage.Since, true));
            var created7  = GetTimestamp(PlacesPage.Created);
            var modified7 = GetTimestamp(PlacesPage.Modified);
            var since7    = GetTimestamp(PlacesPage.Since);

            timeSince = ((DateTimeOffset)Convert.ToDateTime(since.Substring(since.IndexOf(' '))))
                        .ToOffset(TimeZoneInfo.Local.BaseUtcOffset.Subtract(
                                      TimeSpan.FromHours(DateTime.Now.IsDaylightSavingTime() ? 0 : 1)));
            Assert.IsTrue(Math.Abs((created7.Item1 - modified7.Item1).Seconds) <= 10,
                          "Duplicate place Created timestamp and user data should be equal to Modified field data");
            Assert.IsTrue(Math.Abs((since7.Item1 - timeSince).Seconds) <= 10,
                          $"Duplicate place Since should be equal to its timezone time: {timeSince}");
            Assert.IsTrue(IsElementNotFoundQuickly(PlacesPage.ChildPlacesSectionTableHeader),
                          "Duplicate place should not have any children");

            OpenEntityPage(place);
            Assert.IsFalse(AreElementsContainText(PlacesPage.ChildPlacesSectionTableRowsColumnTitle, titleDuplicate),
                           $@"Duplicate place '{titleDuplicate}' should not be a child of parent '{place.Title}'");
            Assert.IsTrue(IsElementFoundQuickly(PlacesPage.PlaceMapImageInline),
                          "Place Map in duplicate place should have a pre-loaded map");
            Assert.IsTrue(IsElementEquals(PlacesPage.PositionReadOnly, positionParent),
                          "Position field has changed in duplicate place");
            Assert.IsTrue(GetValue(PlacesPage.ToleranceRadiusReadOnly) == toleranceRadiusParent,
                          "Tolerance Radius field has changed in duplicate place");
        }
Ejemplo n.º 3
0
        // 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");
        }