Ejemplo n.º 1
0
        public async Task Get_RendersExpectedOutput()
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            var standard = await TestData.CreateStandard(standardCode : 123, version : 1, standardName : "My standard");

            await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetApprenticeshipStandard(standard);
            var mptxInstance = CreateMptxInstance(flowModel);

            // Act
            var response = await HttpClient.GetAsync(
                $"new-apprenticeship-provider/apprenticeship-details?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}");

            // Act
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var doc = await response.GetDocument();

            Assert.Equal(
                "My standard",
                doc.GetElementById("pttcd-new-apprenticeship-provider__apprenticeship-details__standard-name").TextContent);
        }
        public async Task Get_PersistedStateRendersExpectedOutput()
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetApprenticeshipLocationType(ApprenticeshipLocationType.EmployerBased);
            var mptxInstance = CreateMptxInstance(flowModel);

            // Act
            var response = await HttpClient.GetAsync(
                $"new-apprenticeship-provider/apprenticeship-locations?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}");

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var doc = await response.GetDocument();

            Assert.Null(doc.GetElementById("LocationType").GetAttribute("checked"));
            Assert.Equal("checked", doc.GetElementById("LocationType-1").GetAttribute("checked"));
            Assert.Null(doc.GetElementById("LocationType-2").GetAttribute("checked"));
        }
Ejemplo n.º 3
0
        public async Task Post_ValidRequestRedirects()
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            var standard = await TestData.CreateStandard(standardCode : 123, version : 1, standardName : "My standard");

            await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetApprenticeshipStandard(standard);
            var mptxInstance = CreateMptxInstance(flowModel);

            var requestContent = new FormUrlEncodedContentBuilder()
                                 .Add("MarketingInformation", "Apprenticeship info")
                                 .Add("ContactEmail", "*****@*****.**")
                                 .Add("ContactTelephone", "01234 567890")
                                 .ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"new-apprenticeship-provider/apprenticeship-details?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}",
                requestContent);

            // Act
            Assert.Equal(HttpStatusCode.Found, response.StatusCode);
            Assert.StartsWith(
                "/new-apprenticeship-provider/apprenticeship-locations",
                response.Headers.Location.OriginalString);
        }
Ejemplo n.º 4
0
        public async Task Post_HelpdeskUserCannotAccess()
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            var standard = await TestData.CreateStandard(standardCode : 123, version : 1, standardName : "My standard");

            await User.AsHelpdesk();

            var flowModel = new FlowModel();

            flowModel.SetApprenticeshipStandardOrFramework(standard);
            var mptxInstance = CreateMptxInstance(flowModel);

            var requestContent = new FormUrlEncodedContentBuilder()
                                 .Add("MarketingInformation", "Apprenticeship info")
                                 .Add("ContactEmail", "*****@*****.**")
                                 .Add("ContactTelephone", "01234 567890")
                                 .ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"new-apprenticeship-provider/apprenticeship-details?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}",
                requestContent);

            // Act
            Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
        }
Ejemplo n.º 5
0
        public async Task Post_InvalidContactWebsiteRendersError(string contactWebsite)
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            var standard = await TestData.CreateStandard(standardCode : 123, version : 1, standardName : "My standard");

            await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetApprenticeshipStandard(standard);
            var mptxInstance = CreateMptxInstance(flowModel);

            var requestContent = new FormUrlEncodedContentBuilder()
                                 .Add("MarketingInformation", "Apprenticeship info")
                                 .Add("ContactEmail", "*****@*****.**")
                                 .Add("ContactTelephone", "01234 567890")
                                 .Add("ContactWebsite", contactWebsite)
                                 .ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"new-apprenticeship-provider/apprenticeship-details?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}",
                requestContent);

            // Act
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);

            var doc = await response.GetDocument();

            doc.AssertHasError(
                "ContactWebsite",
                "The contact us webpage must be a real website");
        }
