-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathListTest.java
More file actions
2298 lines (1942 loc) · 109 KB
/
ListTest.java
File metadata and controls
2298 lines (1942 loc) · 109 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2018-2019 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.labkey.test.tests.list;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.labkey.remoteapi.CommandException;
import org.labkey.remoteapi.domain.Domain;
import org.labkey.remoteapi.domain.DomainResponse;
import org.labkey.remoteapi.domain.PropertyDescriptor;
import org.labkey.remoteapi.domain.SaveDomainCommand;
import org.labkey.remoteapi.query.Filter;
import org.labkey.serverapi.reader.TabLoader;
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.SortDirection;
import org.labkey.test.TestFileUtils;
import org.labkey.test.WebTestHelper;
import org.labkey.test.categories.Daily;
import org.labkey.test.categories.Data;
import org.labkey.test.categories.Hosting;
import org.labkey.test.components.CustomizeView;
import org.labkey.test.components.domain.AdvancedSettingsDialog;
import org.labkey.test.components.domain.BaseDomainDesigner;
import org.labkey.test.components.domain.ConditionalFormatDialog;
import org.labkey.test.components.domain.DomainFieldRow;
import org.labkey.test.components.domain.DomainFormPanel;
import org.labkey.test.components.ext4.Checkbox;
import org.labkey.test.components.list.AdvancedListSettingsDialog;
import org.labkey.test.pages.ImportDataPage;
import org.labkey.test.pages.list.EditListDefinitionPage;
import org.labkey.test.pages.list.GridPage;
import org.labkey.test.pages.query.UpdateQueryRowPage;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.params.FieldDefinition.StringLookup;
import org.labkey.test.params.FieldInfo;
import org.labkey.test.params.FieldKey;
import org.labkey.test.params.list.VarListDefinition;
import org.labkey.test.tests.AuditLogTest;
import org.labkey.test.util.AbstractDataRegionExportOrSignHelper.ColumnHeaderType;
import org.labkey.test.util.AuditLogHelper;
import org.labkey.test.util.DataRegionExportHelper;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.DomainUtils;
import org.labkey.test.util.EscapeUtil;
import org.labkey.test.util.LogMethod;
import org.labkey.test.util.Maps;
import org.labkey.test.util.OptionalFeatureHelper;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.TestDataGenerator;
import org.labkey.test.util.TextSearcher;
import org.labkey.test.util.data.TestDataUtils;
import org.labkey.test.util.search.SearchAdminAPIHelper;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.labkey.test.params.FieldDefinition.ColumnType;
import static org.labkey.test.params.FieldDefinition.DOMAIN_TRICKY_CHARACTERS;
import static org.labkey.test.util.DataRegionTable.DataRegion;
@Category({Daily.class, Data.class, Hosting.class})
@BaseWebDriverTest.ClassTimeout(minutes = 14)
public class ListTest extends BaseWebDriverTest
{
protected final static String PROJECT_VERIFY = "ListVerifyProject" ;//+ TRICKY_CHARACTERS_FOR_PROJECT_NAMES;
private final static String PROJECT_OTHER = "OtherListVerifyProject";
protected final static String LIST_NAME_COLORS = "A_Colors_" + DOMAIN_TRICKY_CHARACTERS;
protected final static String LIST_NAME_HTML_KEY = "A_HtmlKey_" + DOMAIN_TRICKY_CHARACTERS;
protected final static ColumnType LIST_KEY_TYPE = ColumnType.String;
protected final static String LIST_KEY_NAME = "Key";
boolean IS_POSTGRES = WebTestHelper.getDatabaseType() == WebTestHelper.DatabaseType.PostgreSQL;
protected final static String LIST_KEY_NAME2 = "Color \"`~!@#$%^&*()_-+={}[]|\\:;<>,.?/";
protected final static String LIST_KEY_NAME2_BULK = "\"Color \"\"`~!@#$%^&*()_-+={}[]|\\:;<>,.?/\"";
protected final static String LIST_DESCRIPTION = "A list of colors and what they are like";
protected final static String FAKE_COL_NAME = "FakeName";
protected final static String ALIASED_KEY_NAME = "Material";
protected final static String HIDDEN_TEXT = "CantSeeMe";
protected final FieldDefinition _listColFake = new FieldDefinition(FAKE_COL_NAME, ColumnType.String).setDescription("What the color is like");
protected final FieldDefinition _listColDesc = new FieldDefinition("Desc", ColumnType.String).setLabel("Description").setDescription("What the color is like");
protected final FieldDefinition _listColMonth = new FieldDefinition("Month", ColumnType.TextChoice)
.setTextChoiceValues(List.of("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
.setLabel("Month to Wear").setDescription("When to wear the color");
protected final FieldDefinition _listColTone = new FieldDefinition("JewelTone", ColumnType.Boolean).setLabel("Jewel Tone").setDescription("Am I a jewel tone?");
protected final FieldDefinition _listColGood = new FieldDefinition("Good", ColumnType.Integer).setLabel("Quality").setDescription("How nice the color is");
protected final FieldDefinition _listColHidden = new FieldDefinition("HiddenColumn", ColumnType.String).setLabel(HIDDEN_TEXT).setDescription("I should be hidden!");
protected final FieldDefinition _listColAliased = new FieldDefinition("Aliased,Column", ColumnType.String).setLabel("Element").setDescription("I show aliased data.");
private static final int TD_COLOR = 0;
private static final int TD_DESC = 1;
private static final int TD_TONE = 2;
private static final int TD_MONTH = 3;
private static final int TD_GOOD = 4;
private static final int TD_ALIAS = 5;
protected final static String[] VALID_MONTHS = { "Jan", "Apr", "Mar", "Feb" };
protected final static String[][] TEST_DATA = {
{ "Blue", "Green", "Red", "Yellow" },
{ "Light", "Mellow", "Robust", "ZanzibarMasinginiTanzaniaAfrica" },
{ "true", "false", "true", "false"},
VALID_MONTHS,
{ "10", "9", "8", "7"},
{ "Water", "Earth", "Fire", "Air"}};
private final static String LIST_ROW1 = TEST_DATA[TD_COLOR][0] + "\t" + TEST_DATA[TD_DESC][0] + "\t" + TEST_DATA[TD_TONE][0] + "\t" + VALID_MONTHS[0];
private final static String LIST_ROW2 = TEST_DATA[TD_COLOR][1] + "\t" + TEST_DATA[TD_DESC][1] + "\t" + TEST_DATA[TD_TONE][1] + "\t" + VALID_MONTHS[1];
private final static String LIST_ROW3 = TEST_DATA[TD_COLOR][2] + "\t" + TEST_DATA[TD_DESC][2] + "\t" + TEST_DATA[TD_TONE][2] + "\t" + VALID_MONTHS[2];
private final String LIST_DATA =
LIST_KEY_NAME2_BULK + "\t" + FAKE_COL_NAME + "\t" + _listColTone.getName() + "\t" + _listColMonth.getName() + "\n" +
LIST_ROW1 + "\n" +
LIST_ROW2 + "\n" +
LIST_ROW3;
private final String LIST_DATA2 =
LIST_KEY_NAME2_BULK + "\t" + FAKE_COL_NAME + "\t" + _listColTone.getName() + "\t" + _listColMonth.getName() + "\t" + _listColGood.getName() + "\t" + ALIASED_KEY_NAME + "\t" + _listColHidden.getName() + "\n" +
LIST_ROW1 + "\t" + TEST_DATA[TD_GOOD][0] + "\t" + TEST_DATA[TD_ALIAS][0] + "\t" + HIDDEN_TEXT + "\n" +
LIST_ROW2 + "\t" + TEST_DATA[TD_GOOD][1] + "\t" + TEST_DATA[TD_ALIAS][1] + "\t" + HIDDEN_TEXT + "\n" +
LIST_ROW3 + "\t" + TEST_DATA[TD_GOOD][2] + "\t" + TEST_DATA[TD_ALIAS][2] + "\t" + HIDDEN_TEXT;
private final static String TEST_FAIL = "testfail";
private final static String TEST_FAIL2 = "testfail\n2\n";
private final String TEST_FAIL3 = LIST_KEY_NAME2 + "\t" + FAKE_COL_NAME + "\t" + _listColMonth.getName() + "\n" +
LIST_ROW1;
private final static String TEST_VIEW = "list_view";
private final static String LIST2_NAME_CARS = "Cars_" + DOMAIN_TRICKY_CHARACTERS;
protected final static ColumnType LIST2_KEY_TYPE = ColumnType.String;
protected final static String LIST2_KEY_NAME = "Car";
protected final FieldDefinition _list2Col1 = new FieldDefinition(LIST_KEY_NAME2, new StringLookup(null, "lists", LIST_NAME_COLORS)).setDescription("The color of the car");
private final static String LIST2_KEY = "Car1";
private final static String LIST2_FOREIGN_KEY = "Blue";
private final static String LIST2_KEY2 = "Car2";
private final static String LIST2_FOREIGN_KEY2 = "Green";
private final static String LIST2_FOREIGN_KEY_OUTSIDE = "Guy";
private final static String LIST2_KEY3 = "Car3";
private final static String LIST2_FOREIGN_KEY3 = "Red";
private final static String LIST2_KEY4 = "Car4";
private final static String LIST2_FOREIGN_KEY4 = "Brown";
private final static String LIST3_NAME_OWNERS = "Owners";
private final static ColumnType LIST3_KEY_TYPE = ColumnType.String;
private final static String LIST3_KEY_NAME = "Owner";
private final FieldDefinition _list3Col2 = new FieldDefinition("Wealth", ColumnType.String);
protected final FieldDefinition _list3Col1 = new FieldDefinition(LIST3_KEY_NAME, new StringLookup(PROJECT_OTHER, "lists", LIST3_NAME_OWNERS)).setDescription("Who owns the car");
private final static String LIST3_COL2 = "Rich";
private final String LIST2_DATA =
LIST2_KEY_NAME + "\t" + LIST_KEY_NAME2_BULK + "\t" + LIST3_KEY_NAME + "\n" +
LIST2_KEY + "\t" + LIST2_FOREIGN_KEY + "\n" +
LIST2_KEY2 + "\t" + LIST2_FOREIGN_KEY2 + "\t" + LIST2_FOREIGN_KEY_OUTSIDE + "\n" +
LIST2_KEY3 + "\t" + LIST2_FOREIGN_KEY3 + "\n" +
LIST2_KEY4 + "\t" + LIST2_FOREIGN_KEY4;
private final String LIST3_DATA =
LIST3_KEY_NAME + "\t" + _list3Col2.getName() + "\n" +
LIST2_FOREIGN_KEY_OUTSIDE + "\t" + LIST3_COL2;
public static final String LIST_AUDIT_EVENT = "List events";
public static final String DOMAIN_AUDIT_EVENT = "Domain events";
private final File EXCEL_DATA_FILE = TestFileUtils.getSampleData("dataLoading/excel/fruits.xls");
private final File TSV_DATA_FILE = TestFileUtils.getSampleData("dataLoading/excel/fruits.tsv");
private final File EXCEL_APILIST_FILE = TestFileUtils.getSampleData("dataLoading/excel/ClientAPITestList.xls");
private final File TSV_SAMPLE_FILE = TestFileUtils.getSampleData("fileTypes/tsv_sample.tsv");
private final String TSV_LIST_NAME = "Fruits from TSV";
private final AuditLogHelper _auditLogHelper = new AuditLogHelper(this);
@Override
public List<String> getAssociatedModules()
{
return Arrays.asList("list");
}
@Override
protected String getProjectName()
{
return PROJECT_VERIFY;
}
@Override
protected void doCleanup(boolean afterTest)
{
_containerHelper.deleteProject(PROJECT_VERIFY, afterTest);
_containerHelper.deleteProject(PROJECT_OTHER, afterTest);
}
@BeforeClass
public static void setupProject()
{
ListTest init = getCurrentTest();
init.doSetup();
}
private void doSetup()
{
log("Setup project and list module");
_containerHelper.createProject(PROJECT_VERIFY, null);
log("Create second project");
_containerHelper.createProject(PROJECT_OTHER, null);
goToProjectHome();
}
@Before
public void preTest()
{
goToProjectHome();
if (isElementPresent(PortalHelper.Locators.webPartTitle("Search")))
new PortalHelper(this).removeWebPart("Search");
}
@Override
protected Set<String> getOrphanedViews()
{
Set<String> views = new HashSet<>();
views.add(TEST_VIEW);
return views;
}
@LogMethod
protected void setUpListFinish()
{
// delete existing rows
log("Test deleting rows");
DataRegionTable table = new DataRegionTable("query", getDriver());
table.checkAllOnPage();
table.deleteSelectedRows();
// load test data
_listHelper.clickImportData()
.setText(LIST_DATA2)
.submit();
}
/** Issue 53796: 25.3 -> 25.7: DataRegion.getChecked() incorrectly HTML encodes the results */
@Test
public void testKeyWithHtmlCharacters()
{
_listHelper.createList(getProjectName(), LIST_NAME_HTML_KEY, new FieldDefinition(LIST_KEY_NAME2, LIST_KEY_TYPE));
ImportDataPage importDataPage = _listHelper.clickImportData();
String value = "<>ThisIsTheKeyValueWithHtmlCharacters</>";
importDataPage.setText(LIST_KEY_NAME2_BULK + "\n" + value);
importDataPage.submit();
assertTextPresent(value);
final DataRegionTable dt = DataRegion(getDriver()).withName("query").find();
dt.checkAllOnPage();
@SuppressWarnings("unchecked") List<String> checked = (List<String>)executeScript("return LABKEY.DataRegions.query.getChecked()");
assertEquals(Arrays.asList(value), checked);
dt.deleteSelectedRows();
assertTextNotPresent(value);
}
@LogMethod
protected void setUpList()
{
// TODO: Break this up into explicit test cases and remove redundant test coverage.
// But at least now it's only called from the one test case that relies on this list, testCustomViews().
// Previously it was called from the @BeforeClass method, even though none of the other test cases use this list.
log("Add list -- " + LIST_NAME_COLORS);
_listHelper.createList(getProjectName(), LIST_NAME_COLORS, new FieldDefinition(LIST_KEY_NAME2, LIST_KEY_TYPE), _listColFake,
_listColMonth, _listColTone);
log("Add description and test edit");
_listHelper.goToEditDesign(LIST_NAME_COLORS)
.setDescription(LIST_DESCRIPTION)
.clickSave();
log("Test upload data");
ImportDataPage importDataPage = _listHelper.clickImportData();
importDataPage.submitExpectingErrorContaining("Form contains no data");
importDataPage.setText(TEST_FAIL);
importDataPage.submitExpectingErrorContaining("No rows were inserted.");
importDataPage.setText(TEST_FAIL2);
importDataPage.submitExpectingErrorContaining("Data does not contain required field: Color");
importDataPage.setText(TEST_FAIL3);
importDataPage.submitExpectingErrorContaining(String.format("Value 'true' for field '%s' is invalid.", _listColMonth.getLabel()));
importDataPage.setText(LIST_DATA);
importDataPage.submit();
log("Check upload worked correctly");
assertTextPresent(
_listColMonth.getLabel(),
TEST_DATA[TD_COLOR][0],
TEST_DATA[TD_DESC][1],
TEST_DATA[TD_MONTH][2]);
DataRegionTable table = new DataRegionTable("query", getDriver());
assertEquals(TEST_DATA[TD_TONE][0], table.getDataAsText(table.getRowIndex(TEST_DATA[TD_COLOR][0]), _listColTone.getLabel()));
assertEquals(TEST_DATA[TD_TONE][1], table.getDataAsText(table.getRowIndex(TEST_DATA[TD_COLOR][1]), _listColTone.getLabel()));
assertEquals(TEST_DATA[TD_TONE][2], table.getDataAsText(table.getRowIndex(TEST_DATA[TD_COLOR][2]), _listColTone.getLabel()));
log("Test check/uncheck of checkboxes");
// Second row (Green)
assertEquals(1, table.getRowIndex(TEST_DATA[TD_COLOR][1]));
table.clickEditRow(1);
setFormElement(Locator.name(EscapeUtil.getFormFieldName(_listColMonth.getName())), VALID_MONTHS[1]); // Has a funny format -- need to post converted date
checkCheckbox(Locator.checkboxByName(EscapeUtil.getFormFieldName("JewelTone")));
clickButton("Submit");
// Third row (Red)
assertEquals(2, table.getRowIndex(TEST_DATA[TD_COLOR][2]));
table.clickEditRow(2);
setFormElement(Locator.name(EscapeUtil.getFormFieldName(_listColMonth.getName())), VALID_MONTHS[2]); // Has a funny format -- need to post converted date
uncheckCheckbox(Locator.checkboxByName(EscapeUtil.getFormFieldName("JewelTone")));
clickButton("Submit");
table = new DataRegionTable("query", getDriver());
assertEquals(TEST_DATA[TD_TONE][0], table.getDataAsText(table.getRowIndex(TEST_DATA[TD_COLOR][0]), _listColTone.getLabel()));
assertEquals("true", table.getDataAsText(table.getRowIndex(TEST_DATA[TD_COLOR][1]), _listColTone.getLabel()));
assertEquals("false", table.getDataAsText(table.getRowIndex(TEST_DATA[TD_COLOR][2]), _listColTone.getLabel()));
log("Test edit and adding new field with imported data present");
clickTab("List");
_listHelper.goToList(LIST_NAME_COLORS);
EditListDefinitionPage listDefinitionPage = _listHelper.goToEditDesign(LIST_NAME_COLORS);
DomainFormPanel fieldsPanel = listDefinitionPage.getFieldsPanel();
fieldsPanel.getField(_listColFake.getName())
.setName(_listColDesc.getName())
.setLabel(_listColDesc.getLabel())
.setImportAliases(_listColFake.getName());
fieldsPanel.addField(_listColGood);
// Create "Hidden Field" and remove from all views.
fieldsPanel.addField(_listColHidden);
fieldsPanel.getField(_listColHidden.getName())
.showFieldOnDefaultView(false)
.showFieldOnInsertView(false)
.showFieldOnUpdateView(false)
.showFieldOnDetailsView(false);
fieldsPanel.addField(_listColAliased);
fieldsPanel.getField(_listColAliased.getName())
.setImportAliases(ALIASED_KEY_NAME);
listDefinitionPage.clickSave();
log("Check new field was added correctly");
assertTextPresent(_listColGood.getName());
log("Set title field of 'Colors' to 'Desc'");
listDefinitionPage = _listHelper.goToEditDesign(LIST_NAME_COLORS);
listDefinitionPage.openAdvancedListSettings().setFieldUsedForDisplayTitle("Desc").clickApply();
listDefinitionPage.clickSave();
assertTextPresent(
TEST_DATA[TD_COLOR][0],
TEST_DATA[TD_DESC][1],
TEST_DATA[TD_MONTH][2]);
assertTextNotPresent(HIDDEN_TEXT); // Hidden from Grid view.
setUpListFinish();
log("Check that data was added correctly");
assertTextPresent(
TEST_DATA[TD_COLOR][0],
TEST_DATA[TD_DESC][1],
TEST_DATA[TD_MONTH][2],
TEST_DATA[TD_GOOD][0],
TEST_DATA[TD_GOOD][1],
TEST_DATA[TD_GOOD][2],
TEST_DATA[TD_ALIAS][0],
TEST_DATA[TD_ALIAS][1],
TEST_DATA[TD_ALIAS][2]);
log("Check that hidden column is hidden.");
DataRegionTable regionTable = new DataRegionTable("query", getDriver());
clickAndWait(regionTable.detailsLink(0));
assertTextNotPresent(HIDDEN_TEXT); // Hidden from details view.
clickButton("Edit");
assertTextNotPresent(HIDDEN_TEXT); // Hidden from update view.
clickButton("Cancel");
log("Test inserting new row");
regionTable = new DataRegionTable("query", getDriver());
regionTable.clickInsertNewRow();
assertTextNotPresent(HIDDEN_TEXT); // Hidden from insert view.
String html = getHtmlSource();
assertTrue("Description \"" + _listColDesc.getDescription() + "\" not present.", html.contains(_listColDesc.getDescription()));
assertTrue("Description \"" + _listColTone.getDescription() + "\" not present.", html.contains(_listColTone.getDescription()));
setFormElement(Locator.name(EscapeUtil.getFormFieldName(_listColDesc.getName())), TEST_DATA[TD_DESC][3]);
// Jewel Tone checkbox is left blank -- we'll make sure it's posted as false below
setFormElement(Locator.name(EscapeUtil.getFormFieldName(_listColGood.getName())), TEST_DATA[TD_GOOD][3]);
clickButton("Submit");
assertTextPresent("This field is required");
setFormElement(Locator.name(EscapeUtil.getFormFieldName(LIST_KEY_NAME2)), TEST_DATA[TD_COLOR][3]);
clickButton("Submit");
log("Check new row was added");
assertTextPresent(
TEST_DATA[TD_COLOR][3],
TEST_DATA[TD_DESC][3],
TEST_DATA[TD_TONE][3]);
table = new DataRegionTable("query", getDriver());
assertEquals(TEST_DATA[TD_TONE][2], table.getDataAsText(2, _listColTone.getLabel()));
assertEquals(3, table.getRowIndex(TEST_DATA[TD_COLOR][3]));
assertEquals(TEST_DATA[TD_TONE][3], table.getDataAsText(3, _listColTone.getLabel()));
log("Check hidden field is hidden only where specified.");
listDefinitionPage = _listHelper.goToEditDesign(LIST_NAME_COLORS);
fieldsPanel = listDefinitionPage.getFieldsPanel();
fieldsPanel.getField(_listColHidden.getName()) // Select Hidden field.
.showFieldOnDefaultView(true);
listDefinitionPage.clickSave();
log("Check that hidden column is hidden.");
assertTextPresent(HIDDEN_TEXT); // Not hidden from grid view.
table = new DataRegionTable("query", getDriver());
clickAndWait(table.detailsLink(0));
assertTextNotPresent(HIDDEN_TEXT); // Hidden from details view.
assertTextBefore(_listColMonth.getLabel(), _listColTone.getLabel());
clickButton("Edit");
assertTextNotPresent(HIDDEN_TEXT); // Hidden from update view.
assertTextBefore(_listColMonth.getLabel(), _listColTone.getLabel());
clickButton("Cancel");
table.clickInsertNewRow();
assertTextNotPresent(HIDDEN_TEXT); // Hidden from insert view.
assertTextBefore(_listColMonth.getLabel(), _listColTone.getLabel());
clickButton("Cancel");
listDefinitionPage = _listHelper.goToEditDesign(LIST_NAME_COLORS);
fieldsPanel = listDefinitionPage.getFieldsPanel();
fieldsPanel.getField(_listColHidden.getName()) // Select Hidden field.
.showFieldOnDefaultView(false)
.showFieldOnInsertView(true);
listDefinitionPage.clickSave();
assertTextNotPresent(HIDDEN_TEXT); // Hidden from grid view.
table = new DataRegionTable("query", getDriver());
clickAndWait(table.detailsLink(0));
assertTextNotPresent(HIDDEN_TEXT); // Hidden from details view.
clickButton("Edit");
assertTextNotPresent(HIDDEN_TEXT); // Hidden from update view.
clickButton("Cancel");
table.clickInsertNewRow();
assertTextPresent(HIDDEN_TEXT); // Not hidden from insert view.
clickButton("Cancel");
listDefinitionPage = _listHelper.goToEditDesign(LIST_NAME_COLORS);
fieldsPanel = listDefinitionPage.getFieldsPanel();
fieldsPanel.getField(_listColHidden.getName()) // Select Hidden field.
.showFieldOnInsertView(false)
.showFieldOnUpdateView(true);
listDefinitionPage.clickSave();
assertTextNotPresent(HIDDEN_TEXT); // Hidden from grid view.
table = new DataRegionTable("query", getDriver());
clickAndWait(table.detailsLink(0));
assertTextNotPresent(HIDDEN_TEXT); // Hidden from details view.
clickButton("Edit");
assertTextPresent(HIDDEN_TEXT); // Not hidden from update view.
clickButton("Cancel");
table.clickInsertNewRow();
assertTextNotPresent(HIDDEN_TEXT); // Hidden from insert view.
clickButton("Cancel");
listDefinitionPage = _listHelper.goToEditDesign(LIST_NAME_COLORS);
fieldsPanel = listDefinitionPage.getFieldsPanel();
fieldsPanel.getField(_listColHidden.getName()) // Select Hidden field.
.showFieldOnUpdateView(false)
.showFieldOnDetailsView(true);
listDefinitionPage.clickSave();
assertTextNotPresent(HIDDEN_TEXT); // Hidden from grid view.
table = new DataRegionTable("query", getDriver());
clickAndWait(table.detailsLink(0));
assertTextPresent(HIDDEN_TEXT); // Not hidden from details view.
clickButton("Edit");
assertTextNotPresent(HIDDEN_TEXT); // Hidden from update view.
clickButton("Cancel");
table.clickInsertNewRow();
assertTextNotPresent(HIDDEN_TEXT); // Hidden from insert view.
clickButton("Cancel");
}
@Test
public void testNameTrimming()
{
goToProjectHome();
String trimmedName = "Trimmings";
log("Add list with leading spaces");
_listHelper.createList(getProjectName(), " Trimmings", new FieldDefinition(LIST_KEY_NAME2, LIST_KEY_TYPE), _listColFake);
log("Assure we can go to the page with the trimmed name");
GridPage grid = GridPage.beginAt(this, getProjectName(), trimmedName);
grid.click(Locator.linkWithText("Design"));
EditListDefinitionPage editList = new EditListDefinitionPage(this.getDriver());
checker().withScreenshot().verifyEquals("Name not trimmed as expected", trimmedName, editList.getName());
trimmedName = "Extra Trimmings";
log("Add list with leading and trailing spaces");
_listHelper.createList(getProjectName(), " Extra Trimmings ", new FieldDefinition(LIST_KEY_NAME2, LIST_KEY_TYPE), _listColFake);
log("Assure we can go to the page with the trimmed name");
grid = GridPage.beginAt(this, getProjectName(), trimmedName);
grid.click(Locator.linkWithText("Design"));
editList = new EditListDefinitionPage(this.getDriver());
checker().withScreenshot().verifyEquals("Name not trimmed as expected", trimmedName, editList.getName());
}
@Test // Issue 52339
public void testLongName()
{
String listName = "A_+-:''.¡™£¢∞§¶•ªº–≠œ∑´®†¥¨ˆøπ“‘«æ…¬˚∆˙©√ƒ∂ßΩ≈ç√∫µ≤≥÷‹›fifl‡°·‚—±⁄€‹›‡‰Æ«»¢∫√∑∏∂";
var fieldWithDefault = FieldInfo.random("With Default", ColumnType.String);
EditListDefinitionPage listEditPage = _listHelper.beginCreateList(getProjectName(), listName);
listEditPage.manuallyDefineFieldsWithAutoIncrementingKey("Key");
listEditPage.addField(fieldWithDefault.getFieldDefinition());
listEditPage.clickSave();
listEditPage = _listHelper.goToEditDesign(listName);
var page = listEditPage.getFieldsPanel()
.expand()
.getField(fieldWithDefault.getName())
.clickAdvancedSettings()
.clickDefaultValuesLink();
var input = Locator.tagContainingText("td", fieldWithDefault.getLabel()).followingSibling("td")
.descendant("input").findElement(page.getDriver());
setFormElement(input, "42");
clickButton("Save Defaults");
_listHelper.beginAtList(getProjectName(), listName);
DataRegionTable list = new DataRegionTable("query", getDriver());
UpdateQueryRowPage updatePage = list.clickInsertNewRow();
checker().verifyEquals("Default value not as expected ", "42", updatePage.getTextInputValue(fieldWithDefault.getName()));
updatePage.submit();
}
/* Issue 51572: Bug with creating a new list by uploading a csv file in "UTF-8 with BOM" format
*/
@Test
public void testCreateListWithBOMFile()
{
String listName = TestDataGenerator.randomDomainName("From BOM File", DomainUtils.DomainKind.IntList);
File bomFile = TestFileUtils.getSampleData("lists/TestUTF8_BOM.csv");
EditListDefinitionPage listEditPage = _listHelper.beginCreateList(getProjectName(), listName);
listEditPage.getFieldsPanel()
.setInferFieldFile(bomFile);
String keyName = "KeyValue";
listEditPage.selectKeyField(keyName);
listEditPage.clickSave();
List<FieldDefinition> fields = List.of(
new FieldDefinition(keyName, ColumnType.Integer),
new FieldDefinition("A", ColumnType.String),
new FieldDefinition("B", ColumnType.String),
new FieldDefinition("C", ColumnType.String)
);
String [][] data = { {"101","A2","B2","C2"},
{"102","A3","B3","C3"},
{"103","A4","B4","C4"},
{"104","A5","B5","C5"},
{"105","A6","B6","C6"},
{"106","A7","B7","C7"},
{"107","A8","B8","C8"},
{"108","A9","B9","C9"},
{"109","A10","B10","C10"},
{"110","A11","B11","C11"} };
_listHelper.verifyListData(fields, data, checker());
}
@Test
public void testCustomViews()
{
goToProjectHome();
setUpList();
goToProjectHome();
waitAndClickAndWait(Locator.linkWithText(LIST_NAME_COLORS));
log("Test Sort and Filter in Data View");
DataRegionTable region = new DataRegionTable("query", getDriver());
region.setSort(_listColDesc.getName(), SortDirection.ASC);
assertTextBefore(TEST_DATA[TD_COLOR][0], TEST_DATA[TD_COLOR][1]);
clearSortTest();
region.setFilter(_listColGood.getName(), "Is Greater Than", "7");
assertTextNotPresent(TEST_DATA[TD_COLOR][3]);
log("Test Customize View");
// Re-navigate to the list to clear filters and sorts
clickTab("List");
waitAndClickAndWait(Locator.linkWithText(LIST_NAME_COLORS));
_customizeViewsHelper.openCustomizeViewPanel();
_customizeViewsHelper.removeColumn(_listColGood.getName());
_customizeViewsHelper.addFilter(_listColGood.getName(), "Is Less Than", "10");
_customizeViewsHelper.addSort(_listColMonth.getName(), SortDirection.ASC);
_customizeViewsHelper.saveCustomView(TEST_VIEW);
log("Check Customize View worked");
assertTextPresent(TEST_DATA[TD_COLOR][3]);
// Sorting is different between MSSQL and postgres if one of the values is empty / blank.
if (WebTestHelper.getDatabaseType() == WebTestHelper.DatabaseType.MicrosoftSQLServer)
{
assertTextPresentInThisOrder(TEST_DATA[TD_COLOR][3], TEST_DATA[TD_COLOR][1], TEST_DATA[TD_COLOR][2]);
}
else
{
assertTextPresentInThisOrder(TEST_DATA[TD_COLOR][1], TEST_DATA[TD_COLOR][2], TEST_DATA[TD_COLOR][3]);
}
assertTextNotPresent(TEST_DATA[TD_COLOR][0], _listColGood.getLabel());
log("4725: Check Customize View can't remove all fields");
_customizeViewsHelper.openCustomizeViewPanel();
_customizeViewsHelper.removeColumn(EscapeUtil.fieldKeyEncodePart(LIST_KEY_NAME2));
_customizeViewsHelper.removeColumn(_listColDesc.getName());
_customizeViewsHelper.removeColumn(_listColMonth.getName());
_customizeViewsHelper.removeColumn(_listColTone.getName());
_customizeViewsHelper.removeColumn(EscapeUtil.fieldKeyEncodePart(_listColAliased.getName()));
_customizeViewsHelper.clickViewGrid();
assertExt4MsgBox("You must select at least one field to display in the grid.", "OK");
_customizeViewsHelper.closePanel();
log("Test Export");
File tableFile = new DataRegionExportHelper(new DataRegionTable("query", getDriver())).exportText();
TextSearcher tsvSearcher = new TextSearcher(tableFile);
if (WebTestHelper.getDatabaseType() == WebTestHelper.DatabaseType.MicrosoftSQLServer)
{
assertTextPresentInThisOrder(tsvSearcher, TEST_DATA[TD_COLOR][3], TEST_DATA[TD_COLOR][1], TEST_DATA[TD_COLOR][2]);
}
else
{
assertTextPresentInThisOrder(tsvSearcher, TEST_DATA[TD_COLOR][1], TEST_DATA[TD_COLOR][2], TEST_DATA[TD_COLOR][3]);
}
assertTextNotPresent(tsvSearcher, TEST_DATA[TD_COLOR][0], _listColGood.getLabel());
filterTest();
clickProject(getProjectName());
log("Test that sort only affects one web part");
DataRegionTable firstList = DataRegion(getDriver()).find();
DataRegionTable secondList = DataRegion(getDriver()).index(1).find();
firstList.setSort(_listColGood.getName(), SortDirection.ASC);
List<String> expectedColumn = new ArrayList<>(Arrays.asList(TEST_DATA[TD_GOOD]));
List<String> firstListColumn = secondList.getColumnDataAsText(_listColGood.getName());
assertEquals("Second query webpart shouldn't have been sorted", expectedColumn, firstListColumn);
expectedColumn.sort(Comparator.comparingInt(Integer::parseInt)); // Parse to check sorting of 10 vs 7, 8, 9
List<String> secondListColumn = firstList.getColumnDataAsText(_listColGood.getName());
assertEquals("First query webpart should have been sorted", expectedColumn, secondListColumn);
log("Test list history");
clickAndWait(Locator.linkWithText("manage lists"));
DataRegionTable drt = new DataRegionTable.DataRegionFinder(getDriver()).find();
drt.setFilter("Name", "Equals", LIST_NAME_COLORS);
waitFor(()->drt.getDataRowCount()==1,
String.format("DataRegion table did not filter to list %s", LIST_NAME_COLORS), 2_500);
waitAndClickAndWait(Locator.linkWithText("view history"));
// Wait for the header to load on the page.
waitForElementToBeVisible(Locator.tagContainingText("h3", ":History"));
checker().verifyTrue("DataRegions didn't load.",
waitFor(()->new DataRegionTable.DataRegionFinder(getDriver()).findAll().size() == 2, 3_000));
checker().wrapAssertion(()->assertTextPresent("record was modified", 2)); // An existing list record was modified
checker().wrapAssertion(()->assertTextPresent(" was created. The column(s) of domain ", 1));// Create domain and update columns combined into a single event
checker().wrapAssertion(()->assertTextPresent(" were modified.", 7)); // The column(s) of LIST_NAME_COLORS domain were modified
checker().wrapAssertion(()->assertTextPresent("The descriptor of domain", 1)); // The description LIST_NAME_COLORS domain were modified
checker().wrapAssertion(()->assertTextPresent("Bulk inserted", 2));
checker().wrapAssertion(()->assertTextPresent("A new list record was inserted", 1));
checker().wrapAssertion(()->assertTextPresent("was created", 2)); // Once for the list, once for the domain
// List insert/update events should each have a link to the list item that was modified, but the other events won't have a link
checker().wrapAssertion(()->assertEquals("details Links", 6/*List Events*/ + 8/*Domain Audit*/, DataRegionTable.detailsLinkLocator().findElements(getDriver()).size()));
checker().wrapAssertion(()->assertEquals("Project Links", 17, DataRegionTable.Locators.table().append(Locator.linkWithText(PROJECT_VERIFY)).findElements(getDriver()).size()));
checker().wrapAssertion(()->assertEquals("List Links", 17, DataRegionTable.Locators.table().append(Locator.linkWithText(LIST_NAME_COLORS)).findElements(getDriver()).size()));
checker().screenShotIfNewError("List_History_Error");
DataRegionTable dataRegionTable = new DataRegionTable("query", getDriver());
dataRegionTable.clickRowDetails(0);
checker().wrapAssertion(()->assertTextPresent("List Item Details"));
checker().wrapAssertion(()->assertTextNotPresent("No details available for this event.", "Unable to find the audit history detail for this event"));
checker().screenShotIfNewError("History_Detail_Error");
clickButton("Done");
waitAndClickAndWait(Locator.linkWithText(PROJECT_VERIFY).index(3));
log("Test single list web part");
new PortalHelper(this).addWebPart("List - Single");
setFormElement(Locator.name("title"), "This is my single list web part title");
_ext4Helper.selectComboBoxItem("List:", LIST_NAME_COLORS);
clickButton("Submit");
waitForText(DataRegionTable.getImportBulkDataText());
assertTextPresent("View Design");
new DataRegionTable.DataRegionFinder(getDriver()).index(2).waitFor();
Locator loc = Locator.linkWithSpan("This is my single list web part title");
scrollIntoView(loc);
clickAndWait(loc, WAIT_FOR_PAGE);
assertTextPresent("Colors", "Views");
log("Add List -- " + LIST3_NAME_OWNERS);
_listHelper.createList(PROJECT_OTHER, LIST3_NAME_OWNERS, new FieldDefinition(LIST3_KEY_NAME, LIST3_KEY_TYPE), _list3Col2);
log("Upload data to second list");
_listHelper.goToList(LIST3_NAME_OWNERS);
_listHelper.uploadData(LIST3_DATA);
log("Add list -- " + LIST2_NAME_CARS);
_listHelper.createList(PROJECT_VERIFY, LIST2_NAME_CARS, new FieldDefinition(LIST2_KEY_NAME, LIST2_KEY_TYPE), _list2Col1, _list3Col1);
log("Upload data to second list");
_listHelper.goToList(LIST2_NAME_CARS);
_listHelper.uploadData(LIST2_DATA);
log("Check that upload worked");
assertTextPresent(
LIST2_KEY,
LIST2_KEY2,
LIST2_KEY3,
LIST2_KEY4);
log("Check that reference worked");
_customizeViewsHelper.openCustomizeViewPanel();
_customizeViewsHelper.addColumn(FieldKey.fromParts(_list2Col1.getName(), _listColDesc.getName()));
_customizeViewsHelper.addColumn(FieldKey.fromParts(_list2Col1.getName(), _listColMonth.getName()));
_customizeViewsHelper.addColumn(FieldKey.fromParts(_list2Col1.getName(), _listColGood.getName()));
_customizeViewsHelper.addFilter(FieldKey.fromParts(_list2Col1.getName(), _listColGood.getName()), "Is Less Than", "10");
_customizeViewsHelper.addSort(FieldKey.fromParts(_list2Col1.getName(), _listColGood.getName()), SortDirection.ASC);
_customizeViewsHelper.addColumn(_list3Col1.getName() + "/" + _list3Col1.getName());
_customizeViewsHelper.addColumn(_list3Col1.getName() + "/" + _list3Col2.getName());
_customizeViewsHelper.saveCustomView(TEST_VIEW);
log("Check adding referenced fields worked");
waitForText(WAIT_FOR_JAVASCRIPT, _listColDesc.getLabel());
assertTextPresent(
_listColDesc.getLabel(),
_listColMonth.getLabel(),
_listColGood.getLabel(),
LIST2_FOREIGN_KEY_OUTSIDE,
LIST3_COL2);
assertTextNotPresent(LIST2_KEY);
assertTextBefore(LIST2_KEY3, LIST2_KEY2);
assertTextNotPresent(LIST2_KEY4);
log("Test export");
DataRegionTable list = new DataRegionTable("query", getDriver());
waitForElement(Locator.tagWithAttribute("a", "data-original-title", "Delete"));
DataRegionExportHelper helper = new DataRegionExportHelper(list);
File expFile = helper.exportText(ColumnHeaderType.FieldKey, DataRegionExportHelper.TextSeparator.COMMA);
// Use TabLoader, it is easier to use than TextSearch when dealing with 'tricky characters'.
TabLoader tabLoader = new TabLoader(expFile, true);
tabLoader.parseAsCSV();
// According to Issue 52318 field keys are encoded.
List<String> expectedValues = List.of(EscapeUtil.fieldKeyEncodePart(LIST_KEY_NAME2) + '/' + _listColDesc.getName(),
EscapeUtil.fieldKeyEncodePart(LIST_KEY_NAME2) + '/' + _listColMonth.getName(),
EscapeUtil.fieldKeyEncodePart(LIST_KEY_NAME2) + '/' + _listColGood.getName());
List<Map<String, Object>> exportedFileData = tabLoader.load();
List<String> actualValues = exportedFileData.get(0).keySet().stream().toList();
assertTrue("Exported file does not contain expected header values.",
actualValues.containsAll(expectedValues));
assertEquals("Key value in row 0 not as expected.",
LIST2_KEY3, exportedFileData.get(0).get(LIST2_KEY_NAME));
assertEquals("Key value in row 1 not as expected.",
LIST2_KEY2, exportedFileData.get(1).get(LIST2_KEY_NAME));
assertEquals("Value of foreign key in row 1 not as expected.",
LIST2_FOREIGN_KEY_OUTSIDE, exportedFileData.get(1).get(LIST3_KEY_NAME));
assertEquals("Value of 'Wealth' column in row 1 not as expected.",
LIST3_COL2, exportedFileData.get(1).get(LIST3_KEY_NAME + "/" + _list3Col2.getName()));
log("Test edit row");
list.updateRow(LIST2_KEY3, Maps.of(
LIST_KEY_NAME2, TEST_DATA[TD_DESC][1],
LIST3_KEY_NAME, LIST2_FOREIGN_KEY_OUTSIDE));
final DataRegionTable dt = DataRegion(getDriver()).withName("query").find();
dt.goToView("Default");
assertTextPresent(TEST_DATA[TD_DESC][1], 2);
log("Test deleting rows");
dataRegionTable.checkAllOnPage();
doAndWaitForPageToLoad(() ->
{
dt.clickHeaderButton("Delete");
assertAlert("Are you sure you want to delete the selected rows?");
});
assertEquals("Failed to delete all rows", 0, dataRegionTable.getDataRowCount());
assertTextNotPresent(LIST2_KEY, LIST2_KEY2, LIST2_KEY3, LIST2_KEY4);
log("Test deleting data (should any list custom views)");
clickTab("List");
clickAndWait(Locator.linkWithText(LIST_NAME_COLORS));
_listHelper.deleteList();
log("Test that deletion happened");
assertTextNotPresent(LIST_NAME_COLORS);
clickAndWait(Locator.linkWithText(LIST2_NAME_CARS));
_customizeViewsHelper.openCustomizeViewPanel();
waitForElement(Locator.tagWithAttribute("tr", "data-recordid", LIST3_KEY_NAME.toUpperCase()));
assertElementNotPresent(Locator.tagWithAttribute("tr", "data-recordid", LIST_KEY_NAME.toUpperCase()));
goToProjectHome();
assertTextPresent("query not found");
log("Test exporting a nonexistent list returns a 404");
String exportUrl = WebTestHelper.buildURL("query", PROJECT_VERIFY, "exportRowsTsv",
Map.of("schemaName", "lists", "query.queryName", LIST_NAME_COLORS));
beginAt(exportUrl);
assertEquals("Incorrect response code", 404, getResponseCode());
assertTextPresent("The specified query '%s' does not exist in schema '%s'".formatted(LIST_NAME_COLORS, "lists"));
clickButton("Back");
// after the 13.2 audit log migration, we are no longer going to co-mingle domain and list events in the same table
AuditLogTest.verifyAuditEvent(this, DOMAIN_AUDIT_EVENT, AuditLogTest.COMMENT_COLUMN, "The domain " + LIST_NAME_COLORS + " was deleted", 5);
AuditLogTest.verifyAuditEvent(this, LIST_AUDIT_EVENT, AuditLogTest.COMMENT_COLUMN, "An existing list record was deleted", 5);
AuditLogTest.verifyAuditEvent(this, LIST_AUDIT_EVENT, AuditLogTest.COMMENT_COLUMN, "An existing list record was modified", 10);
customizeURLTest();
crossContainerLookupTest();
// Prevent crawler errors after the list is deleted
// A Query WebPart for a missing query contains links that will 404
goToProjectHome();
new PortalHelper(this).removeAllWebParts();
}
/* Issue 23487: add regression coverage for batch insert into list with multiple errors
*/
@Test
public void testBatchInsertErrors()
{
// create the list for this case
String multiErrorListName = "multiErrorBatchList";
String[] expectedErrors = new String[]{
getConversionErrorMessage("green", "ShouldInsertCorrectly", Boolean.class),
getConversionErrorMessage("five", "Id", Integer.class)
};
createList(multiErrorListName, BatchListColumns, BatchListData);
_listHelper.beginAtList(PROJECT_VERIFY, multiErrorListName);
_listHelper.clickImportData();
// insert the new list data and verify the expected errors appear
setListImportAsTestDataField(toTSV(BatchListColumns, BatchListExtraData), expectedErrors);
// no need to query the list; nothing will be inserted if the batch insert fails/errors
}
@Test
public void testListMerge()
{
String mergeListName = "listForMerging";
createList(mergeListName, BatchListColumns, BatchListData);
_listHelper.beginAtList(PROJECT_VERIFY, mergeListName);
ImportDataPage importDataPage = _listHelper.clickImportData();
checker().verifyTrue("For list with an integer, non-auto-increment key, merge option should be available for copy/paste", importDataPage.isPasteMergeOptionPresent());
_listHelper.chooseFileUpload();
checker().verifyTrue("For list with an integer, non-auto-increment key, merge option should be available for file upload", importDataPage.isFileMergeOptionPresent());
_listHelper.chooseCopyPasteText();
log("Try to upload the same data without choosing to merge. Errors are expected.");
String[] expectedErrors = new String[]{
"duplicate key value"
};
setListImportAsTestDataField(toTSV(BatchListColumns, BatchListMergeData), expectedErrors);
_listHelper.beginAtList(PROJECT_VERIFY, mergeListName);
_listHelper.verifyListData(BatchListColumns, BatchListData, checker());
log("Upload the same data using the merge operation. No errors should result.");
importDataPage = _listHelper.clickImportData();
importDataPage.setCopyPasteMerge(true);
setListImportAsTestDataField(toTSV(BatchListColumns, BatchListData));
_listHelper.verifyListData(BatchListColumns, BatchListData, checker());
log("Now upload some new data and modify existing data");
importDataPage = _listHelper.clickImportData();
importDataPage.setCopyPasteMerge(true);
setListImportAsTestDataField(toTSV(BatchListMergeColumns, BatchListMergeData));
_listHelper.verifyListData(BatchListColumns, BatchListAfterMergeData, checker());
}
@Test
public void testAutoIncrementKeyListNoMerge()
{
String mergeListName = "autoIncrementIdList";
_listHelper.createList(PROJECT_VERIFY, mergeListName, "Key", col("Name", ColumnType.String));
ImportDataPage importDataPage = _listHelper.clickImportData();
checker().verifyFalse("For list with an integer, auto-increment key, merge option should not be available", importDataPage.isPasteMergeOptionPresent());
}
@Test
public void testAddListColumnOverRemoteAPI() throws Exception
{
List<FieldDefinition> cols = Arrays.asList(
new FieldDefinition("name", ColumnType.String),
new FieldDefinition("title", ColumnType.String),
new FieldDefinition("dewey", ColumnType.Decimal)
);
String listName = "remoteApiListTestAddColumn";
TestDataGenerator dgen = new TestDataGenerator("lists", listName, getProjectName())
.withColumns(cols);
DomainResponse createResponse = dgen.createList(createDefaultConnection(), "key");
Domain listDomain = createResponse.getDomain();
List<PropertyDescriptor> listFields = createResponse.getDomain().getFields();
listFields.add(new FieldDefinition("volume", ColumnType.Decimal));
listDomain.setFields(listFields);
// now save with an extra field
SaveDomainCommand saveCmd = new SaveDomainCommand(dgen.getSchema(), dgen.getQueryName());
saveCmd.setDomainDesign(listDomain);
DomainResponse saveResponse = saveCmd.execute(createDefaultConnection(), dgen.getContainerPath());
// now verify
assertEquals(listFields.size(), saveResponse.getDomain().getFields().size());
for (PropertyDescriptor expectedField : listFields)
{
checker().verifyTrue( "expect field [" + expectedField.getName() + "] with type [" +expectedField.getRangeURI()+ "]",
saveResponse.getDomain().getFields().stream()
.anyMatch(a -> a.getName().equals(expectedField.getName()) &&
a.getRangeURI().endsWith(expectedField.getRangeURI())));
}
}
@Test
public void testRemoveColumnOverAPI() throws Exception
{
List<FieldDefinition> cols = Arrays.asList(
new FieldDefinition("name", ColumnType.String),
new FieldDefinition("title", ColumnType.String),
new FieldDefinition("dewey", ColumnType.Decimal),
new FieldDefinition("removeMe", ColumnType.Decimal)
);
String listName = "remoteApiListTestRemoveColumn";
TestDataGenerator dgen = new TestDataGenerator("lists", listName, getProjectName())
.withColumns(cols);
DomainResponse createResponse = dgen.createList(createDefaultConnection(), "key");
Domain listDomain = createResponse.getDomain();
List<PropertyDescriptor> listFields = createResponse.getDomain().getFields();
listFields.removeIf(a-> a.getName().equals("removeMe"));
listDomain.setFields(listFields);
SaveDomainCommand saveCmd = new SaveDomainCommand(dgen.getSchema(), dgen.getQueryName());
saveCmd.setDomainDesign(listDomain);
DomainResponse saveResponse = saveCmd.execute(createDefaultConnection(), dgen.getContainerPath());
checker().verifyFalse("'removeMe' field was not deleted.",
saveResponse.getDomain().getFields().stream()
.anyMatch(a -> a.getName().equals("removeMe")));
}
@Test
public void testChangeListNameOverAPI() throws Exception
{