|
1
|
|
|
// / <reference types="Cypress" /> |
|
2
|
|
|
|
|
3
|
|
|
import OrderPageObject from '../../../support/pages/module/sw-order.page-object'; |
|
4
|
|
|
|
|
5
|
|
|
describe('Order: Create credit note', () => { |
|
6
|
|
View Code Duplication |
beforeEach(() => { |
|
|
|
|
|
|
7
|
|
|
cy.setToInitialState() |
|
|
|
|
|
|
8
|
|
|
.then(() => { |
|
9
|
|
|
cy.loginViaApi(); |
|
|
|
|
|
|
10
|
|
|
}) |
|
11
|
|
|
.then(() => { |
|
12
|
|
|
return cy.createProductFixture(); |
|
|
|
|
|
|
13
|
|
|
}) |
|
14
|
|
|
.then(() => { |
|
15
|
|
|
return cy.searchViaAdminApi({ |
|
|
|
|
|
|
16
|
|
|
endpoint: 'product', |
|
17
|
|
|
data: { |
|
18
|
|
|
field: 'name', |
|
19
|
|
|
value: 'Product name' |
|
20
|
|
|
} |
|
21
|
|
|
}); |
|
22
|
|
|
}) |
|
23
|
|
|
.then((result) => { |
|
24
|
|
|
return cy.createGuestOrder(result.id); |
|
|
|
|
|
|
25
|
|
|
}) |
|
26
|
|
|
.then(() => { |
|
27
|
|
|
cy.openInitialPage(`${Cypress.env('admin')}#/sw/order/index`); |
|
|
|
|
|
|
28
|
|
|
}); |
|
29
|
|
|
}); |
|
30
|
|
|
|
|
31
|
|
|
it('@base @order: create credit note', () => { |
|
32
|
|
|
const page = new OrderPageObject(); |
|
33
|
|
|
|
|
34
|
|
|
cy.route({ |
|
|
|
|
|
|
35
|
|
|
url: `${Cypress.env('apiPath')}/_action/order/**/recalculate`, |
|
|
|
|
|
|
36
|
|
|
method: 'post' |
|
37
|
|
|
}).as('orderRecalculateCall'); |
|
38
|
|
|
|
|
39
|
|
|
cy.route({ |
|
40
|
|
|
url: `${Cypress.env('apiPath')}/_action/order/*/document/invoice`, |
|
41
|
|
|
method: 'post' |
|
42
|
|
|
}).as('createInvoice'); |
|
43
|
|
|
|
|
44
|
|
|
cy.route({ |
|
45
|
|
|
url: `${Cypress.env('apiPath')}/_action/order/*/document/credit_note`, |
|
46
|
|
|
method: 'post' |
|
47
|
|
|
}).as('createCreditNote'); |
|
48
|
|
|
|
|
49
|
|
|
cy.get(`${page.elements.dataGridRow}--0`).contains('Max Mustermann'); |
|
50
|
|
|
cy.clickContextMenuItem( |
|
51
|
|
|
'.sw-order-list__order-view-action', |
|
52
|
|
|
page.elements.contextMenuButton, |
|
53
|
|
|
`${page.elements.dataGridRow}--0` |
|
54
|
|
|
); |
|
55
|
|
|
|
|
56
|
|
|
cy.get(`${page.elements.userMetadata}-user-name`) |
|
57
|
|
|
.contains('Max Mustermann'); |
|
58
|
|
|
cy.get('.sw-order-detail__smart-bar-edit-button').click(); |
|
59
|
|
|
cy.get('.sw-context-button .sw-button--ghost').click(); |
|
60
|
|
|
cy.get('.sw-order-line-items-grid__can-create-discounts-button').click(); |
|
61
|
|
|
|
|
62
|
|
|
cy.get('.sw-data-grid__row--0').dblclick(); |
|
63
|
|
|
cy.get('#sw-field--item-label').type('Discount 100 Euro'); |
|
64
|
|
|
cy.get('#sw-field--item-priceDefinition-price').clear().type('-100'); |
|
65
|
|
|
|
|
66
|
|
|
cy.get('.sw-data-grid__inline-edit-save').click(); |
|
67
|
|
|
|
|
68
|
|
|
cy.wait('@orderRecalculateCall').then((xhr) => { |
|
69
|
|
|
expect(xhr).to.have.property('status', 204); |
|
70
|
|
|
}); |
|
71
|
|
|
|
|
72
|
|
|
cy.get('.sw-order-detail__smart-bar-save-button').click(); |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
// Open Invoice modal |
|
76
|
|
|
cy.get('.sw-order-detail-base__document-grid').scrollIntoView(); |
|
77
|
|
|
cy.get('.sw-order-detail-base__document-grid').should('be.visible'); |
|
78
|
|
|
cy.get(page.elements.loader).should('not.exist'); |
|
79
|
|
|
cy.clickContextMenuItem( |
|
80
|
|
|
'.sw-context-menu-item', |
|
81
|
|
|
'.sw-order-document-grid-button', |
|
82
|
|
|
null, |
|
83
|
|
|
'Invoice' |
|
84
|
|
|
); |
|
85
|
|
|
|
|
86
|
|
|
// Generate invoice |
|
87
|
|
|
cy.get('.sw-order-document-settings-modal__settings-modal').should('be.visible'); |
|
88
|
|
|
cy.get('#sw-field--documentConfig-documentComment').type('New invoice'); |
|
89
|
|
|
cy.get('.sw-order-document-settings-modal__settings-modal .sw-button--primary').click(); |
|
90
|
|
|
|
|
91
|
|
|
cy.wait('@createInvoice').then((xhr) => { |
|
92
|
|
|
expect(xhr).to.have.property('status', 200); |
|
93
|
|
|
}); |
|
94
|
|
|
|
|
95
|
|
|
// Open create edit note modal |
|
96
|
|
|
cy.get('.sw-order-detail-base__document-grid').scrollIntoView(); |
|
97
|
|
|
cy.get('.sw-order-detail-base__document-grid').should('be.visible'); |
|
98
|
|
|
cy.get(page.elements.loader).should('not.exist'); |
|
99
|
|
|
|
|
100
|
|
|
cy.reload(); |
|
101
|
|
|
cy.get('.sw-order-detail-base__document-grid').scrollIntoView(); |
|
102
|
|
|
|
|
103
|
|
|
cy.clickContextMenuItem( |
|
104
|
|
|
'.sw-context-menu-item', |
|
105
|
|
|
'.sw-order-document-grid-button', |
|
106
|
|
|
null, |
|
107
|
|
|
'Credit note' |
|
108
|
|
|
); |
|
109
|
|
|
|
|
110
|
|
|
cy.get('#sw-field--documentConfig-custom-invoiceNumber').select('1000'); |
|
111
|
|
|
|
|
112
|
|
|
cy.get('.sw-modal__footer button.sw-button--primary').should('be.visible'); |
|
113
|
|
|
cy.get('.sw-modal__footer button.sw-button--primary').click(); |
|
114
|
|
|
|
|
115
|
|
|
cy.wait('@createCreditNote').then((xhr) => { |
|
116
|
|
|
expect(xhr).to.have.property('status', 200); |
|
117
|
|
|
}); |
|
118
|
|
|
|
|
119
|
|
|
// check exsits credit note |
|
120
|
|
|
cy.get('.sw-simple-search-field--form input[placeholder="Search all documents..."]').type('Credit note'); |
|
121
|
|
|
cy.get('.sw-data-grid__row.sw-data-grid__row--0').contains('Credit note'); |
|
122
|
|
|
}); |
|
123
|
|
|
}); |
|
124
|
|
|
|