Skip to content

Commit b5355fe

Browse files
author
Vitaliy
authored
Merge pull request #166 from magento/mftf-selector-fix-and-test-coverage
Fixed MFTF selector reference contributor and completion, added tes coverage
2 parents c56f546 + becb816 commit b5355fe

File tree

12 files changed

+284
-65
lines changed

12 files changed

+284
-65
lines changed

src/com/magento/idea/magento2plugin/completion/xml/XmlCompletionContributor.java

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -215,51 +215,16 @@ public XmlCompletionContributor() {
215215
new RequireJsMappingCompletionProvider()
216216
);
217217

218-
// mftf selector completion contributor
219-
extend(CompletionType.BASIC,
220-
psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
221-
.inside(XmlPatterns.xmlAttribute()
222-
.withName(MftfActionGroup.SELECTOR_ATTRIBUTE))
223-
.inFile(xmlFile().withName(string().endsWith("Test.xml"))),
224-
new SelectorCompletionProvider()
225-
);
226-
227218
// mftf action group completion contributor
228219
extend(
229220
CompletionType.BASIC,
230221
psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
231222
.inside(
232223
XmlPatterns.xmlAttribute().withName(string().oneOf("ref", "extends"))
233224
.withParent(XmlPatterns.xmlTag().withName("actionGroup")
234-
)
235-
),
236-
new ActionGroupCompletionProvider()
237-
);
238-
239-
// mftf page url completion contributor
240-
extend(
241-
CompletionType.BASIC,
242-
psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
243-
.inside(
244-
XmlPatterns.xmlAttribute().withName(MftfActionGroup.URL_ATTRIBUTE)
245-
.withParent(XmlPatterns.xmlTag().withParent(
246-
XmlPatterns.xmlTag().withName(
247-
string().oneOf(MftfActionGroup.ROOT_TAG, MftfTest.ROOT_TAG)
248-
)))
225+
)
249226
),
250-
new PageCompletionProvider()
251-
);
252-
extend(
253-
CompletionType.BASIC,
254-
psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
255-
.inside(
256-
XmlPatterns.xmlAttribute().withName(MftfActionGroup.URL_ATTRIBUTE)
257-
.withParent(XmlPatterns.xmlTag().withParent(
258-
XmlPatterns.xmlTag().withParent(XmlPatterns.xmlTag().withName(
259-
string().oneOf(MftfActionGroup.ROOT_TAG, MftfTest.ROOT_TAG)
260-
))))
261-
),
262-
new PageCompletionProvider()
227+
new ActionGroupCompletionProvider()
263228
);
264229

265230
// mftf data entity completion contributor
@@ -282,5 +247,44 @@ public XmlCompletionContributor() {
282247
),
283248
new DataCompletionProvider()
284249
);
250+
251+
registerCompletionsForDifferentNesting();
252+
}
253+
254+
private void registerCompletionsForDifferentNesting() {
255+
int i = 1;
256+
int maxNesting = 10;
257+
while( i < maxNesting) {
258+
259+
// mftf selector completion contributor
260+
extend(CompletionType.BASIC,
261+
psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
262+
.inside(XmlPatterns.xmlAttribute()
263+
.withName(MftfActionGroup.SELECTOR_ATTRIBUTE).withSuperParent(
264+
i,
265+
XmlPatterns.xmlTag().withParent(
266+
XmlPatterns.xmlTag().withName(
267+
string().oneOf(MftfActionGroup.ROOT_TAG, MftfTest.ROOT_TAG)
268+
)))
269+
),
270+
new SelectorCompletionProvider()
271+
);
272+
273+
// mftf page url completion contributor
274+
extend(
275+
CompletionType.BASIC,
276+
psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
277+
.inside(
278+
XmlPatterns.xmlAttribute().withName(MftfActionGroup.URL_ATTRIBUTE)
279+
.withSuperParent(i ,XmlPatterns.xmlTag().withParent(
280+
XmlPatterns.xmlTag().withName(
281+
string().oneOf(MftfActionGroup.ROOT_TAG, MftfTest.ROOT_TAG)
282+
)))
283+
),
284+
new PageCompletionProvider()
285+
);
286+
287+
i++;
288+
}
285289
}
286290
}

src/com/magento/idea/magento2plugin/reference/xml/XmlReferenceContributor.java

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -170,34 +170,6 @@ public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar)
170170
)
171171
);
172172

