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);
        }
Ejemplo n.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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);
        }