/// <summary>
        /// Finalizes execution of every test. Use this method in TearDown section of
        /// every TestFixture
        /// </summary>
        protected async Task TestEnd()
        {
            var deleteAllTasksTask = BackgroundTaskApi.DeleteAllTasksAsync(CurrentUser);

            if (TestConfig.IsReportingEnabled)
            {
                ReportManager.GenerateTestResultRecord();
            }

            CloseSecondaryBrowser();
            if (IsEachTestInNewBrowser)
            {
                ClosePrimaryBrowser();
                IsUserLoggedIn = false;
                await deleteAllTasksTask.ConfigureAwait(false);

                return;
            }

            var browserTabs = GetTabHandles();

            if (browserTabs == null || browserTabs.Count <= 1)
            {
                await deleteAllTasksTask.ConfigureAwait(false);

                return;
            }
            foreach (var browserTab in browserTabs.Skip(1))
            {
                CloseTab(browserTab);
            }
            await deleteAllTasksTask.ConfigureAwait(false);
        }
Exemple #2
0
        public async Task Setup()
        {
            if (TestConfig.IsReportingEnabled)
            {
                await ReportManager.CreateTestAsync().ConfigureAwait(false);
            }

            CurrentTenant = TenantTitle.upload1;
            CurrentUser   = TestConfig.AdminUser;
            await BackgroundTaskApi.DeleteAllTasksAsync(TestConfig.AdminUser).ConfigureAwait(false);

            AppApi.DeleteApps(true,
                              new[]
            {
                AppTitle.Haribo,
                AppTitle.ComposerHq1,
                AppTitle.ComposerHq2,
                AppTitle.SapPorsche,
                AppTitle.Player
            },
                              TenantTitle.upload1);
            AppApi.DeleteApps(true,
                              new[] { AppTitle.Haribo, AppTitle.ComposerHq1, AppTitle.ComposerHq2 }, TenantTitle.upload2);
            // page ready without "upload spinner" element check
            IsUseAllPageReadyChecks = false;
        }
        public async Task Setup()
        {
            if (TestConfig.IsReportingEnabled)
            {
                await ReportManager.CreateTestAsync().ConfigureAwait(false);
            }

            CurrentTenant = TenantTitle.media1;
            CurrentUser   = TestConfig.AdminUser;
            await BackgroundTaskApi.DeleteAllTasksAsync(TestConfig.AdminUser).ConfigureAwait(false);
        }
Exemple #4
0
        /// <summary>
        /// Deletes apps (or all of specified type(s)) within all or specified tenant
        /// </summary>
        /// <param name="deleteCompletely">Optional. If true, delete app(s) of the type(s) specified.
        /// If false, mark the app(s) version(s) as deleted.</param>
        /// <param name="appTypes">App types array (optional, use null to delete all app types)
        /// </param>
        /// <param name="tenantTitle">Tenant title (optional)</param>
        public static void DeleteApps(bool deleteCompletely   = true,
                                      string[] appTypes       = null,
                                      TenantTitle tenantTitle = TenantTitle.All)
        {
            var tenantList = tenantTitle == TenantTitle.All
                ? ActionManager.Tenants.ToArray()
                : ActionManager.Tenants
                             .Where(x => x.Title == tenantTitle.ToString())
                             .ToArray();

            if (appTypes == null || appTypes.Length == 0)
            {
                appTypes = new [] { AppTitle.Any };
            }

            BackgroundTaskApi.DeleteAllTasksAsync(TestConfig.AdminUser)
            .ConfigureAwait(false)
            .GetAwaiter()
            .GetResult();
            foreach (var tenant in tenantList)
            {
                var response = RestController.HttpRequestJson(
                    UriCxm.Apps, Method.GET, tenantCode: tenant.Code, user: TestConfig.AdminUser);
                var apps = JsonConvert.DeserializeObject <AppResponse[]>(response.Content);
                foreach (var app in apps)
                {
                    if (appTypes.All(x => x.ToString() != AppTitle.Any) &&
                        appTypes.All(x => x.ToString() != app.ActualAppVersion.Title) &&
                        appTypes.All(x => x.ToString() != app.Key) &&
                        !app.ActualAppVersion.Title.Contains("Auto"))
                    {
                        continue;
                    }

                    var app1 = GetById(app.AppId, tenant.Code, TestConfig.AdminUser);

                    if (app1.Places != null && app1.Places.Count > 0)
                    {
                        foreach (var place in app1.Places)
                        {
                            try
                            {
                                var p = PlaceApi.GetById(place.Id, tenant.Code);
                                p.Schedule.ScheduleApps.ForEach(x => x.DoDelete = true);
                                PlaceApi.SavePlace(p);
                            }
                            catch
                            {
                                // ignored
                            }
                        }

                        app1 = GetById(app.AppId, tenant.Code, TestConfig.AdminUser);
                    }

                    foreach (var version in app1.Versions)
                    {
                        RestController.HttpRequestJson(
                            new Uri(
                                string.Format(
                                    UriCxm.AppsDelete,
                                    version.Id,
                                    DateTime.MaxValue.ToString("yyyy-MM-ddTHH:mm:ss"),
                                    deleteCompletely.ToString().ToLower()),
                                UriKind.Relative)
                            .ToString(),
                            Method.DELETE,
                            tenantCode: tenant.Code,
                            user: TestConfig.AdminUser);
                    }
                }
            }
        }