示例#1
0
        public void RT02310_UdAdminAssignsRoleWithLoginAndUserCanLogin()
        {
            UserDirectoryApi.AssignRolesToUser(TestConfig.ComposerOnlyUser, new [] { UserRole.ComposerAdmin, UserRole.CxmAdmin });
            Login(TestConfig.ComposerOnlyUser, isPressTenantButton: false);
            Assert.IsTrue(IsPageRedirectedTo(TestConfig.TenantsUrl),
                          @"Composer user with granted login permission and tenants cannot login to CX Manager");

            UserDirectoryApi.AssignRolesToUser(
                TestConfig.ComposerOnlyUser, new[] { UserRole.ComposerAdmin });
        }
 public void RT01370_AddPermissionsToNewUserAndLogin()
 {
     if (!_isNewUserActivatedByAdmin)
     {
         RT01350_ActivateUserAndFindEmailUserActivated();
     }
     if (!_activationLinkClicked)
     {
         Assert.Warn("Cannot run because test method " +
                     "RT01350_ActivateUserAndFindEmailUserActivated has failed");
     }
     UserDirectoryApi.AssignRolesToUser(TestConfig.NewUser, new [] { UserRole.CxmAdmin });
     Login(TestConfig.NewUser, isPressTenantButton: false);
     Assert.IsTrue(IsElementNotFound(LoginPage.ErrorNoRolesAndPermissionsAssigned),
                   "Error 'You have no permissions assigned to you...' is displayed");
 }
        public void RT08010_AssignItemToPlace()
        {
            Place place1 = null, place2 = null, place3 = null, rootPlace = null;
            Item  item = null;

            UserDirectoryApi.AssignRolesToUser(TestConfig.AdminUser, new [] { UserRole.CxmAdmin });
            Parallel.Invoke(
                () => AddAppIbeacon(TestConfig.IbeaconAppVersions[1], true),
                () => place1    = AddPlaceIbeacon(PlaceStatus.Any, pageToBeOpened: 0, isCreateNewPlace: true),
                () => place2    = AddPlaceIbeacon(PlaceStatus.Any, pageToBeOpened: 0, isCreateNewPlace: true),
                () => place3    = AddPlaceWw(PlaceStatus.Any, pageToBeOpened: 0, isCreateNewPlace: true),
                () => rootPlace = AddPlaceNoType(PlaceStatus.Any, pageToBeOpened: 0, isCreateNewPlace: true),
                () => item      = AddItem(ItemType.PorscheCar, isAddNew: true)
                );
            TestStart();

            OpenEntityPage(item);
            EditForm();
            ClickUntilShown(ItemsPage.AssignedPlacesAddButton, ItemsPage.AssignedPlacesPlaceDropDown);
            ClickUntilShown(ItemsPage.AssignedPlacesPlaceDropDown, CommonElement.DropDownOptionList);
            Assert.IsTrue(IsElementFoundQuickly(string.Format(CommonElement.DropDownOption, place1.Title)),
                          $"Assigned places: dropdown should contain place {place1.Title}");
            Assert.IsTrue(IsElementFoundQuickly(string.Format(CommonElement.DropDownOption, place2.Title)),
                          $"Assigned places: dropdown should contain place {place2.Title}");
            Assert.IsTrue(IsElementNotFoundQuickly(string.Format(CommonElement.DropDownOption, place3.Title)),
                          $"Assigned places: dropdown should not contain WW place {place3.Title}");
            if (rootPlace != null)
            {
                Assert.IsTrue(IsElementNotFoundQuickly(string.Format(CommonElement.DropDownOption, rootPlace.Title)),
                              $"Assigned places: dropdown should not contain root place {rootPlace.Title}");
            }

            DropDownSelect(ItemsPage.AssignedPlacesPlaceDropDown, place1.Title);
            SubmitForm();
            Assert.IsTrue(AreElementsContainText(ItemsPage.ReferencesSectionPlaces, place1.Title),
                          $"References: Field Places should contain place {place1.Title}");

            Click(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place1.Title));
            Assert.IsTrue(IsPageContainsUri($"{TestConfig.PlaceUri}/{place1.Id}"),
                          $"Place {place1.Title} page should be opened");
            Assert.IsTrue(IsElementFoundQuickly(string.Format(PlacesPage.ItemsSectionItemByTitle, item.LangJsonData.EnJson.Title)),
                          $"Items section: place should contain item {item.LangJsonData.EnJson.Title}");

            Click(string.Format(PlacesPage.ItemsSectionItemByTitle, item.LangJsonData.EnJson.Title));
            Assert.IsTrue(IsViewMode(), "Place should stay in view mode");

            Click(PageFooter.DeleteButton);
            Click(PlacesPage.DeleteButton);
            OpenEntityPage(item);
            Assert.IsTrue(AreElementsContainText(ItemsPage.ReferencesSectionPlaces, place1.Title),
                          $"References: Field Places should contain place {place1.Title}");

            Click(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place1.Title));
            Click(PageFooter.RestoreButton);
            SubmitForm();
            OpenEntityPage(item);
            Assert.IsTrue(AreElementsContainText(ItemsPage.ReferencesSectionPlaces, place1.Title),
                          $"References: Field Places should contain place {place1.Title}");

            EditForm();
            ClickUntilConditionMet(ItemsPage.AssignedPlacesAddButton,
                                   () => CountElements(ItemsPage.AssignedPlacesPlaceDropDown) == 2);
            ClickUntilShown(ItemsPage.AssignedPlacesPlaceLastDropDown, CommonElement.DropDownOptionList);
            Assert.IsTrue(AreElementsContainText(CommonElement.DropDownOptionList, place2.Title),
                          $"Assigned places: last dropdown should contain place {place2.Title}");

            DropDownSelect(ItemsPage.AssignedPlacesPlaceLastDropDown, place2.Title);
            ClickUntilConditionMet(ItemsPage.AssignedPlacesAddButton,
                                   () => CountElements(ItemsPage.AssignedPlacesPlaceDropDown) == 3);
            Click(ItemsPage.AssignedPlacesPlaceLastDropDown);
            Assert.IsTrue(IsElementNotFoundQuickly(CommonElement.DropDownOptionList) ||
                          (!AreElementsContainText(CommonElement.DropDownOptionList, place2.Title) &&
                           !AreElementsContainText(CommonElement.DropDownOptionList, place1.Title)),
                          $"Assigned places: last dropdown should not contain places {place2.Title} and {place1.Title}");

            Click(ItemsPage.AssignedPlacesDeleteLastButton);
            SubmitForm();
            Assert.IsTrue(AreElementsContainText(ItemsPage.ReferencesSectionPlaces, place1.Title),
                          $"References: Field Places should contain place {place1.Title}");
            Assert.IsTrue(AreElementsContainText(ItemsPage.ReferencesSectionPlaces, place2.Title),
                          $"References: Field Places should contain place {place2.Title}");

            EditForm();
            Click(ItemsPage.AssignedPlacesDeleteButton);
            SubmitForm();
            Assert.IsTrue(!AreElementsContainText(ItemsPage.ReferencesSectionPlaces, place1.Title),
                          $"References: Field Places should not contain place {place1.Title}");
            Assert.IsTrue(AreElementsContainText(ItemsPage.ReferencesSectionPlaces, place2.Title),
                          $"References: Field Places should contain place {place2.Title}");

            Click(PageFooter.DeleteButton);
            Assert.IsTrue(IsElementFound(ItemsPage.ItemIsReferencedDialog),
                          $@"'This item is referenced in {place2.Title}...' dialog should be displayed");

            Click(ItemsPage.OkButton);
            Assert.IsTrue(IsElementNotFound(ItemsPage.ItemIsReferencedDialog),
                          $@"'This item is referenced in {place2.Title}...' dialog should be closed");
            Assert.IsTrue(IsElementNotFoundQuickly(PageFooter.RestoreButton),
                          "Item should not be deleted");

            Click(string.Format(ItemsPage.ReferencesSectionPlaceByTitle, place2.Title));
            EditForm();
            var itemTitle = item.LangJsonData.EnJson.Title;

            Assert.IsTrue(IsElementFoundQuickly(
                              string.Format(PlacesPage.ItemsSectionItemByTitleUnassignButton, itemTitle)),
                          @"Items section: All items should have text 'Unassign'");

            Click(string.Format(PlacesPage.ItemsSectionItemByTitleUnassignButton, itemTitle));
            Assert.IsTrue(IsElementFoundQuickly(PlacesPage.DoYouWantToUnassignDialog),
                          @"Dialog 'Do you really want to unassign this item?' should be displayed");

            Click(PlacesPage.UnassignButton);
            Assert.IsTrue(IsElementNotFoundQuickly(PlacesPage.DoYouWantToUnassignDialog),
                          @"Dialog 'Do you really want to unassign this item?' should be closed");
            Assert.IsTrue(IsElementNotFoundQuickly(
                              string.Format(PlacesPage.ItemsSectionItemByTitleUnassignButton, place2.Title)),
                          $"Items section: item {itemTitle} should be unassigned (absent)");
            Assert.IsTrue(IsEditMode(), "Place should stay in edit mode");

            SubmitForm();
            OpenEntityPage(item);
            Assert.IsTrue(IsElementNotFound(ItemsPage.ReferencesSectionPlaces),
                          "Reference section should be absent");

            Click(PageFooter.DeleteButton);
            Assert.IsTrue(IsElementFoundQuickly(ItemsPage.DeleteConfirmationDialog),
                          "Item delete confirmation dialog should be displayed");

            Click(ItemsPage.DeleteButton);
            Assert.IsTrue(IsPageContainsUri(TestConfig.ItemsUri), "Page Items should be opened");
        }
示例#4
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");
        }