public async Task WhenRequestingNonSpecificReport_ReportIncludesCurrentWeekSummary() { DateTime date = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day - 2); var user = database.Users.First(); TimeEntryService timeEntryService = new TimeEntryService(user.UserId, database); await timeEntryService.CreateBillableTimeEntry(date, 2, 1); await timeEntryService.CreateNonBillableTimeEntry(date.AddDays(1), 3, null, TimeEntryTypeEnum.Vacation); await timeEntryService.CreateNonBillableTimeEntry(date.AddDays(2), 1, "flu", TimeEntryTypeEnum.Sick); date = date.AddMonths(1); await timeEntryService.CreateBillableTimeEntry(date, 2, 1); await timeEntryService.CreateNonBillableTimeEntry(date.AddDays(1), 3, null, TimeEntryTypeEnum.Vacation); await timeEntryService.CreateNonBillableTimeEntry(date.AddDays(2), 1, "flu", TimeEntryTypeEnum.Sick); var response = await orchestrator.HandleCommand(new SlashCommandPayload { text = "summary", user_id = user.SlackUserId, user_name = user.UserName }); response.Text.Should().Contain($"This Week Billable Hours: 2.0"); response.Text.Should().Contain($"This Week Vacation Hours: 3.0"); response.Text.Should().Contain($"This Week Sick Hours: 1.0"); response.Text.Should().Contain($"This Week Other Non-billable Hours: 0.0"); }
public async Task HandleCommand_deleteHours_returnsDeletedMessage_andDeletesHours() { var user = database.Users.First(); var timeEntryService = new TimeEntryService(user.UserId, database); await timeEntryService.CreateBillableTimeEntry(DateTime.UtcNow.Date, 7, 1); var slackMessage = await orchestrator.HandleCommand(new SlashCommandPayload() { text = "delete", user_id = user.SlackUserId, user_name = user.UserName }); slackMessage.Text.Should().Be($"Deleted {7d:F1} hours for date: {DateTime.UtcNow.Date:D}"); database.TimeEntries.Count().Should().Be(0); }
public async Task HandleCommand_hours_processesRecordOption() { var todayString = DateTime.UtcNow.ToString("D"); var textCommand = "record Au 8 wfh"; var slackMessage = await orchestrator.HandleCommand(new SlashCommandPayload() { text = textCommand, user_id = "UT33423", user_name = "James" }); slackMessage.Text.Should() .Be($"Registered *8.0 hours* for project *au* {todayString}. _Worked From Home_"); var timeEntry = await database.TimeEntries.FirstOrDefaultAsync(); timeEntry.Should().NotBeNull(); timeEntry.Hours.Should().Be(8); }
public async Task WhenRequestingProjects_ShowsAllProjects() { createAuClientAndProject(); createFakeProject(); var slackMessage = await orchestrator.HandleCommand(new SlashCommandPayload() { text = "projects", user_id = "UT33423", user_name = "James" }); slackMessage.Text.Should() .Contain("VSM - Au").And .Contain("proyecto - no client"); }
public async Task HandleCommand_web_returnsWebLinkInstructionMessage_andProvidesWebLink() { var user = database.Users.First(); var timeEntryService = new TimeEntryService(user.UserId, database); await timeEntryService.CreateBillableTimeEntry(DateTime.UtcNow.Date, 7, 1); var slackMessage = await orchestrator.HandleCommand(new SlashCommandPayload() { text = "web", user_id = user.SlackUserId, user_name = user.UserName }); var link = $"{WebAppUri}/account/linkslack?slackuser="******"Click this link {link} to access your hours on the web."); }
public async Task WhenRequestingHelp_ShowsMessageWithAllCommands() { var payload = CreateHelpRequest("help"); var slackMessage = await orchestrator.HandleCommand(payload); slackMessage.Text.Should() .Contain("*/hours* record - Allows the user to record hours.").And .Contain("*/hours* summary - Shows the users reported hours.").And .Contain("*/hours* delete - Deletes hours reported.").And .Contain("*/hours* projects - Lists available projects (project - client).").And .Contain("*/hours* web - Links user to web for hours report.").And .Contain("Add 'help' to each one of the options to get specific help. ex: */hours* record help"); }
public async Task <ActionResult <SlackMessage> > HandleCommand([FromForm] SlashCommandPayload slashCommandPayload) { var message = await messageOrchestrator.HandleCommand(slashCommandPayload); return(Ok(message)); }