using Library.TestingFramework;
using Library.TestingFramework.Model;
using Library.TestingFramework.PageObjects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Securities.Test.Framework.Phoenix;
using System;
using Securities.Test.Framework.Phoenix.PageObjects;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using Library.TestingFramework.DataAccessHelpers;
namespace Phoenix.Tests.Regression.ProcessFiling.ProcessBlueExpressFiling
{
[TestClass]
public class ProcessBlueExpressFiling : TestBase
{
[TestInitialize]
public void InitializeTest()
{
Role.Needed("Phoenix.User");
Pages.HomePage.GoTo();
}
[TestCleanup]
public void CleanupTest()
{
}
/// <summary>
/// Scenario: Process a Blue Express Filing inserted into the database via SQL since normally it would be accepted via XML or something and Selenium does not interact with
/// Windows applications without an additional plugin.
/// </summary>
[TestMethod, TestCategory("Regression")]
public void Process_Blue_Express_Filing()
{
HomePage homePage = Pages.HomePage; //instantiate homepage object
//- Create Blue Express Data, use the ‘BlueExpress AutoFile and NonAutofile Filing Test’ script in the Regression Tests as a template
// o Creates 1 package, 1 payment, 2 filings
// o Parameterize Filing Names (make unique!) , PaymentID (make unique!), Date
string nameOfIssuerLine1 = homePage.BlueExpressFilingName();
string filingNameAutofiledFiling = nameOfIssuerLine1 + " Yes Autofile";
string filingNameNonAutofiledFiling = nameOfIssuerLine1 + " No Autofile";
string paymentIDNonAutofiledFiling = homePage.BlueExpressPaymentID();
string fileNameNonAutofiledFiling = "Automated Script Test BE Open End Mutual Fund " + DateTime.Now.ToString("MM.dd.yyyy hh.mm.ss");
//- Process the Blue Express Payment in Phoenix (http://iwebapptest/apps/Phoenix/BlueExpress/PaymentList)
//- Validate no error on the Filing Group page (‘Processing complete’)
BlueExpressPaymentsPage blueExpressPaymentsPage = homePage.BlueExpressPaymentProcessingLinkClick();
Assert.IsTrue(Pages.BlueExpressPaymentsPage.IsCurrent, "Blue Express Payments Page assertion failed.");
blueExpressPaymentsPage.PaymentIDFilterButtonClick();
blueExpressPaymentsPage.PaymentIDFilterBoxText = paymentIDNonAutofiledFiling;
blueExpressPaymentsPage.Row1ReceivedDateBoxClick();
blueExpressPaymentsPage.ActiveReceivedDateBoxText = DateTime.Now.ToString("MM/dd/yyyy");
blueExpressPaymentsPage.Row1DepositAmountBoxClick();
blueExpressPaymentsPage.ActiveDepositAmountBoxText = "3000";
blueExpressPaymentsPage.Row1DepositIDBoxClick();
blueExpressPaymentsPage.ActiveDepositIDBoxText = "Test Deposit ID " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
FilingGroupDetailsPage filingGroupDetailsPage = blueExpressPaymentsPage.ProcessPaymentsClick();
Assert.IsTrue(filingGroupDetailsPage.ProcessingCompleteTextBool, "Processing complete text verify on Filing Group Details Page failed");
// - Search for and validate Autofiled filing: Similar to paper filing after processing…
// o Click on ‘Search Filing’
Pages.HomePage.GoTo();
RegistrationSearchPage registrationSearchPage = homePage.SearchFilingLinkClick();
// o Enter the filing name you created in the ‘File Name’ field, click Search
registrationSearchPage.FileNameTextBox = filingNameAutofiledFiling;
registrationSearchPage.ClickSearch();
// o Single result should be returned.
Assert.AreEqual("16", registrationSearchPage.TDCount.ToString(), "Single search result on Registration Search Page validation failed.");
// o Click on File Number link, should take you to the Filing Detail page for the filing.
registrationSearchPage.ClickFirstSearchResultFileNumberLink();
// o Verify header fields (Name, Filing Type, Status = Filed, Dates, etc.)
FilingDetailPage filingDetailPage = Pages.FilingDetailPage;
Assert.AreEqual("File Name " + filingNameAutofiledFiling, filingDetailPage.FileNameLabelText, "File Name Autofiled Filing on Filing Detail Page validation failed."); //file name
Assert.AreEqual("Filing Type Open-End Mutual Fund Filing ", filingDetailPage.FilingTypeLabelText, "Filing Type on Filing Detail Page Validation failed."); //filing type
Assert.AreEqual("Status Filed ", filingDetailPage.FiledStatusLabelText, "Filed Status on Filing Detail Page validation failed."); //status
// can't get these to work. (DOS-215)
//Assert.AreEqual(" Received Date " + DateTime.Now.ToString("MM/dd/yyyy") + " ", filingDetailPage.ReceivedDateLabelText, "Received Date on Filing Detail Page validation failed."); //received date
//Assert.AreEqual("SEC Effective Date " + DateTime.Now.AddDays(-5).ToString("MM/dd/yyyy"), filingDetailPage.SECEffectiveDateLabelText, "SEC Effective Date on Filing Detail Page validation failed."); //sec effective date
// o Verify some of the tabs load and contain valid data:
// Names – list should have current file name
System.Threading.Thread.Sleep(2000);
Assert.AreEqual(filingNameAutofiledFiling, filingDetailPage.FilingNamesCurrentLabelText, "File Name on Filing Detail Page validation failed."); //current names list
// Contacts – Should have entered Issuer Address
filingDetailPage.ClickContactsTab();
string address = "Address Line 1";
string city = "City";
string zip = "12345";
Assert.AreEqual(address, filingDetailPage.ContactsAddressLabelText, "Address on Filing Detail Page Contact Tab validation failed."); //street address on contacts page verify
Assert.AreEqual(city + " WI " + zip, filingDetailPage.ContactsCityStateZipLabelText, "City on Filing Detail Page Contact Tab validation failed."); //city state zip on contacts page verify
// Events Journal – should have 2 records (Notice Filing Received, SEC Effective)
filingDetailPage.ClickJournalTab();
Assert.AreEqual("SEC Effective", filingDetailPage.EventsJournalRow1EventLabelText, "SEC Effective Event on Filing Detail Page Journal Tab validation failed."); //SEC filing received on journal page verify
//this is not showing up for some reason
//Assert.AreEqual("Notice Filing Received", filingDetailPage.JournalNoticeFilingReceivedLabelText, "Notice Filing Received on Filing Detail Page Journal Tab validation failed."); //Notice Effective on journal page verify
// Fiscal Record – has a record of the fiscal payments for this filing.
filingDetailPage.ClickFiscalRecordTab();
Assert.AreEqual("$1,500.00", filingDetailPage.FiscalRecordAmountLabelText, "Amount on Filing Detail Page Fiscal Record Tab validation failed."); //Fiscal Record Amount on Fiscal Record tab verify
// • Verify BE Filing link; not NULL, goes to SSRS...
Assert.IsTrue(filingDetailPage.FiscalRecordValidateSSRSURL, "Fiscal Record tab BE Filing ID Link goes to SSRS Assertion Failed.");
//- Get envelope ID (from processed payment or autofiled filing fiscal tab)
string envelopeID = filingDetailPage.FiscalRecordEnvelopeIDLinkText;
//- Process NonAutoFiled filing: Similar to paper filing process.
//o Go to Phoenix app home page: http://iwebapptest/apps/Phoenix
Pages.HomePage.GoTo();
//o In Unprocessed Filings grid, enter Envelope # to filter.
homePage.EnvelopeNumberFilterTextBox = envelopeID;
homePage.FilterButtonClick(); // click on filter button
//o Click on envelope # link in the results, should take you to Phoenix Classify page.
homePage.FirstEnvelopeLinkClick();
//o Choose Product Type = Open-End Mutual Fund
ClassifyPage classifyPage = Pages.ClassifyPage;
classifyPage.SelectProductType();
//o Money will not auto-apply $1500 after product is selected… Do we have add adjustment script to re-use? If not, I can try and change the reason for not autofiling… probably to have an indeterminate filing type.
//o Verify ‘Blue Express’
//o Click ‘Continue’, should go to Open-End Mutual Fund – Phoenix ‘Data Entry’ page.
InitialFilingPage initialFilingPage = classifyPage.ClickContinue(); // click Continue, instantiate the new page
//o Enter all required data:
// Filing Type = Open End Mutual Fund Filing
initialFilingPage.SelectProductType();
// File Name = Something unique, end with date?
initialFilingPage.FileNameTextBox = fileNameNonAutofiledFiling;
// Address fields can be any standard data
initialFilingPage.Address1TextBox = address;
initialFilingPage.CityTextBox = city;
initialFilingPage.ZipTextBox = zip;
// Fiscal Year End = 0131
initialFilingPage.SelectFiscalYearEnd();
// SEC Effective Date = today -5 (or some recent some past date…)
DateTime secEffectiveDate = DateTime.Now.AddDays(-5); //make sure this is taking properly
initialFilingPage.SECEffectiveDateTextBox = secEffectiveDate.ToString();
// Leave defaults for other fields… add comments if you want about this being a test filing…
initialFilingPage.CommentsTextBox = "This is a test Initial Filing created by Automated Script ProcessBlueExpressFiling.cs";
// Leave ‘Response Due Date’ blank.
//o Click ‘Confirm and Process Another’, should take you back to the Phoenix Home Page
initialFilingPage.ClickConfirmAndReturnToMainMenu();
//o Click on ‘Search Filing’
//o Enter the filing name you created in the ‘File Name’ field, click Search
homePage.SearchFilingLinkClick();
registrationSearchPage.FileNameTextBox = fileNameNonAutofiledFiling;
registrationSearchPage.ClickSearch();
//o Single result should be returned.
Assert.AreEqual("16", registrationSearchPage.CountLinks(), "The number of links on the Filing Search results page is not equal to 16.");
//o Click on File Number link, should take you to the Filing Detail page for the filing.
registrationSearchPage.ClickFirstSearchResultFileNumberLink();
//o Verify header fields (Name, Filing Type, Status = Filed, Dates, etc.)
System.Threading.Thread.Sleep(2000);
Assert.AreEqual("File Name " + fileNameNonAutofiledFiling, filingDetailPage.FileNameLabelText, "File Name on Filing Detail Page validation failed."); //name
Assert.AreEqual("Filing Type Open-End Mutual Fund Filing ", filingDetailPage.FilingTypeLabelText, "Filing Type on Filing Detail Page Validation failed."); //filing type
Assert.AreEqual("Status Filed ", filingDetailPage.FiledStatusLabelText, "Filed Status on Filing Detail Page validation failed."); //status
// (DOS-215) will need to figure out how to put the date into one digit if that's all there is, two if more.
/*if (DateTime.Now.ToString("MM")
{
} else
{
}*/
//Assert.AreEqual(" Received Date " + DateTime.Now.ToString("MM/dd/yyyy") + " ", filingDetailPage.ReceivedDateLabelText, "Received Date on Filing Detail Page validation failed."); //received date
//Assert.AreEqual("SEC Effective Date " + DateTime.Now.AddDays(-5).ToString("MM/dd/yyyy"), filingDetailPage.SECEffectiveDateLabelText, "SEC Effective Date on Filing Detail Page validation failed."); //sec effective date
//o Verify some of the tabs load and contain valid data:
// Names – list should have current file name
Assert.AreEqual(fileNameNonAutofiledFiling, filingDetailPage.FilingNamesCurrentLabelText, "File Name on Filing Detail Page validation failed."); //current names list
// Contacts – Should have entered Issuer Address
filingDetailPage.ClickContactsTab();
Assert.AreEqual(address, filingDetailPage.ContactsAddressLabelText, "Address on Filing Detail Page Contact Tab validation failed."); //street address on contacts page verify
Assert.AreEqual(city + " WI " + zip, filingDetailPage.ContactsCityStateZipLabelText, "City on Filing Detail Page Contact Tab validation failed."); //city state zip on contacts page verify
// Events Journal – should have 2 records (Notice Filing Received, SEC Effective)
filingDetailPage.ClickJournalTab();
Assert.AreEqual("Notice Filing Received", filingDetailPage.EventsJournalRow2EventLabelText, "Notice Filing Received on Filing Detail Page Journal Tab validation failed."); //Notice Effective on journal page verify
Assert.AreEqual("SEC Effective", filingDetailPage.EventsJournalRow3EventLabelText, "SEC Effective Event on Filing Detail Page Journal Tab validation failed."); //SEC filing received on journal page verify
// Fiscal Record – has a record of the fiscal payments for this filing.
filingDetailPage.ClickFiscalRecordTab();
Assert.AreEqual("$1,500.00", filingDetailPage.FiscalRecordAmountLabelText, "Amount on Filing Detail Page Fiscal Record Tab validation failed."); //Fiscal Record Amount on Fiscal Record tab verify
// • Verify BE Filing link; not NULL, goes to SSRS...
Assert.IsTrue(filingDetailPage.FiscalRecordValidateSSRSURL, "Fiscal Record tab BE Filing ID Link goes to SSRS Assertion Failed.");
}
}
}
public string BlueExpressFilingName() {
var insertBlueExpressAction = Phoenix.Query.InsertBlueExpressFilingAction();
var filingNameAutofiledFiling = Phoenix.Query.ReturnFilingNameAutofiledFilingAction();
return string.Format(filingNameAutofiledFiling.ToString()); }
internal static object InsertBlueExpressFilingAction()
{
return Repository.InsertBlueExpressFiling();
}
internal static object ReturnFilingNameAutofiledFilingAction()
{
return Repository.ReturnFilingNameAutofiledFiling();
}
public int InsertBlueExpressFiling()
{
var query = string.Format(
@"
--This script will create a 2 filings, one that will autofile and another that will not.
USE [BlueExpress]
DECLARE @currDate VARCHAR(100) = CONVERT(varchar, FORMAT(getdate(), 'MM.dd.yy hh.mm.ss'), 100)
DECLARE @PackageID VARCHAR(32) = 'TestPackage ' + @currDate
DECLARE @PaymentID VARCHAR(25) = 'TstPymt ' + @currDate
DECLARE @FilingName VARCHAR(100) = 'Test NameOfIssuerLine1 ' + @currDate
/*CREATE PACKAGE*/
INSERT INTO [BlueExpress].[dbo].[Package]
(
[FilerID]
,[FilersPackageID]
,[TotalItemsCount]
,[TotalFeesAmount]
)
VALUES
(
'CLEARSKY' --[FilerID]
,@PackageID --[FilersPackageID]
,2 --[TotalItemsCount]
,3000.00 --[TotalFeesAmount]
)
/*CREATE PAYMENT*/
INSERT INTO [BlueExpress].[dbo].[Payment]
(
[FilerID]
,[PaymentID]
,[PaymentMethod]
,[ScheduledDate]
,[ItemCount]
,[TotalAmount]
,[OriginationNoticeDate]
,[OriginationNoticeConfirmationID]
,[AdjustmentsAppliedPositiveCNT]
,[AdjustmentsAppliedPositiveAmount]
,[AdjustmentsAppliedNegativeCNT]
,[AdjustmentsAppliedNegativeAmount])
VALUES
(
'CLEARSKY' --[FilerID]
,@PaymentID --[PaymentID]
,'ACH' --[PaymentMethod]
,'2018-08-05' --[ScheduledDate]
,2 --[ItemCount]
,3000.00 --[TotalAmount]
,'2018-09-05 00:00:00.000' --[OriginationNoticeDate]
,'ConfirmationID001' --[OriginationNoticeConfirmationID]
,0 --[AdjustmentsAppliedPositiveCNT]
,0 --[AdjustmentsAppliedPositiveAmount]
,0 --[AdjustmentsAppliedNegativeCNT]
,0 --[AdjustmentsAppliedNegativeAmount]
)
/*CREATE FILINGS*/
--Add an initial filing that will autofile.
INSERT INTO [BlueExpress].[dbo].[Filing] (
[FilerID]
,[FilersDocumentID]
,[FilersPackageID]
,[PaymentID]
,[FiledDate]
,[DemonstrationFilingYN]
,[NameOfIssuerLine1]
,[NameOfIssuerLine2]
,[IssuerAddressLine1]
,[IssuerAddressCity]
,[IssuerAddressStateCode]
,[IssuerAddressZIP]
,[OpenEndedMutualFundX]
,[InitialFilingX]
,[DescriptionOfSecurities]
,[FiscalYearEndOfIssuer]
,[TotalFeeAmount]
,[EffectiveUponFilingX]
,[SECEffectivenessFilingYN]
,[SECEffectiveDate]
)
VALUES
(
'CLEARSKY' --FilerID
,'TestDID001' --FilersDocumentID
,@PackageID --FilersPackageID
,@PaymentID --PaymentID
,'2018-09-05' --FiledDate
,'N' --DemonstrationFilingYN
,@FilingName --NameOfIssuerLine1
,'Yes Autofile' --NameOfIssuerLine2
,'Address Line 1' --IssuerAddressLine1
,'City' --IssuerAddressCity
,'WI' --IssuerAddressStateCode
,'12345' --IssuerAddressZIP
,'X' --OpenEndedMutualFundX
,'X' --InitialFilingX
,'Shares of Beneficial Interest' --DescriptionOfSecurities
,'March 31' --FiscalYearEndOfIssuer
,'1500.00' --TotalFeeAmount
,'X' --EffectiveUponFilingX
,'Y' --SECEffectivenessFilingYN
,'2018-08-01 00:00:00.000' --SECEffectiveDate
)
--Add an initial filing that will NOT autofile.
INSERT INTO [BlueExpress].[dbo].[Filing] (
[FilerID]
,[FilersDocumentID]
,[FilersPackageID]
,[PaymentID]
,[FiledDate]
,[DemonstrationFilingYN]
,[NameOfIssuerLine1]
,[NameOfIssuerLine2]
,[IssuerAddressLine1]
,[IssuerAddressCity]
,[IssuerAddressStateCode]
,[IssuerAddressZIP]
,[InitialFilingX]
,[DescriptionOfSecurities]
,[FiscalYearEndOfIssuer]
,[TotalFeeAmount]
,[EffectiveUponFilingX]
,[SECEffectivenessFilingYN]
,[SECEffectiveDate]
)
VALUES
(
'CLEARSKY' --FilerID
,'TestDID002' --FilersDocumentID
,@PackageID --FilersPackageID
,@PaymentID --PaymentID
,'2018-09-05' --FiledDate
,'N' --DemonstrationFilingYN
,@FilingName --NameOfIssuerLine1
,'No Autofile' --NameOfIssuerLine2
,'123 Main Street' --IssuerAddressLine1
,'City' --IssuerAddressCity
,'WI' --IssuerAddressStateCode
,'12345' --IssuerAddressZIP
,'X' --InitialFilingX
,'Shares of Beneficial Interest' --DescriptionOfSecurities
,'March 31' --FiscalYearEndOfIssuer
,'1500.00' --TotalFeeAmount
,'X' --EffectiveUponFilingX
,'Y' --SECEffectivenessFilingYN
,'2018-08-01 00:00:00.000' --SECEffectiveDate
)
");
return _coreConnection.ExecuteScalar<int>(query);
}
public string ReturnFilingNameAutofiledFiling()
{
var query = string.Format(
@"SELECT TOP 1 BlueExpress.dbo.Filing.NameOfIssuerLine1
FROM BlueExpress.dbo.Filing
WHERE NameOfIssuerLine2 = 'Yes Autofile'
ORDER by FilingDateTime DESC");
return _coreConnection.ExecuteScalar<string>(query);
}