@vtex/faststore-plugin-buyer-portal 1.1.92 → 1.1.94

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.
Files changed (62) hide show
  1. package/cypress/constants.ts +4 -9
  2. package/cypress/integration/addresses.test.ts +39 -55
  3. package/cypress/integration/budgets.test.ts +130 -100
  4. package/cypress/integration/buying-policies.test.ts +66 -96
  5. package/cypress/integration/collections.test.ts +192 -172
  6. package/cypress/integration/credit-cards.test.ts +1 -1
  7. package/cypress/integration/locations.test.ts +39 -43
  8. package/cypress/integration/organizational-units.test.ts +70 -33
  9. package/cypress/integration/recipients.test.ts +34 -46
  10. package/cypress/integration/users.test.ts +83 -136
  11. package/cypress/shared.ts +32 -2
  12. package/cypress/support/addressHelper.tsx +17 -6
  13. package/package.json +1 -1
  14. package/public/buyer-portal-icons.svg +1 -1
  15. package/src/features/addresses/components/DeleteRecipientAddressDrawer/DeleteRecipientAddressDrawer.tsx +1 -1
  16. package/src/features/addresses/services/get-addresses-by-unit-id.service.ts +13 -1
  17. package/src/features/addresses/services/get-addresses.service.ts +15 -2
  18. package/src/features/buying-policies/services/get-buying-policies.service.ts +19 -21
  19. package/src/features/contracts/services/get-contract-details.service.ts +13 -1
  20. package/src/features/contracts/services/get-contracts-org-by-unit-id.service.ts +18 -11
  21. package/src/features/contracts/services/update-contract-status.service.ts +18 -11
  22. package/src/features/profile/layouts/ProfileLayout/profile-layout.scss +1 -0
  23. package/src/features/shared/clients/Client.ts +84 -8
  24. package/src/features/shared/components/BuyerPortalProvider/BuyerPortalProvider.tsx +4 -1
  25. package/src/features/shared/components/Error/Error.tsx +31 -0
  26. package/src/features/shared/components/Error/error.scss +71 -0
  27. package/src/features/shared/components/ErrorBoundary/ErrorBoundary.tsx +63 -0
  28. package/src/features/shared/components/ErrorBoundary/types.ts +14 -0
  29. package/src/features/shared/components/index.ts +3 -0
  30. package/src/features/shared/components/withErrorBoundary/withErrorBoundary.tsx +35 -0
  31. package/src/features/shared/layouts/BaseTabsLayout/SidebarMenu.tsx +9 -2
  32. package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +4 -2
  33. package/src/features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout.tsx +119 -0
  34. package/src/features/shared/layouts/ErrorTabsLayout/error-tabs-layout.scss +1 -0
  35. package/src/features/shared/utils/constants.ts +1 -1
  36. package/src/features/shared/utils/environment.ts +41 -0
  37. package/src/features/shared/utils/extractErrorMessage.ts +22 -0
  38. package/src/features/shared/utils/getHome.tsx +5 -0
  39. package/src/features/shared/utils/index.ts +2 -0
  40. package/src/features/shared/utils/withClientErrorBoundary.ts +61 -0
  41. package/src/features/shared/utils/withLoaderErrorBoundary.ts +46 -0
  42. package/src/features/users/clients/UsersClient.ts +0 -1
  43. package/src/pages/address-details.tsx +38 -11
  44. package/src/pages/addresses.tsx +35 -6
  45. package/src/pages/budgets-details.tsx +38 -8
  46. package/src/pages/budgets.tsx +33 -8
  47. package/src/pages/buying-policies.tsx +36 -12
  48. package/src/pages/buying-policy-details.tsx +38 -8
  49. package/src/pages/collections.tsx +36 -12
  50. package/src/pages/cost-centers.tsx +38 -8
  51. package/src/pages/credit-cards.tsx +38 -8
  52. package/src/pages/home.tsx +22 -5
  53. package/src/pages/org-unit-details.tsx +43 -7
  54. package/src/pages/org-units.tsx +39 -8
  55. package/src/pages/payment-methods.tsx +38 -8
  56. package/src/pages/po-numbers.tsx +38 -8
  57. package/src/pages/profile.tsx +31 -6
  58. package/src/pages/releases.tsx +33 -8
  59. package/src/pages/role-details.tsx +39 -7
  60. package/src/pages/roles.tsx +28 -7
  61. package/src/pages/user-details.tsx +39 -8
  62. package/src/pages/users.tsx +25 -7
