@vtex/faststore-plugin-buyer-portal 1.1.44 → 1.1.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70,6 +70,18 @@ export const TEST_DATA = {
70
70
  ACTION_TYPE: "Bypass all buying policies",
71
71
  },
72
72
  },
73
+ BUDGET: {
74
+ FIRST_BUDGET_NAME: "First Budget",
75
+ BUDGET_DETAILS_NAME: "First Details",
76
+ EDIT_BUDGET_DETAILS: "Edited Details",
77
+ EDIT_BUDGET_NAME: "Edited Budget",
78
+ BUDGET_AMOUNT: "2000",
79
+ FIRST_BUDGET_MESSAGE:
80
+ "Because this is the first budget created in this organization",
81
+ ALLOCATION_TYPE_1: "PO Number",
82
+ ALLOCATION_TYPE_2: "USER",
83
+ NO_ALLOCATION_MESSAGE: "No allocations yet",
84
+ },
73
85
  ADDRESS: {
74
86
  EXISTING_ADDRESS: "Existing Test Address",
75
87
  NEW_ADDRESS_NAME: "VTEX RJ",
@@ -97,6 +109,9 @@ export const TEST_DATA = {
97
109
  FOURTH_RECIPIENT_NAME: "Fourth Recipient",
98
110
  EDITED_RECIPIENT_NAME: "Edited Recipient",
99
111
  },
112
+ CUSTOM_FIELDS: {
113
+ EXISTING_PO_NUMBER: "PO Number for Test",
114
+ },
100
115
  CREDIT_CARDS: {
101
116
  SPECIFIC_CARD: "************1928",
102
117
  NEW_CARD: {
@@ -0,0 +1,316 @@
1
+ import { TEST_CONFIG, TEST_DATA } from "../constants";
2
+ import { clickConfirmButton } from "../shared";
3
+
4
+ function navigateToBudgetByName(budgetName: string) {
5
+ cy.get("[data-fs-bp-budgets-table]").within(() => {
6
+ cy.contains(budgetName).should("be.visible").parent().parent().click();
7
+ });
8
+
9
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
10
+ }
11
+
12
+ function generateDate(daysAfterToday = 1) {
13
+ const today = new Date();
14
+ today.setDate(today.getDate() + daysAfterToday);
15
+ const yyyy = today.getFullYear();
16
+ const mm = today.getMonth() + 1; // Months start at 0!
17
+ const dd = today.getDate();
18
+
19
+ const day = dd < 10 ? "0" + dd : String(dd);
20
+ const month = mm < 10 ? "0" + mm : String(mm);
21
+
22
+ return yyyy + "-" + month + "-" + day;
23
+ }
24
+
25
+ function goToBudgetsPage() {
26
+ // Navigate to Addresses page
27
+ cy.contains("Budgets").click();
28
+
29
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
30
+
31
+ // Check to see if contract details loaded correctly
32
+ cy.get("[data-fs-bp-header-inside]").should("exist");
33
+ cy.contains(TEST_DATA.PROFILE.TEST_CONTRACT_NAME).should("be.visible");
34
+ }
35
+
36
+ function openActionsDropdown(budgetName: string) {
37
+ cy.get("[data-fs-bp-budgets-table]")
38
+ .contains(budgetName)
39
+ .parent()
40
+ .parent()
41
+ .find("[data-fs-bp-basic-dropdown-menu-trigger]")
42
+ .click();
43
+ }
44
+
45
+ describe("Budgets list", () => {
46
+ beforeEach(() => {
47
+ cy.login();
48
+
49
+ // Visit the homepage
50
+ cy.visit(TEST_CONFIG.ROUTES.BUYER_PORTAL);
51
+
52
+ // Go to Budget Page and check empty state
53
+ goToBudgetsPage();
54
+ });
55
+ it("Create first budget", () => {
56
+ // Check to see if the empty section loaded
57
+ cy.get("[data-fs-empty-state]").should("exist");
58
+
59
+ // Open the Budget Creation modal
60
+ cy.get('[data-fs-button-variant="primary"]').click();
61
+
62
+ // Inside the modal, fill budget information
63
+ cy.get("[data-fs-bp-add-budget-drawer]").within(() => {
64
+ cy.get("[data-fs-bp-budget-name]").type(
65
+ TEST_DATA.BUDGET.FIRST_BUDGET_NAME
66
+ );
67
+ cy.get("[data-fs-bp-budget-amount]").type(TEST_DATA.BUDGET.BUDGET_AMOUNT);
68
+ cy.get("[data-fs-bp-budget-start-date]").type(generateDate());
69
+ cy.get("[data-fs-bp-budget-end-date]").type(generateDate(10));
70
+
71
+ cy.get("[data-fs-toggle]").click();
72
+ });
73
+
74
+ clickConfirmButton();
75
+
76
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
77
+
78
+ // Add Alocation
79
+ cy.get("[data-fs-bp-budget-allocation-row-select-all]").check();
80
+
81
+ clickConfirmButton();
82
+
83
+ cy.contains(TEST_DATA.BUDGET.FIRST_BUDGET_MESSAGE).should("be.visible");
84
+
85
+ clickConfirmButton();
86
+
87
+ cy.reload();
88
+
89
+ // Check to see if the table loaded and has the budget
90
+ cy.get("[data-fs-bp-budgets-table]").should("exist");
91
+ cy.contains(TEST_DATA.BUDGET.FIRST_BUDGET_NAME).should("be.visible");
92
+ });
93
+ it("Edit a budget from the list", () => {
94
+ // Check to see if the table loaded and has the budget
95
+ cy.get("[data-fs-bp-budgets-table]").should("exist");
96
+ cy.contains(TEST_DATA.BUDGET.FIRST_BUDGET_NAME).should("be.visible");
97
+
98
+ openActionsDropdown(TEST_DATA.BUDGET.FIRST_BUDGET_NAME);
99
+
100
+ cy.contains("Edit settings").click();
101
+
102
+ cy.get("[data-fs-bp-budget-name]")
103
+ .clear()
104
+ .type(TEST_DATA.BUDGET.EDIT_BUDGET_NAME);
105
+
106
+ clickConfirmButton();
107
+
108
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
109
+
110
+ cy.reload();
111
+
112
+ // Check to see if the table loaded and has the budget
113
+ cy.get("[data-fs-bp-budgets-table]").should("exist");
114
+ cy.contains(TEST_DATA.BUDGET.EDIT_BUDGET_NAME).should("be.visible");
115
+ });
116
+
117
+ it("Add Allocations from list", () => {
118
+ // Check to see if the table loaded and has the budget
119
+ cy.get("[data-fs-bp-budgets-table]").should("exist");
120
+ cy.contains(TEST_DATA.BUDGET.EDIT_BUDGET_NAME).should("be.visible");
121
+
122
+ openActionsDropdown(TEST_DATA.BUDGET.EDIT_BUDGET_NAME);
123
+
124
+ cy.contains("Add allocations").click();
125
+
126
+ cy.wait(1000);
127
+
128
+ cy.get("[data-fs-bp-budget-allocation-select-current]").click();
129
+
130
+ cy.contains("Users").click();
131
+
132
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
133
+
134
+ // Add Alocation
135
+ cy.get("[data-fs-bp-budget-allocation-row-select-all]").check();
136
+
137
+ clickConfirmButton();
138
+
139
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
140
+ });
141
+ it("Enter budget details and check allocations", () => {
142
+ // Check to see if the table loaded and has the budget
143
+ cy.get("[data-fs-bp-budgets-table]").should("exist");
144
+ cy.contains(TEST_DATA.BUDGET.EDIT_BUDGET_NAME).should("be.visible");
145
+
146
+ navigateToBudgetByName(TEST_DATA.BUDGET.EDIT_BUDGET_NAME);
147
+
148
+ cy.get("[data-fs-bp-budget-details-allocation-table]")
149
+ .should("exist")
150
+ .within(() => {
151
+ cy.contains(TEST_DATA.BUDGET.ALLOCATION_TYPE_1).should("exist");
152
+ cy.contains(TEST_DATA.BUDGET.ALLOCATION_TYPE_2).should("exist");
153
+ });
154
+ });
155
+
156
+ it("Delete a budget from list", () => {
157
+ // Check to see if the table loaded and has the budget
158
+ cy.get("[data-fs-bp-budgets-table]").should("exist");
159
+ cy.contains(TEST_DATA.BUDGET.EDIT_BUDGET_NAME).should("be.visible");
160
+
161
+ openActionsDropdown(TEST_DATA.BUDGET.EDIT_BUDGET_NAME);
162
+
163
+ cy.contains("Delete").click();
164
+
165
+ cy.get("[data-fs-bp-basic-drawer-body-wrapper]").within(() => {
166
+ cy.get("[data-fs-bp-input-text-input]").type(
167
+ TEST_DATA.BUDGET.EDIT_BUDGET_NAME,
168
+ { delay: 500 }
169
+ );
170
+ });
171
+
172
+ cy.get('[data-fs-bp-basic-drawer-button-variant="danger"]').click();
173
+
174
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
175
+
176
+ // Check to see if the empty section loaded
177
+ cy.get("[data-fs-empty-state]").should("exist");
178
+ });
179
+ });
180
+
181
+ describe("Budget Details", () => {
182
+ beforeEach(() => {
183
+ cy.login();
184
+
185
+ // Visit the homepage
186
+ cy.visit(TEST_CONFIG.ROUTES.BUYER_PORTAL);
187
+
188
+ // Go to Budget Page and check empty state
189
+ goToBudgetsPage();
190
+ });
191
+ it("Create budget", () => {
192
+ // Check to see if the empty section loaded
193
+ cy.get("[data-fs-empty-state]").should("exist");
194
+
195
+ // Open the Budget Creation modal
196
+ cy.get('[data-fs-button-variant="primary"]').click();
197
+
198
+ // Inside the modal, fill budget information
199
+ cy.get("[data-fs-bp-add-budget-drawer]").within(() => {
200
+ cy.get("[data-fs-bp-budget-name]").type(
201
+ TEST_DATA.BUDGET.BUDGET_DETAILS_NAME
202
+ );
203
+ cy.get("[data-fs-bp-budget-amount]").type(TEST_DATA.BUDGET.BUDGET_AMOUNT);
204
+ cy.get("[data-fs-bp-budget-start-date]").type(generateDate());
205
+ cy.get("[data-fs-bp-budget-end-date]").type(generateDate(10));
206
+
207
+ cy.get("[data-fs-toggle]").click();
208
+ });
209
+
210
+ clickConfirmButton();
211
+
212
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
213
+
214
+ // Add Alocation
215
+ cy.get("[data-fs-bp-budget-allocation-row-select-all]").check();
216
+
217
+ clickConfirmButton();
218
+
219
+ cy.contains(TEST_DATA.BUDGET.FIRST_BUDGET_MESSAGE).should("be.visible");
220
+
221
+ clickConfirmButton();
222
+
223
+ cy.reload();
224
+
225
+ // Check to see if the table loaded and has the budget
226
+ cy.get("[data-fs-bp-budgets-table]").should("exist");
227
+ cy.contains(TEST_DATA.BUDGET.BUDGET_DETAILS_NAME).should("be.visible");
228
+ });
229
+
230
+ it("Edit Inside Budget Details", () => {
231
+ navigateToBudgetByName(TEST_DATA.BUDGET.BUDGET_DETAILS_NAME);
232
+
233
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
234
+
235
+ cy.get("[data-fs-budget-settings-edit-button]").click();
236
+ cy.get("[data-fs-bp-budget-name")
237
+ .clear()
238
+ .type(TEST_DATA.BUDGET.EDIT_BUDGET_DETAILS);
239
+
240
+ clickConfirmButton();
241
+
242
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
243
+ cy.reload();
244
+
245
+ cy.contains(TEST_DATA.BUDGET.EDIT_BUDGET_DETAILS).should("exist");
246
+ });
247
+
248
+ it("Remove allocation inside details", () => {
249
+ navigateToBudgetByName(TEST_DATA.BUDGET.EDIT_BUDGET_DETAILS);
250
+
251
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
252
+
253
+ cy.get("[data-fs-bp-budget-allocation-table-trash-icon]").click();
254
+
255
+ cy.get("[data-fs-bp-delete-allocation-drawer-body]").within(() => {
256
+ cy.get("[data-fs-bp-input-text-input]").type(
257
+ TEST_DATA.CUSTOM_FIELDS.EXISTING_PO_NUMBER,
258
+ { delay: 500 }
259
+ );
260
+ });
261
+
262
+ clickConfirmButton();
263
+
264
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
265
+ cy.reload();
266
+
267
+ cy.get("[data-fs-empty-state-section]")
268
+ .should("exist")
269
+ .within(() => {
270
+ cy.contains(TEST_DATA.BUDGET.NO_ALLOCATION_MESSAGE).should("exist");
271
+ });
272
+ });
273
+
274
+ it("Add alocation from inside details", () => {
275
+ navigateToBudgetByName(TEST_DATA.BUDGET.EDIT_BUDGET_DETAILS);
276
+
277
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
278
+
279
+ cy.get("[data-fs-budget-details-allocation-table-edit-button]").click();
280
+
281
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
282
+
283
+ cy.get("[data-fs-bp-budget-allocation-row-select-all]").check();
284
+
285
+ clickConfirmButton();
286
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
287
+ cy.reload();
288
+
289
+ cy.get("[data-fs-bp-budget-allocation-table-row-name-td]").should("exist");
290
+ });
291
+ it("Delete budget from inside details", () => {
292
+ navigateToBudgetByName(TEST_DATA.BUDGET.EDIT_BUDGET_DETAILS);
293
+
294
+ cy.get("[data-fs-bp-budgets-details-header-wrapper]").within(() => {
295
+ cy.get("[data-fs-bp-basic-dropdown-menu-trigger]").click();
296
+ });
297
+
298
+ cy.contains("Delete").click();
299
+
300
+ cy.get("[data-fs-bp-input-wrapper]")
301
+ .last()
302
+ .within(() => {
303
+ cy.get("[data-fs-bp-input-text-input]").type(
304
+ TEST_DATA.BUDGET.EDIT_BUDGET_DETAILS,
305
+ { delay: 500 }
306
+ );
307
+ });
308
+
309
+ cy.get('[data-fs-bp-basic-drawer-button-variant="danger"]').last().click();
310
+
311
+ cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
312
+
313
+ // Check to see if the empty section loaded
314
+ cy.get("[data-fs-empty-state]").should("exist");
315
+ });
316
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.1.44",
3
+ "version": "1.1.45",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -42,6 +42,7 @@ export const BudgetAddForm = ({
42
42
  </div>
43
43
 
44
44
  <InputText
45
+ data-fs-bp-budget-name
45
46
  label="Name"
46
47
  value={budget.name}
47
48
  wrapperProps={{ style: { marginTop: 16 } }}
@@ -56,6 +57,7 @@ export const BudgetAddForm = ({
56
57
  />
57
58
 
58
59
  <InputText
60
+ data-fs-bp-budget-amount
59
61
  label="Amount"
60
62
  value={
61
63
  typeof budget.amount === "number"
@@ -83,6 +85,7 @@ export const BudgetAddForm = ({
83
85
  <InputText
84
86
  label="Start date"
85
87
  type="date"
88
+ data-fs-bp-budget-start-date
86
89
  value={budget.startDate?.split("T")[0] ?? ""}
87
90
  wrapperProps={{ style: { marginTop: 16 } }}
88
91
  onChange={(e) => handleChange("startDate", e.target.value)}
@@ -101,6 +104,7 @@ export const BudgetAddForm = ({
101
104
  <InputText
102
105
  label="End date"
103
106
  type="date"
107
+ data-fs-bp-budget-end-date
104
108
  value={endDate ? endDate.split("T")[0] : ""}
105
109
  wrapperProps={{ style: { marginTop: 16 } }}
106
110
  onChange={(e) => handleChange("endDate", e.target.value)}