1
|
|
|
/// <reference types="Cypress" /> |
2
|
|
|
|
3
|
|
|
import RulePageObject from '../../../support/pages/module/sw-rule.page-object'; |
4
|
|
|
|
5
|
|
|
describe('Rule builder: Test viewing rule assignments in other entities', () => { |
6
|
|
|
beforeEach(() => { |
7
|
|
|
cy.setToInitialState() |
|
|
|
|
8
|
|
|
.then(() => { |
9
|
|
|
cy.loginViaApi(); |
|
|
|
|
10
|
|
|
}) |
11
|
|
|
.then(() => { |
12
|
|
|
return cy.createDefaultFixture('rule'); |
|
|
|
|
13
|
|
|
}) |
14
|
|
|
.then(() => { |
15
|
|
|
cy.openInitialPage(`${Cypress.env('admin')}#/sw/settings/rule/index`); |
|
|
|
|
16
|
|
|
}); |
17
|
|
|
}); |
18
|
|
|
|
19
|
|
|
it('@rule: assign rule to shipping costs and verify assignment', () => { |
20
|
|
|
cy.window().then((win) => { |
|
|
|
|
21
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_12289')) { |
22
|
|
|
return; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
const page = new RulePageObject(); |
26
|
|
|
|
27
|
|
|
cy.server(); |
|
|
|
|
28
|
|
|
cy.route({ |
29
|
|
|
url: '/api/v*/shipping-method/*', |
30
|
|
|
method: 'patch' |
31
|
|
|
}).as('saveShippingMethod'); |
32
|
|
|
|
33
|
|
|
// Open rule |
34
|
|
|
cy.get(`${page.elements.dataGridRow}--0`).should('be.visible'); |
35
|
|
|
cy.get('.sw-search-bar__input').typeAndCheckSearchField('Ruler'); |
36
|
|
|
cy.get(`${page.elements.dataGridRow}--0 .sw-data-grid__cell--name`).should('be.visible'); |
37
|
|
|
cy.get(`${page.elements.dataGridRow}--0 .sw-data-grid__cell--name`).contains('Ruler'); |
38
|
|
|
cy.clickContextMenuItem( |
39
|
|
|
'.sw-entity-listing__context-menu-edit-action', |
40
|
|
|
page.elements.contextMenuButton, |
41
|
|
|
`${page.elements.dataGridRow}--0` |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
// Switch to assignments tab |
45
|
|
|
cy.get('.sw-settings-rule-detail__tabs').should('be.visible'); |
46
|
|
|
cy.get('.sw-settings-rule-detail__tab-item-assignments').click(); |
47
|
|
|
|
48
|
|
|
// Expect empty-state to be visible because the rule it not yet assigned to any entity |
49
|
|
|
cy.get('.sw-settings-rule-detail-assignments__empty-state').should('be.visible'); |
50
|
|
|
|
51
|
|
|
// Go to shipping methods |
52
|
|
|
cy.visit(`${Cypress.env('admin')}#/sw/settings/shipping/index`); |
|
|
|
|
53
|
|
|
|
54
|
|
|
// Open shipping method |
55
|
|
|
cy.get(`${page.elements.dataGridRow}--0`).should('be.visible'); |
56
|
|
|
cy.get('.sw-search-bar__input').typeAndCheckSearchField('Express'); |
57
|
|
|
cy.get(`${page.elements.dataGridRow}--0 .sw-data-grid__cell--name`).should('be.visible'); |
58
|
|
|
cy.get(`${page.elements.dataGridRow}--0 .sw-data-grid__cell--name`).contains('Express'); |
59
|
|
|
cy.clickContextMenuItem( |
60
|
|
|
'.sw-settings-shipping-list__edit-action', |
61
|
|
|
page.elements.contextMenuButton, |
62
|
|
|
`${page.elements.dataGridRow}--0` |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
// Assign rule to shipping method |
66
|
|
|
cy.get('.sw-settings-shipping-detail__condition_container').scrollIntoView(); |
67
|
|
|
cy.get('.sw-settings-shipping-detail__top-rule').typeSingleSelectAndCheck( |
68
|
|
|
'Ruler', |
69
|
|
|
'.sw-settings-shipping-detail__top-rule' |
70
|
|
|
); |
71
|
|
|
|
72
|
|
|
// Save rule |
73
|
|
|
cy.get('.sw-settings-shipping-method-detail__save-action').click(); |
74
|
|
|
cy.wait('@saveShippingMethod').then((xhr) => { |
75
|
|
|
expect(xhr).to.have.property('status', 204); |
76
|
|
|
}); |
77
|
|
|
|
78
|
|
|
// Go back to rule |
79
|
|
|
cy.visit(`${Cypress.env('admin')}#/sw/settings/rule/index`); |
80
|
|
|
cy.get(`${page.elements.dataGridRow}--0`).should('be.visible'); |
81
|
|
|
cy.get('.sw-search-bar__input').typeAndCheckSearchField('Ruler'); |
82
|
|
|
cy.get(`${page.elements.dataGridRow}--0 .sw-data-grid__cell--name`).should('be.visible'); |
83
|
|
|
cy.get(`${page.elements.dataGridRow}--0 .sw-data-grid__cell--name`).contains('Ruler'); |
84
|
|
|
cy.clickContextMenuItem( |
85
|
|
|
'.sw-entity-listing__context-menu-edit-action', |
86
|
|
|
page.elements.contextMenuButton, |
87
|
|
|
`${page.elements.dataGridRow}--0` |
88
|
|
|
); |
89
|
|
|
|
90
|
|
|
// Switch to assignments tab |
91
|
|
|
cy.get('.sw-settings-rule-detail__tabs').should('be.visible'); |
92
|
|
|
cy.get('.sw-settings-rule-detail__tab-item-assignments').click(); |
93
|
|
|
|
94
|
|
|
// Shipping method assignment should be present |
95
|
|
|
cy.get('.sw-settings-rule-detail-assignments__card-shipping_method').should('be.visible'); |
96
|
|
|
cy.get(`.sw-settings-rule-detail-assignments__card-shipping_method ${page.elements.dataGridRow}--0 .sw-data-grid__cell--name`).should('be.visible'); |
97
|
|
|
cy.get(`.sw-settings-rule-detail-assignments__card-shipping_method ${page.elements.dataGridRow}--0 .sw-data-grid__cell--name`).contains('Express'); |
98
|
|
|
}); |
99
|
|
|
}); |
100
|
|
|
}); |
101
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.