Ejemplo n.º 1
0
        public async Task EditDetails_ValidFields_Success()
        {
            var user      = TestUser.NationalTeamUser;
            var pageRoute = (RouteHelper.GetContactDetailsSubPath(user.Id, ContactDetailsSubPaths.Edit));

            using (var client = Factory.WithUserAuth(user).CreateClientWithoutRedirects())
            {
                client.DefaultRequestHeaders.Authorization =
                    new AuthenticationHeaderValue(UserAuthentication.SchemeName);
                // Arrange
                var initialPage = await client.GetAsync(pageRoute);

                var initialDocument = await GetDocumentAsync(initialPage);

                var formData = new Dictionary <string, string>
                {
                    ["ContactDetails.Username"]             = user.Username,
                    ["ContactDetails.JobTitle"]             = "Teacher",
                    ["ContactDetails.PhoneNumberPrimary"]   = "0888192311",
                    ["ContactDetails.PhoneNumberSecondary"] = "0123871623",
                    ["ContactDetails.EmailPrimary"]         = "primary@email",
                    ["ContactDetails.EmailSecondary"]       = "secondary@email",
                    ["ContactDetails.Notes"] = "Notes"
                };

                // Act
                var result = await client.SendPostFormWithData(initialDocument, formData, pageRoute);

                // Assert
                Assert.Equal(HttpStatusCode.Redirect, result.StatusCode);
            }
        }
Ejemplo n.º 2
0
        public async Task EditDetails_TabInNotes_DisplayErrors()
        {
            var user      = TestUser.NationalTeamUser;
            var pageRoute = (RouteHelper.GetContactDetailsSubPath(user.Id, ContactDetailsSubPaths.Edit));

            using (var client = Factory.WithUserAuth(user).CreateClientWithoutRedirects())
            {
                // Arrange
                var initialPage = await client.GetAsync(pageRoute);

                var initialDocument = await GetDocumentAsync(initialPage);

                var formData = new Dictionary <string, string>
                {
                    ["ContactDetails.Username"]             = user.Username,
                    ["ContactDetails.JobTitle"]             = "Teacher",
                    ["ContactDetails.PhoneNumberPrimary"]   = "0888192311",
                    ["ContactDetails.PhoneNumberSecondary"] = "0123871623",
                    ["ContactDetails.EmailPrimary"]         = "primary@email",
                    ["ContactDetails.EmailSecondary"]       = "secondary@email",
                    ["ContactDetails.Notes"] = "Notes\t"
                };

                // Act
                var result = await client.SendPostFormWithData(initialDocument, formData, pageRoute);

                // Assert
                var resultDocument = await GetDocumentAsync(result);

                result.EnsureSuccessStatusCode();

                resultDocument.AssertErrorMessage("notes",
                                                  string.Format(ValidationMessages.StringCannotContainTabs, "Notes"));
            }
        }
Ejemplo n.º 3
0
        public async Task EditDetails_EditingOtherUser_IsForbiddenForNonAdmin()
        {
            var user      = TestUser.ServiceUserWithNoTbServices;
            var pageRoute = (RouteHelper.GetContactDetailsSubPath(user.Id, ContactDetailsSubPaths.Edit));

            using (var client = Factory.WithUserAuth(user).CreateClientWithoutRedirects())
            {
                // Arrange
                var initialPage = await client.GetAsync(pageRoute);

                var initialDocument = await GetDocumentAsync(initialPage);

                var formData = new Dictionary <string, string>
                {
                    ["ContactDetails.Username"]             = Utilities.CASEMANAGER_ABINGDON_EMAIL,
                    ["ContactDetails.JobTitle"]             = "Teacher",
                    ["ContactDetails.PhoneNumberPrimary"]   = "0888192311",
                    ["ContactDetails.PhoneNumberSecondary"] = "0123871623",
                    ["ContactDetails.EmailPrimary"]         = "primary@email",
                    ["ContactDetails.EmailSecondary"]       = "secondary@email",
                    ["ContactDetails.Notes"] = "Notes"
                };

                // Act
                var result = await client.SendPostFormWithData(initialDocument, formData, pageRoute);

                // Assert
                Assert.Equal(HttpStatusCode.Forbidden, result.StatusCode);
            }
        }
        public async Task BreadcrumbForRegionPresentForRegionalUser()
        {
            var user      = TestUser.RegionalUserWithPermittedPhecCode;
            var pageRoute = (RouteHelper.GetContactDetailsSubPath(user.Id, null));

            using (var client = Factory.WithUserAuth(user).CreateClientWithoutRedirects())
            {
                client.DefaultRequestHeaders.Authorization =
                    new AuthenticationHeaderValue(UserAuthentication.SchemeName);
                // Arrange
                var initialPage = await client.GetAsync(pageRoute);

                var pageContent = await GetDocumentAsync(initialPage);

                // Assert
                var breadcrumbs = pageContent.GetElementsByClassName("nhsuk-breadcrumb__list").Single().TextContent;
                Assert.Contains("Service Directory", breadcrumbs);
                Assert.Contains("South East", breadcrumbs);
                Assert.Contains("Permitted Phec", breadcrumbs);
            }
        }