Skip to content

Commit

Permalink
Fixed duplicate tests not being passed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ammelll committed Feb 8, 2025
1 parent 383cc24 commit fbfcb82
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
28 changes: 23 additions & 5 deletions lib/pages/project/project_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -922,16 +922,20 @@ class _ProjectPageState extends State<ProjectPage> {
String pathName = _paths[i].name;
RegExp exp = RegExp(r'\(\d+\)');
String source = pathName.substring(pathName.length - 3);
while (pathNames.contains(pathName)) {
String originalPathName = pathName;
while (pathNames.contains(pathName) || pathName == '$originalPathName (0)') {
source = pathName.substring(pathName.length - 3);
if (exp.hasMatch(source)) {
RegExpMatch? match = exp.firstMatch(source);
int index = int.parse(match![0]!.substring(1, 2)) + 1;
pathName = '${pathName.substring(0, pathName.length - 3)}($index)';
int index = int.parse(match![0]!.substring(1, 2));
while(pathNames.contains(pathName) || pathName.substring(pathName.length-3) == '(0)'){
index++;
pathName = '${pathName.substring(0, pathName.length - 3)}($index)';
}
} else {
pathName = '$pathName (1)';
pathName = '$pathName (0)';
}
}

setState(() {
_paths.add(_paths[i].duplicate(pathName));
_sortPaths(_pathSortValue);
Expand Down Expand Up @@ -1477,6 +1481,20 @@ class _ProjectPageState extends State<ProjectPage> {
String autoName = _autos[i].name;
RegExp exp = RegExp(r'\(\d+\)');
String source = autoName.substring(autoName.length - 3);
String originalAutoName = autoName;
while (autoNames.contains(autoName) || autoName == '$originalAutoName (0)') {
source = autoName.substring(autoName.length - 3);
if (exp.hasMatch(source)) {
RegExpMatch? match = exp.firstMatch(source);
int index = int.parse(match![0]!.substring(1, 2));
while(autoNames.contains(autoName) || autoName.substring(autoName.length-3) == '(0)'){
index++;
autoName = '${autoName.substring(0, autoName.length - 3)}($index)';
}
} else {
autoName = '$autoName (0)';
}
}
while (autoNames.contains(autoName)) {
if (exp.hasMatch(source)) {
RegExpMatch? match = exp.firstMatch(source);
Expand Down
2 changes: 1 addition & 1 deletion test/main_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ void main() {
));
await widgetTester.pumpAndSettle();
});
}
}
13 changes: 12 additions & 1 deletion test/pages/project/project_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,20 @@ void main() {

await widgetTester.tap(find.text('Duplicate'));
await widgetTester.pumpAndSettle();

for (var element in widgetTester.allWidgets){
print("TEXT ELEMENT " + element.toStringDeep());
}
expect(find.widgetWithText(ProjectItemCard, 'Example Path (2)'),
findsOneWidget);

await widgetTester.tap(menuButton);
await widgetTester.pumpAndSettle();

await widgetTester.tap(find.text('Duplicate'));
await widgetTester.pumpAndSettle();

expect(find.widgetWithText(ProjectItemCard, 'Example Path (3)'),
findsOneWidget);
});

testWidgets('duplicate auto', (widgetTester) async {
Expand Down

0 comments on commit fbfcb82

Please sign in to comment.