@@ -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.wait(TEST_CONFIG.TIMEOUTS.RETRY_DELAY);
8
- cy.get("[data-fs-buying-policies-section]").should("exist");
9
- };
10
-
11
- const verifyBuyingPolicyState = (
12
- policyName: string,
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
- describe("Buying Policies", () => {
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(TEST_DATA.BUYING_POLICIES.NEW_POLICY);
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
- // Reload and verify policy was created
140
- cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
141
- verifyBuyingPolicyState(TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME, true);
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
- verifyBuyingPolicyState(TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME, true);
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(TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME)
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(TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME);
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
- // Navigate to details
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.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
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(TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME).should("be.visible");
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(TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME).should("be.visible");
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(TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME);
210
- cy.contains("Edit").click();
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: `${TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME} Updated`,
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
- // Reload and verify policy was updated
232
- verifyBuyingPolicyState(TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME, false);
233
- verifyBuyingPolicyState(updatedPolicyData.NAME, true);
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
- navigateToBuyingPolicies();
238
-
239
- const updatedPolicyName = `${TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME} Updated`;
206
+ const updatedPolicyName = `${POLICY_NAME} Updated`;
240
207
 
241
- verifyBuyingPolicyState(updatedPolicyName, true);
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(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
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 = `${TEST_DATA.BUYING_POLICIES.NEW_POLICY.NAME} Updated Edit`;
256
+ const updatedPolicyName = `${POLICY_NAME} Updated Edit`;
278
257
 
279
258
  // Open delete dialog
280
259
  openBuyingPolicyDropdown(updatedPolicyName);
281
- cy.contains("Delete").click();
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
- const checkCollectionList = (length: number) =>
16
- cy
17
- .get("@collectionLayout")
18
- .find("[data-fs-bp-table] [data-fs-bp-table-row]")
19
- .as("collectionList")
20
- .should("have.length", length);
21
-
22
- describe("Collections", () => {
23
- const COLLECTION_UNDER_TEST = "Collection Demo";
24
-
25
- beforeEach(() => {
26
- cy.login();
27
- });
28
-
29
- it("Should show empty state when unit has no collection", () => {
30
- cy.intercept(
31
- "GET",
32
- "/_next/data/**/pvt/organization-account/collections/**",
33
- (req) => {
34
- req.reply((res) => {
35
- res.body.pageProps.data.isContractEmpty = true;
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
- visitCollectionsPage();
41
-
42
- cy.get("@collectionLayout")
43
- .find("[data-fs-bp-collection-content]")
44
- .should("not.exist");
45
- cy.get("@collectionLayout")
46
- .find("[data-fs-empty-state-section]")
47
- .should("be.visible");
48
- });
49
-
50
- it("Should list and filter Collections correctly", () => {
51
- visitCollectionsPage();
52
-
53
- // Wait for collections section to be visible
54
- cy.get("[data-fs-bp-header-inside-title]")
55
- .contains("Collections")
56
- .should("be.visible");
57
-
58
- // Wait for collections table to be loaded
59
- checkCollectionList(3);
60
-
61
- // Type a valid name in search input
62
- cy.get("@collectionLayout")
63
- .find("[data-fs-collection-filter] input")
64
- .as("searchInput")
65
- .should("be.visible")
66
- .lazyType("Produtos");
67
-
68
- // Wait for list to update
69
- cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
70
-
71
- // Check if the resulted collection is visible
72
- checkCollectionList(1);
73
-
74
- // Clear search field and include an invalid keyword
75
- cy.get("@searchInput").clear().lazyType("foo bar");
76
-
77
- // Wait for list to update
78
- cy.wait(TEST_CONFIG.TIMEOUTS.PAGE_LOAD);
79
-
80
- // Check if no collection is listed
81
- cy.get("@collectionList").should("not.exist");
82
- });
83
-
84
- it("Should add a new Collection correctly", () => {
85
- visitCollectionsPage();
86
-
87
- // Check if drawer is present on screen
88
- cy.get("[data-fs-bp-add-collections-drawer]").should("not.exist");
89
-
90
- // Click on add button to open drawer
91
- cy.get("@collectionLayout")
92
- .find("[aria-label='Add collection']")
93
- .should("be.visible")
94
- .click();
95
-
96
- // Check if drawer was opened
97
- cy.get("[data-fs-bp-add-collections-drawer]")
98
- .as("addDrawer")
99
- .should("be.visible");
100
- cy.get("@addDrawer")
101
- .find("[data-fs-bp-basic-drawer-heading]")
102
- .contains("Add collections")
103
- .should("be.visible");
104
-
105
- // Check if collections was listed correclty and submit button is disable
106
- cy.get("@addDrawer")
107
- .find("[data-fs-bp-basic-drawer-button-variant='confirm']")
108
- .as("submitButton")
109
- .should("be.disabled");
110
- cy.get("@addDrawer")
111
- .find("[data-fs-bp-add-collections-drawer-table] tbody tr")
112
- .as("results")
113
- .should("have.length", 2);
114
-
115
- // Check if empty state is visibile when a search returns no results
116
- cy.get("@addDrawer")
117
- .find("[data-fs-buyer-portal-internal-search-input]")
118
- .as("input")
119
- .type("foo bar");
120
- cy.get("@addDrawer")
121
- .find("[data-fs-bp-add-collections-drawer-empty-state]")
122
- .as("emptyState")
123
- .should("be.visible");
124
- cy.get("@results").should("not.exist");
125
-
126
- // Check if results is updated when search results is not empty
127
- cy.get("@input").clear().type(COLLECTION_UNDER_TEST);
128
- cy.get("@emptyState").should("not.exist");
129
- cy.get("@results").should("have.length", 1);
130
-
131
- // Select first Collection
132
- cy.get("@addDrawer")
133
- .find(
134
- "[data-fs-bp-add-collections-drawer-table] tbody td [data-fs-checkbox]"
135
- )
136
- .first()
137
- .check();
138
-
139
- // Check if submit button is enable and click it
140
- cy.get("@submitButton").should("be.enabled").click();
141
-
142
- // Wait for page refresh
143
- cy.wait(TEST_CONFIG.TIMEOUTS.RETRY_DELAY);
144
-
145
- // Wait for collections table to be loaded
146
- checkCollectionList(4).contains(COLLECTION_UNDER_TEST);
147
- });
148
-
149
- it("Should remove Collection correctly", () => {
150
- visitCollectionsPage();
151
-
152
- // Check if delete drawer is not visible
153
- cy.get("[data-fs-bp-remove-collections-drawer]").should("not.exist");
154
-
155
- // Count current collection list before remove one
156
- checkCollectionList(4);
157
-
158
- // Find remove collection icon button and click it
159
- cy.get("@collectionList")
160
- .contains(COLLECTION_UNDER_TEST)
161
- .closest("[data-fs-bp-table-row]")
162
- .find("[aria-label='Remove collections']")
163
- .click();
164
-
165
- // Check if delete drawer was opened
166
- cy.get("[data-fs-bp-remove-collections-drawer]")
167
- .as("deleteDrawer")
168
- .should("be.visible");
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
+ );
@@ -67,7 +67,7 @@ function fillInitialCreditCardData() {
67
67
  .type(TEST_DATA.CREDIT_CARDS.NEW_CARD.CARDHOLDER_NAME);
68
68
  }
69
69
 
70
- describe("Credit Cards Page", () => {
70
+ describe("Credit Cards Page", { retries: 2 }, () => {
71
71
  beforeEach(() => {
72
72
  cy.login();
73
73
  });