Skip to content

Commit

Permalink
tests: ensure exported file can be imported
Browse files Browse the repository at this point in the history
  • Loading branch information
darakeon committed Sep 17, 2024
1 parent be6de14 commit a7e3ffb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
27 changes: 27 additions & 0 deletions core/Tests/BusinessLogic/H.Attendant/f.ImportMovesFile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -817,3 +817,30 @@ Scenario: Hf84. Too long file name
Then I will receive this core error: InvalidArchiveName
And the pre-import data will not be recorded
And the lines will not be queued

Scenario: Hf85. Import exported file
Given I have moves of
| Description | Date | Category | Nature | Out | In | Value | Conversion | Detail |
| Sample Move Out | 2024-09-16 | Category | Out | Account Out | | 1 | | |
| Sample Move Out with Details | 2024-09-16 | Category | Out | Account Out | | 1 | | D1 |
| Sample Move In | 2024-09-16 | Category | In | | Account In | 1 | | |
| Sample Move In with Details | 2024-09-16 | Category | In | | Account In | 1 | | D1 |
| Sample Move Transfer | 2024-09-16 | Category | Transfer | Account Out | Account In | 1 | | |
| Sample Move Transfer with Details | 2024-09-16 | Category | Transfer | Account Out | Account In | 1 | | D1 |
| Sample Move Transfer with Conversion | 2024-09-16 | Category | Transfer | Account Out EUR | Account In BRL | 1 | 10 | |
| Sample Move Transfer with Conversion and Details | 2024-09-16 | Category | Transfer | Account Out EUR | Account In BRL | 1 | 10 | D1 |
And order start date 2024-09-16
And order end date 2024-09-16
And order account account_out
And order account account_in
And order account account_out_eur
And order account account_in_brl
And order category Category
And an export is ordered
And robot export the order
And test user login
And the order file is chosen to import
When import moves file
Then I will receive no core error
And the pre-import data will be recorded
And the lines will be queued
20 changes: 18 additions & 2 deletions core/Tests/BusinessLogic/Steps/_D.RobotStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,19 @@ public void GivenTheFileNameIsCharactersLong(Int32 nameSize)
csvName = $"{new String('D', nameSize - 4)}.csv";
}

[Given(@"the order file is chosen to import")]
public void GivenTheOrderFileIsChosenToImport()
{
var user = repos.User.GetByEmail(userEmail);
var order = repos.Order.ByUser(user).Single();

csvName = order.Path;

var fakeS3Path = Path.Combine(Cfg.S3.Directory, order.Path);

csvContent = File.ReadAllText(fakeS3Path);
}

[When(@"import moves file")]
public void WhenImportMovesFile()
{
Expand Down Expand Up @@ -780,8 +793,11 @@ public void ThenThePreImportDataWillBeRecorded()
var actual = CSVHelper.ToCsv(line, hasConversion);

var expected = csvLines[l + 1];
while (expected.EndsWith(",,,"))
expected = expected.Substring(0, expected.Length - 3);
while (expected.EndsWith(","))
expected = expected[..^1];

while (actual.EndsWith(","))
actual = actual[..^1];

Assert.That(actual, Is.EqualTo(expected));
}
Expand Down
2 changes: 1 addition & 1 deletion docs/todo/importer-exporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
- [x] Allow retry orders
- [x] Allow cancel orders
- [x] Record order creation / export and show
- [ ] Exported can be imported
- [x] Exported can be imported
- [ ] Integrate to site
- [ ] Integrate to robot

Expand Down

0 comments on commit a7e3ffb

Please sign in to comment.