Ejemplo n.º 6
0
        public async Task Post_QAStatusNotValidReturnsBadRequest(ApprenticeshipQAStatus qaStatus)
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : qaStatus);

            var standard = await TestData.CreateStandard(standardCode : 123, version : 1, standardName : "My standard");

            await User.AsProviderUser(provider.ProviderId, ProviderType.FE);

            var flowModel = new FlowModel();

            flowModel.SetApprenticeshipStandard(standard);
            var mptxInstance = CreateMptxInstance(flowModel);

            var requestContent = new FormUrlEncodedContentBuilder()
                                 .Add("MarketingInformation", "Apprenticeship info")
                                 .Add("ContactEmail", "*****@*****.**")
                                 .Add("ContactTelephone", "01234 567890")
                                 .ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"new-apprenticeship-provider/apprenticeship-details?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}",
                requestContent);

            // Act
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
Ejemplo n.º 7
0
        public async Task Get_RendersExpectedOutput()
        {
            // Arrange
            var provider = await TestData.CreateProvider(
                providerName : "Provider name",
                apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted,
                marketingInformation : "<p>Existing marketing info</p>");

            await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetProviderDetails("<p>Existing marketing info</p>");
            var mptxInstance = CreateMptxInstance(flowModel);

            // Act
            var response = await HttpClient.GetAsync(
                $"new-apprenticeship-provider/provider-detail?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}");

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var doc = await response.GetDocument();

            Assert.Equal("<p>Existing marketing info</p>", doc.GetElementById("MarketingInformation").TextContent.Trim());
        }
Ejemplo n.º 8
0
        public async Task PostConfirmation_ValidRequestUpdatesDbAndRedirects()
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetProviderDetails("<p>New marketing info</p>");
            var mptxInstance = CreateMptxInstance(flowModel);

            var requestContent = new FormUrlEncodedContentBuilder().ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"new-apprenticeship-provider/provider-detail-confirmation?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}",
                requestContent);

            // Assert
            CosmosDbQueryDispatcher.Verify(mock => mock.ExecuteQuery(It.Is <UpdateProviderInfo>(c =>
                                                                                                c.ProviderId == provider.ProviderId &&
                                                                                                c.MarketingInformation == "<p>New marketing info</p>" &&
                                                                                                c.UpdatedBy.UserId == User.UserId &&
                                                                                                c.UpdatedOn == Clock.UtcNow)));

            Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
            Assert.Equal(
                "/new-apprenticeship-provider/find-standard",
                UrlHelper.StripQueryParams(response.Headers.Location.OriginalString));
        }
Ejemplo n.º 9
0
        public async Task GetConfirmation_QAStatusNotValidReturnsBadRequest(ApprenticeshipQAStatus qaStatus)
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : qaStatus);

            await User.AsProviderUser(provider.ProviderId, ProviderType.FE);

            var flowModel = new FlowModel();

            flowModel.SetProviderDetails("<p>New marketing info</p>");
            var mptxInstance = CreateMptxInstance(flowModel);

            // Act
            var response = await HttpClient.GetAsync(
                $"new-apprenticeship-provider/provider-detail-confirmation?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}");

            // Assert
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
Ejemplo n.º 10
0
        public async Task Get_QAStatusNotValidReturnsBadRequest(ApprenticeshipQAStatus qaStatus)
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : qaStatus);

            var standard = await TestData.CreateStandard(standardCode : 123, version : 1, standardName : "My standard");

            await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetApprenticeshipStandard(standard);
            var mptxInstance = CreateMptxInstance(flowModel);

            // Act
            var response = await HttpClient.GetAsync(
                $"new-apprenticeship-provider/apprenticeship-details?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}");

            // Act
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
Ejemplo n.º 11
0
        public async Task Get_HelpdeskUserCannotAccess()
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            var standard = await TestData.CreateStandard(standardCode : 123, version : 1, standardName : "My standard");

            await User.AsHelpdesk();

            var flowModel = new FlowModel();

            flowModel.SetApprenticeshipStandard(standard);
            var mptxInstance = CreateMptxInstance(flowModel);

            // Act
            var response = await HttpClient.GetAsync(
                $"new-apprenticeship-provider/apprenticeship-details?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}");

            // Act
            Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
        }
Ejemplo n.º 12
0
        public async Task PostConfirmation_HelpdeskUserCannotAccess()
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            await User.AsHelpdesk();

            var flowModel = new FlowModel();

            flowModel.SetProviderDetails("<p>New marketing info</p>");
            var mptxInstance = CreateMptxInstance(flowModel);

            var requestContent = new FormUrlEncodedContentBuilder().ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"new-apprenticeship-provider/provider-detail-confirmation?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}",
                requestContent);

            // Assert
            Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
        }
Ejemplo n.º 13
0
        public async Task GetConfirmation_RendersExpectedOutput()
        {
            // Arrange
            var provider = await TestData.CreateProvider(
                apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted,
                providerName : "Test Provider",
                courseDirectoryName : "CD Name");

            await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetProviderDetails("<p>New marketing info</p>");
            var mptxInstance = CreateMptxInstance(flowModel);

            // Act
            var response = await HttpClient.GetAsync(
                $"new-apprenticeship-provider/provider-detail-confirmation?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}");

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }