@vtex/faststore-plugin-buyer-portal 1.1.93 → 1.1.95
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.
- package/cypress/constants.ts +4 -9
- package/cypress/integration/addresses.test.ts +39 -55
- package/cypress/integration/budgets.test.ts +130 -100
- package/cypress/integration/buying-policies.test.ts +66 -96
- package/cypress/integration/collections.test.ts +192 -172
- package/cypress/integration/credit-cards.test.ts +1 -1
- package/cypress/integration/locations.test.ts +39 -43
- package/cypress/integration/organizational-units.test.ts +70 -33
- package/cypress/integration/recipients.test.ts +34 -46
- package/cypress/integration/users.test.ts +83 -136
- package/cypress/shared.ts +32 -2
- package/cypress/support/addressHelper.tsx +17 -6
- package/package.json +1 -1
- package/src/features/addresses/clients/AddressesClient.ts +2 -2
- package/src/features/addresses/components/AddressForm/AddressForm.tsx +0 -15
- package/src/features/addresses/components/AddressInfoDisplay/AddressInfoDisplay.tsx +0 -1
- package/src/features/addresses/components/CreateAddressDrawer/CreateAddressDrawer.tsx +0 -2
- package/src/features/addresses/components/DeleteRecipientAddressDrawer/DeleteRecipientAddressDrawer.tsx +1 -1
- package/src/features/addresses/types/AddressData.ts +3 -3
- package/src/features/shared/utils/addresLabelToPropMapping.ts +0 -1
- package/src/features/shared/utils/constants.ts +1 -1
|
@@ -1,43 +1,16 @@
|
|
|
1
1
|
import { TEST_CONFIG, TEST_DATA } from "../constants";
|
|
2
|
+
import { generateRandomString, useInternalSearch } from "../shared";
|
|
2
3
|
|
|
3
4
|
// Reusable utility functions
|
|
4
5
|
const navigateToBuyingPolicies = () => {
|
|
5
6
|
cy.visit(TEST_CONFIG.ROUTES.BUYER_PORTAL);
|
|
6
7
|
cy.contains("Buying Policies").click();
|
|
7
|
-
cy.
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
shouldExist: boolean,
|
|
14
|
-
maxRetries = TEST_CONFIG.RETRY.DEFAULT_MAX_ATTEMPTS
|
|
15
|
-
) => {
|
|
16
|
-
const verifyAndRetry = (currentRetry = 0) => {
|
|
17
|
-
cy.get("[data-fs-buying-policies-section]").should("exist");
|
|
18
|
-
|
|
19
|
-
cy.get("body").then(($body) => {
|
|
20
|
-
const exists = $body.text().includes(policyName);
|
|
21
|
-
if (exists !== shouldExist && currentRetry < maxRetries) {
|
|
22
|
-
cy.log(`Retry attempt ${currentRetry + 1} of ${maxRetries}`);
|
|
23
|
-
cy.wait(TEST_CONFIG.TIMEOUTS.RETRY_DELAY);
|
|
24
|
-
cy.reload();
|
|
25
|
-
verifyAndRetry(currentRetry + 1);
|
|
26
|
-
} else if (exists !== shouldExist) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
`Failed to verify buying policy state after ${maxRetries} retries`
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
verifyAndRetry();
|
|
35
|
-
|
|
36
|
-
if (shouldExist) {
|
|
37
|
-
cy.contains(policyName).should("be.visible");
|
|
38
|
-
} else {
|
|
39
|
-
cy.contains(policyName).should("not.exist");
|
|
40
|
-
}
|
|
8
|
+
cy.get("[data-fs-skeleton]", {
|
|
9
|
+
timeout: TEST_CONFIG.TIMEOUTS.LONG_DELAY,
|
|
10
|
+
}).should("not.exist");
|
|
11
|
+
cy.get("[data-fs-buying-policies-section]", {
|
|
12
|
+
timeout: TEST_CONFIG.TIMEOUTS.LONG_DELAY,
|
|
13
|
+
}).should("exist");
|
|
41
14
|
};
|
|
42
15
|
|
|
43
16
|
const fillBuyingPolicyForm = (
|
|
@@ -81,16 +54,6 @@ const openBuyingPolicyDropdown = (policyName: string) => {
|
|
|
81
54
|
});
|
|
82
55
|
};
|
|
83
56
|
|
|
84
|
-
const verifyEmptyState = () => {
|
|
85
|
-
cy.contains("Buying Policies").should("be.visible");
|
|
86
|
-
cy.get("[data-fs-empty-state-section]").should("be.visible");
|
|
87
|
-
cy.contains("No buying policies yet").should("be.visible");
|
|
88
|
-
|
|
89
|
-
// Verify page elements are present
|
|
90
|
-
cy.get("[data-fs-header-inside-button]").should("be.visible");
|
|
91
|
-
cy.get("[data-fs-buyer-portal-internal-search]").should("be.visible");
|
|
92
|
-
};
|
|
93
|
-
|
|
94
57
|
const confirmBuyingPolicyDeletion = (policyName: string) => {
|
|
95
58
|
cy.contains("Delete buying policy").should("be.visible");
|
|
96
59
|
cy.contains("Confirm by typing the buying policy name below:").should(
|
|
@@ -106,21 +69,20 @@ const confirmBuyingPolicyDeletion = (policyName: string) => {
|
|
|
106
69
|
cy.contains("button", "Delete").click();
|
|
107
70
|
};
|
|
108
71
|
|
|
109
|
-
|
|
72
|
+
let POLICY_NAME: string = "";
|
|
73
|
+
|
|
74
|
+
describe("Buying Policies", { retries: 2 }, () => {
|
|
75
|
+
before(() => {
|
|
76
|
+
POLICY_NAME = `${
|
|
77
|
+
TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME
|
|
78
|
+
} ${generateRandomString()}`;
|
|
79
|
+
});
|
|
110
80
|
beforeEach(() => {
|
|
111
81
|
cy.login();
|
|
112
|
-
});
|
|
113
82
|
|
|
114
|
-
it("Should display empty state when no buying policies exist", () => {
|
|
115
83
|
navigateToBuyingPolicies();
|
|
116
|
-
|
|
117
|
-
// Check for empty state
|
|
118
|
-
verifyEmptyState();
|
|
119
84
|
});
|
|
120
|
-
|
|
121
85
|
it("Should add a new buying policy", () => {
|
|
122
|
-
navigateToBuyingPolicies();
|
|
123
|
-
|
|
124
86
|
// Click to add a new buying policy
|
|
125
87
|
cy.get("[data-fs-header-inside-button]").should("be.visible").click();
|
|
126
88
|
|
|
@@ -128,7 +90,10 @@ describe("Buying Policies", () => {
|
|
|
128
90
|
cy.contains("Add new buying policy").should("be.visible");
|
|
129
91
|
|
|
130
92
|
// Fill buying policy form
|
|
131
|
-
fillBuyingPolicyForm(
|
|
93
|
+
fillBuyingPolicyForm({
|
|
94
|
+
...TEST_DATA.BUYING_POLICIES.NEW_POLICY,
|
|
95
|
+
NAME: POLICY_NAME,
|
|
96
|
+
});
|
|
132
97
|
|
|
133
98
|
// Submit form
|
|
134
99
|
cy.contains("button", "Add").click();
|
|
@@ -136,32 +101,36 @@ describe("Buying Policies", () => {
|
|
|
136
101
|
// Verify success message
|
|
137
102
|
cy.contains("Buying policy added successfully").should("be.visible");
|
|
138
103
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
104
|
+
useInternalSearch(POLICY_NAME);
|
|
105
|
+
|
|
106
|
+
cy.get("[data-fs-buying-policies-section]").within(() => {
|
|
107
|
+
cy.contains(POLICY_NAME).should("be.visible");
|
|
108
|
+
});
|
|
142
109
|
});
|
|
143
110
|
|
|
144
111
|
it("Should view buying policies list and details", () => {
|
|
145
|
-
navigateToBuyingPolicies();
|
|
146
|
-
|
|
147
112
|
// Verify list page elements
|
|
148
113
|
cy.contains("Buying Policies").should("be.visible");
|
|
149
114
|
cy.get("[data-fs-header-inside-button]").should("be.visible");
|
|
150
115
|
cy.get("[data-fs-buyer-portal-internal-search]").should("be.visible");
|
|
151
116
|
|
|
152
117
|
// Verify the created policy exists in the list
|
|
153
|
-
|
|
118
|
+
useInternalSearch(POLICY_NAME);
|
|
119
|
+
|
|
120
|
+
cy.get("[data-fs-buying-policies-section]").within(() => {
|
|
121
|
+
cy.contains(POLICY_NAME).should("be.visible");
|
|
122
|
+
});
|
|
154
123
|
|
|
155
124
|
// Test table structure and dropdown menu
|
|
156
125
|
cy.get("[data-fs-bp-table-row]")
|
|
157
|
-
.contains(
|
|
126
|
+
.contains(POLICY_NAME)
|
|
158
127
|
.parents("[data-fs-bp-table-row]")
|
|
159
128
|
.within(() => {
|
|
160
129
|
cy.get("[data-fs-bp-basic-dropdown-menu-trigger]").should("be.visible");
|
|
161
130
|
});
|
|
162
131
|
|
|
163
132
|
// Test dropdown menu options
|
|
164
|
-
openBuyingPolicyDropdown(
|
|
133
|
+
openBuyingPolicyDropdown(POLICY_NAME);
|
|
165
134
|
cy.contains("Open").should("be.visible");
|
|
166
135
|
cy.contains("Edit settings").should("be.visible");
|
|
167
136
|
cy.contains("Delete").should("be.visible");
|
|
@@ -169,24 +138,22 @@ describe("Buying Policies", () => {
|
|
|
169
138
|
// Close dropdown and navigate to details
|
|
170
139
|
cy.get("body").click(); // Close dropdown
|
|
171
140
|
|
|
172
|
-
|
|
173
|
-
cy.contains(TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME)
|
|
174
|
-
.should("be.visible")
|
|
175
|
-
.parents("[data-fs-bp-table-row]")
|
|
176
|
-
.click();
|
|
141
|
+
cy.wait(1000);
|
|
177
142
|
|
|
178
|
-
cy.
|
|
143
|
+
cy.get("[data-fs-skeleton]", {
|
|
144
|
+
timeout: TEST_CONFIG.TIMEOUTS.LONG_DELAY,
|
|
145
|
+
}).should("not.exist");
|
|
179
146
|
|
|
180
147
|
// Verify details page
|
|
181
148
|
cy.get("[data-fs-buying-policy-details-section]", {
|
|
182
149
|
timeout: TEST_CONFIG.TIMEOUTS.PAGE_LOAD,
|
|
183
150
|
}).should("exist");
|
|
184
|
-
cy.contains(
|
|
151
|
+
cy.contains(POLICY_NAME).should("be.visible");
|
|
185
152
|
cy.contains(TEST_DATA.BUYING_POLICIES.NEW_POLICY.DESCRIPTION).should(
|
|
186
153
|
"be.visible"
|
|
187
154
|
);
|
|
188
155
|
cy.contains("Name").should("be.visible");
|
|
189
|
-
cy.contains(
|
|
156
|
+
cy.contains(POLICY_NAME).should("be.visible");
|
|
190
157
|
cy.contains("Description").should("be.visible");
|
|
191
158
|
cy.contains(TEST_DATA.BUYING_POLICIES.NEW_POLICY.DESCRIPTION).should(
|
|
192
159
|
"be.visible"
|
|
@@ -203,18 +170,18 @@ describe("Buying Policies", () => {
|
|
|
203
170
|
});
|
|
204
171
|
|
|
205
172
|
it("Should edit the buying policy", () => {
|
|
206
|
-
navigateToBuyingPolicies();
|
|
207
|
-
|
|
208
173
|
// Open edit dialog
|
|
209
|
-
openBuyingPolicyDropdown(
|
|
210
|
-
cy.
|
|
174
|
+
openBuyingPolicyDropdown(POLICY_NAME);
|
|
175
|
+
cy.get("[data-fs-bp-basic-dropdown-menu]").within(() => {
|
|
176
|
+
cy.contains("Edit").click({ force: true });
|
|
177
|
+
});
|
|
211
178
|
|
|
212
179
|
// Verify edit drawer is open
|
|
213
180
|
cy.contains("Update Buying Policy").should("be.visible");
|
|
214
181
|
|
|
215
182
|
// Update policy information
|
|
216
183
|
const updatedPolicyData = {
|
|
217
|
-
NAME: `${
|
|
184
|
+
NAME: `${POLICY_NAME} Updated`,
|
|
218
185
|
DESCRIPTION: `${TEST_DATA.BUYING_POLICIES.NEW_POLICY.DESCRIPTION} Updated`,
|
|
219
186
|
CRITERIA: TEST_DATA.BUYING_POLICIES.NEW_POLICY.CRITERIA,
|
|
220
187
|
ACTION_TYPE: "Deny order",
|
|
@@ -228,25 +195,37 @@ describe("Buying Policies", () => {
|
|
|
228
195
|
// Verify success message
|
|
229
196
|
cy.contains("Buying policy updated successfully").should("be.visible");
|
|
230
197
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
198
|
+
useInternalSearch(updatedPolicyData.NAME);
|
|
199
|
+
|
|
200
|
+
cy.get("[data-fs-buying-policies-section]").within(() => {
|
|
201
|
+
cy.contains(updatedPolicyData.NAME).should("be.visible");
|
|
202
|
+
});
|
|
234
203
|
});
|
|
235
204
|
|
|
236
205
|
it("Should edit the buying policy on the details page", () => {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const updatedPolicyName = `${TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME} Updated`;
|
|
206
|
+
const updatedPolicyName = `${POLICY_NAME} Updated`;
|
|
240
207
|
|
|
241
|
-
|
|
208
|
+
useInternalSearch(updatedPolicyName);
|
|
242
209
|
|
|
210
|
+
cy.get("[data-fs-buying-policies-section]").within(() => {
|
|
211
|
+
cy.contains(updatedPolicyName).should("be.visible");
|
|
212
|
+
});
|
|
243
213
|
// Navigate to details
|
|
244
214
|
cy.contains(updatedPolicyName)
|
|
245
215
|
.should("be.visible")
|
|
246
216
|
.parents("[data-fs-bp-table-row]")
|
|
247
217
|
.click();
|
|
248
218
|
|
|
249
|
-
cy.wait(
|
|
219
|
+
cy.wait(1000);
|
|
220
|
+
|
|
221
|
+
cy.get("[data-fs-skeleton]", {
|
|
222
|
+
timeout: TEST_CONFIG.TIMEOUTS.LONG_DELAY,
|
|
223
|
+
}).should("not.exist");
|
|
224
|
+
|
|
225
|
+
// Verify details page
|
|
226
|
+
cy.get("[data-fs-buying-policy-details-section]", {
|
|
227
|
+
timeout: TEST_CONFIG.TIMEOUTS.PAGE_LOAD,
|
|
228
|
+
}).should("exist");
|
|
250
229
|
|
|
251
230
|
cy.contains("Edit").click();
|
|
252
231
|
|
|
@@ -274,27 +253,18 @@ describe("Buying Policies", () => {
|
|
|
274
253
|
it("Should delete the buying policy", () => {
|
|
275
254
|
navigateToBuyingPolicies();
|
|
276
255
|
|
|
277
|
-
const updatedPolicyName = `${
|
|
256
|
+
const updatedPolicyName = `${POLICY_NAME} Updated Edit`;
|
|
278
257
|
|
|
279
258
|
// Open delete dialog
|
|
280
259
|
openBuyingPolicyDropdown(updatedPolicyName);
|
|
281
|
-
cy.
|
|
260
|
+
cy.get("[data-fs-bp-basic-dropdown-menu]").within(() => {
|
|
261
|
+
cy.contains("Delete").click();
|
|
262
|
+
});
|
|
282
263
|
|
|
283
264
|
// Confirm deletion
|
|
284
265
|
confirmBuyingPolicyDeletion(updatedPolicyName);
|
|
285
266
|
|
|
286
267
|
// Verify success message
|
|
287
268
|
cy.contains("Buying policy deleted successfully").should("be.visible");
|
|
288
|
-
|
|
289
|
-
// Reload and verify policy was deleted
|
|
290
|
-
cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
|
|
291
|
-
verifyBuyingPolicyState(updatedPolicyName, false);
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it("Should display empty state again after deletion", () => {
|
|
295
|
-
navigateToBuyingPolicies();
|
|
296
|
-
|
|
297
|
-
// Check for empty state
|
|
298
|
-
verifyEmptyState();
|
|
299
269
|
});
|
|
300
270
|
});
|
|
@@ -9,179 +9,199 @@ function visitCollectionsPage() {
|
|
|
9
9
|
.contains("Collections")
|
|
10
10
|
.click({ timeout: TEST_CONFIG.TIMEOUTS.PAGE_LOAD });
|
|
11
11
|
|
|
12
|
+
cy.wait(1000);
|
|
13
|
+
|
|
14
|
+
cy.get("[data-fs-skeleton]", {
|
|
15
|
+
timeout: TEST_CONFIG.TIMEOUTS.LONG_DELAY,
|
|
16
|
+
}).should("not.exist");
|
|
17
|
+
|
|
12
18
|
cy.get("[data-fs-bp-collections-layout]").as("collectionLayout");
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
describe(
|
|
22
|
+
"Collections",
|
|
23
|
+
{
|
|
24
|
+
retries: 2,
|
|
25
|
+
},
|
|
26
|
+
() => {
|
|
27
|
+
const COLLECTION_UNDER_TEST = "Collection Demo";
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
cy.login();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("Should show empty state when unit has no collection", () => {
|
|
34
|
+
cy.intercept(
|
|
35
|
+
"GET",
|
|
36
|
+
"/_next/data/**/pvt/organization-account/collections/**",
|
|
37
|
+
(req) => {
|
|
38
|
+
req.reply((res) => {
|
|
39
|
+
res.body.pageProps.data.isContractEmpty = true;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
visitCollectionsPage();
|
|
45
|
+
|
|
46
|
+
cy.get("@collectionLayout")
|
|
47
|
+
.find("[data-fs-bp-collection-content]")
|
|
48
|
+
.should("not.exist");
|
|
49
|
+
cy.get("@collectionLayout")
|
|
50
|
+
.find("[data-fs-empty-state-section]")
|
|
51
|
+
.should("be.visible");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("Should list and filter Collections correctly", () => {
|
|
55
|
+
visitCollectionsPage();
|
|
56
|
+
|
|
57
|
+
// Wait for collections section to be visible
|
|
58
|
+
cy.get("[data-fs-bp-header-inside-title]")
|
|
59
|
+
.contains("Collections")
|
|
60
|
+
.should("be.visible");
|
|
61
|
+
|
|
62
|
+
// Wait for collections table to be loaded
|
|
63
|
+
cy.get("[data-fs-bp-collection-table]", {
|
|
64
|
+
timeout: TEST_CONFIG.TIMEOUTS.PAGE_LOAD,
|
|
65
|
+
}).should("exist");
|
|
66
|
+
|
|
67
|
+
cy.get("[data-fs-bp-table-row-title]")
|
|
68
|
+
.eq(0)
|
|
69
|
+
.then(($firstTitle) => {
|
|
70
|
+
cy.get("@collectionLayout")
|
|
71
|
+
.find("[data-fs-collection-filter] input")
|
|
72
|
+
.as("searchInput")
|
|
73
|
+
.should("be.visible")
|
|
74
|
+
.lazyType($firstTitle.text());
|
|
36
75
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.should("
|
|
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
|
-
.should("
|
|
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
|
-
cy.get("@deleteDrawer")
|
|
170
|
-
.find("[data-fs-bp-basic-drawer-heading]")
|
|
171
|
-
.contains("Remove collection from unit")
|
|
172
|
-
.should("be.visible");
|
|
173
|
-
|
|
174
|
-
// Find remove confirmation button and click it
|
|
175
|
-
cy.get("@deleteDrawer")
|
|
176
|
-
.find("[data-fs-bp-basic-drawer-button-variant='confirm']")
|
|
177
|
-
.should("be.visible")
|
|
178
|
-
.click();
|
|
179
|
-
|
|
180
|
-
// Wait for page refresh
|
|
181
|
-
cy.wait(TEST_CONFIG.TIMEOUTS.RETRY_DELAY);
|
|
182
|
-
|
|
183
|
-
// Check if the list was updated without removed collection
|
|
184
|
-
cy.get("@deleteDrawer").should("not.exist");
|
|
185
|
-
checkCollectionList(3).contains(COLLECTION_UNDER_TEST).should("not.exist");
|
|
186
|
-
});
|
|
187
|
-
});
|
|
76
|
+
|
|
77
|
+
// Wait for list to update
|
|
78
|
+
cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
|
|
79
|
+
|
|
80
|
+
// Check if the resulted collection is visible
|
|
81
|
+
cy.get("[data-fs-bp-collection-table]", {
|
|
82
|
+
timeout: TEST_CONFIG.TIMEOUTS.PAGE_LOAD,
|
|
83
|
+
}).should("exist");
|
|
84
|
+
|
|
85
|
+
// Clear search field and include an invalid keyword
|
|
86
|
+
cy.get("@searchInput").clear().lazyType("foo bar");
|
|
87
|
+
|
|
88
|
+
// Wait for list to update
|
|
89
|
+
cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
|
|
90
|
+
|
|
91
|
+
cy.get("[data-fs-bp-table] [data-fs-bp-table-row]").should("not.exist");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("Should add a new Collection correctly", () => {
|
|
95
|
+
visitCollectionsPage();
|
|
96
|
+
|
|
97
|
+
// Check if drawer is present on screen
|
|
98
|
+
cy.get("[data-fs-bp-add-collections-drawer]").should("not.exist");
|
|
99
|
+
|
|
100
|
+
// Click on add button to open drawer
|
|
101
|
+
cy.get("@collectionLayout")
|
|
102
|
+
.find("[aria-label='Add collection']")
|
|
103
|
+
.should("be.visible")
|
|
104
|
+
.click();
|
|
105
|
+
|
|
106
|
+
// Check if drawer was opened
|
|
107
|
+
cy.get("[data-fs-bp-add-collections-drawer]")
|
|
108
|
+
.as("addDrawer")
|
|
109
|
+
.should("be.visible");
|
|
110
|
+
cy.get("@addDrawer")
|
|
111
|
+
.find("[data-fs-bp-basic-drawer-heading]")
|
|
112
|
+
.contains("Add collections")
|
|
113
|
+
.should("be.visible");
|
|
114
|
+
|
|
115
|
+
// Check if collections was listed correclty and submit button is disable
|
|
116
|
+
cy.get("@addDrawer")
|
|
117
|
+
.find("[data-fs-bp-basic-drawer-button-variant='confirm']")
|
|
118
|
+
.as("submitButton")
|
|
119
|
+
.should("be.disabled");
|
|
120
|
+
cy.get("@addDrawer")
|
|
121
|
+
.find("[data-fs-bp-add-collections-drawer-table] tbody tr")
|
|
122
|
+
.as("results");
|
|
123
|
+
|
|
124
|
+
// Check if empty state is visibile when a search returns no results
|
|
125
|
+
cy.get("@addDrawer")
|
|
126
|
+
.find("[data-fs-buyer-portal-internal-search-input]")
|
|
127
|
+
.as("input")
|
|
128
|
+
.type("foo bar");
|
|
129
|
+
cy.get("@addDrawer")
|
|
130
|
+
.find("[data-fs-bp-add-collections-drawer-empty-state]")
|
|
131
|
+
.as("emptyState")
|
|
132
|
+
.should("be.visible");
|
|
133
|
+
cy.get("@results").should("not.exist");
|
|
134
|
+
|
|
135
|
+
// Check if results is updated when search results is not empty
|
|
136
|
+
cy.get("@input").clear().type(COLLECTION_UNDER_TEST);
|
|
137
|
+
cy.get("@emptyState").should("not.exist");
|
|
138
|
+
cy.get("@results").should("have.length", 1);
|
|
139
|
+
|
|
140
|
+
// Select first Collection
|
|
141
|
+
cy.get("@addDrawer")
|
|
142
|
+
.find(
|
|
143
|
+
"[data-fs-bp-add-collections-drawer-table] tbody td [data-fs-checkbox]"
|
|
144
|
+
)
|
|
145
|
+
.first()
|
|
146
|
+
.check();
|
|
147
|
+
|
|
148
|
+
// Check if submit button is enable and click it
|
|
149
|
+
cy.get("@submitButton").should("be.enabled").click();
|
|
150
|
+
|
|
151
|
+
// Wait for page refresh
|
|
152
|
+
cy.wait(TEST_CONFIG.TIMEOUTS.RETRY_DELAY);
|
|
153
|
+
|
|
154
|
+
cy.get("[data-fs-bp-collection-table]", {
|
|
155
|
+
timeout: TEST_CONFIG.TIMEOUTS.PAGE_LOAD,
|
|
156
|
+
}).within(() => {
|
|
157
|
+
cy.contains(COLLECTION_UNDER_TEST);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("Should remove Collection correctly", () => {
|
|
162
|
+
visitCollectionsPage();
|
|
163
|
+
|
|
164
|
+
// Check if delete drawer is not visible
|
|
165
|
+
cy.get("[data-fs-bp-remove-collections-drawer]").should("not.exist");
|
|
166
|
+
|
|
167
|
+
// Count current collection list before remove one
|
|
168
|
+
cy.get("[data-fs-bp-collection-table]", {
|
|
169
|
+
timeout: TEST_CONFIG.TIMEOUTS.PAGE_LOAD,
|
|
170
|
+
}).should("exist");
|
|
171
|
+
|
|
172
|
+
// Find remove collection icon button and click it
|
|
173
|
+
cy.get("[data-fs-bp-table] [data-fs-bp-table-row]")
|
|
174
|
+
.contains(COLLECTION_UNDER_TEST)
|
|
175
|
+
.closest("[data-fs-bp-table-row]")
|
|
176
|
+
.find("[aria-label='Remove collections']")
|
|
177
|
+
.click();
|
|
178
|
+
|
|
179
|
+
// Check if delete drawer was opened
|
|
180
|
+
cy.get("[data-fs-bp-remove-collections-drawer]")
|
|
181
|
+
.as("deleteDrawer")
|
|
182
|
+
.should("be.visible");
|
|
183
|
+
cy.get("@deleteDrawer")
|
|
184
|
+
.find("[data-fs-bp-basic-drawer-heading]")
|
|
185
|
+
.contains("Remove collection from unit")
|
|
186
|
+
.should("be.visible");
|
|
187
|
+
|
|
188
|
+
// Find remove confirmation button and click it
|
|
189
|
+
cy.get("@deleteDrawer")
|
|
190
|
+
.find("[data-fs-bp-basic-drawer-button-variant='confirm']")
|
|
191
|
+
.should("be.visible")
|
|
192
|
+
.click();
|
|
193
|
+
|
|
194
|
+
// Wait for page refresh
|
|
195
|
+
cy.wait(TEST_CONFIG.TIMEOUTS.RETRY_DELAY);
|
|
196
|
+
|
|
197
|
+
// Check if the list was updated without removed collection
|
|
198
|
+
cy.get("@deleteDrawer").should("not.exist");
|
|
199
|
+
cy.get("[data-fs-bp-collection-table]", {
|
|
200
|
+
timeout: TEST_CONFIG.TIMEOUTS.PAGE_LOAD,
|
|
201
|
+
})
|
|
202
|
+
.should("exist")
|
|
203
|
+
.contains(COLLECTION_UNDER_TEST)
|
|
204
|
+
.should("not.exist");
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
);
|