173-
// <someXmlTag url="{{someValue}}" /> in MFTF Tests and ActionGroups
174-
registrar.registerReferenceProvider(
175-
XmlPatterns.xmlAttributeValue().withValue(
176-
string().matches(RegExUtil.Magento.MFTF_CURLY_BRACES)
177-
).withParent(XmlPatterns.xmlAttribute().withName(
178-
MftfActionGroup.URL_ATTRIBUTE
179-
).withParent(XmlPatterns.xmlTag().withParent(XmlPatterns.xmlTag().withName(
180-
string().oneOf(MftfActionGroup.ROOT_TAG, MftfTest.ROOT_TAG)
181-
)))),
182-
new CompositeReferenceProvider(
183-
new PageReferenceProvider()
184-
)
185-
);
186-
registrar.registerReferenceProvider(
187-
XmlPatterns.xmlAttributeValue().withValue(
188-
string().matches(RegExUtil.Magento.MFTF_CURLY_BRACES)
189-
).withParent(XmlPatterns.xmlAttribute().withName(
190-
MftfActionGroup.URL_ATTRIBUTE
191-
).withParent(XmlPatterns.xmlTag().withParent(XmlPatterns.xmlTag().withParent(
192-
XmlPatterns.xmlTag().withName(
193-
string().oneOf(MftfActionGroup.ROOT_TAG, MftfTest.ROOT_TAG)
194-
)
195-
)))),
196-
new CompositeReferenceProvider(
197-
new PageReferenceProvider()
198-
)
199-
);
200-
201173
// <createData entity="SimpleProduct" />
202174
// <updateData entity="SimpleProduct" />
203175
registrar.registerReferenceProvider(
@@ -273,5 +245,44 @@ public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar)
273245
),
274246
new RequireJsPreferenceReferenceProvider()
275247
);
248+
249+
registerReferenceForDifferentNesting(registrar);
250+
}
251+
252+
private void registerReferenceForDifferentNesting(@NotNull PsiReferenceRegistrar registrar) {
253+
int i = 1;
254+
int maxNesting = 10;
255+
while( i < maxNesting) {
256+
257+
// <someXmlTag url="{{someValue}}" /> in MFTF Tests and ActionGroups
258+
registrar.registerReferenceProvider(
259+
XmlPatterns.xmlAttributeValue().withValue(
260+
string().matches(RegExUtil.Magento.MFTF_CURLY_BRACES)
261+
).withParent(XmlPatterns.xmlAttribute().withName(
262+
MftfActionGroup.URL_ATTRIBUTE
263+
).withParent(XmlPatterns.xmlTag().withSuperParent(i, XmlPatterns.xmlTag().withName(
264+
string().oneOf(MftfActionGroup.ROOT_TAG, MftfTest.ROOT_TAG)
265+
)))),
266+
new CompositeReferenceProvider(
267+
new PageReferenceProvider()
268+
)
269+
);
270+
271+
// <someXmlTag selector="{{someValue}}" /> in MFTF Tests and ActionGroups
272+
registrar.registerReferenceProvider(
273+
XmlPatterns.xmlAttributeValue().withValue(
274+
string().matches(RegExUtil.Magento.MFTF_CURLY_BRACES)
275+
).withParent(XmlPatterns.xmlAttribute().withName(
276+
MftfActionGroup.SELECTOR_ATTRIBUTE
277+
).withParent(XmlPatterns.xmlTag().withSuperParent(i, XmlPatterns.xmlTag().withName(
278+
string().oneOf(MftfActionGroup.ROOT_TAG, MftfTest.ROOT_TAG)
279+
)))),
280+
new CompositeReferenceProvider(
281+
new SectionReferenceProvider()
282+
)
283+
);
284+
285+
i++;
286+
}
276287
}
277288
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="Test">
11+
<click selector="{{AttributeSet<caret>}}" stepKey="saveCategoryWithProducts1"/>
12+
</actionGroup>
13+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="Test">
11+
<click selector="{{Section<caret>}}" stepKey="saveCategoryWithProducts1"/>
12+
</actionGroup>
13+
</actionGroups>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="TestAddOutOfStockProductToCompareListTest">
12+
<before>
13+
<click selector="{{AttributeSet<caret>}}" stepKey="saveCategoryWithProducts1"/>
14+
</before>
15+
</test>
16+
</tests>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="TestAddOutOfStockProductToCompareListTest">
12+
<before>
13+
<click selector="{{Section<caret>}}" stepKey="saveCategoryWithProducts1"/>
14+
</before>
15+
</test>
16+
</tests>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="Test">
11+
<click selector="{{TestAdminMenuCatalog<caret>}}" stepKey="saveCategoryWithProducts1"/>
12+
</actionGroup>
13+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="Test">
11+
<click selector="{{TestAdminAddProductsToOptionPanelSection.testaddSelectedProducts<caret>}}" stepKey="saveCategoryWithProducts1"/>
12+
</actionGroup>
13+
</actionGroups>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="TestAddOutOfStockProductToCompareListTest">
12+
<before>
13+
<click selector="{{TestAdminMenuCatalog<caret>}}" stepKey="saveCategoryWithProducts1"/>
14+
</before>
15+
</test>
16+
</tests>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="TestAddOutOfStockProductToCompareListTest">
12+
<before>
13+
<click selector="{{TestAdminAddProductsToOptionPanelSection.testaddSelectedProducts<caret>}}" stepKey="saveCategoryWithProducts1"/>
14+
</before>
15+
</test>
16+
</tests>

0 commit comments

Comments
 (0)