@bigbinary/neeto-commons-frontend 2.0.43 → 2.0.44
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-commands.d.ts +1 -0
- package/cypress-utils.cjs.js +133 -119
- package/cypress-utils.d.ts +3 -1
- package/cypress-utils.js +133 -120
- package/package.json +6 -6
- package/react-utils.cjs.js +17 -2
- package/react-utils.js +17 -2
package/cypress-commands.d.ts
CHANGED
package/cypress-utils.cjs.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var common = require('constants/texts/common');
|
|
5
6
|
var dayjs = require('dayjs');
|
|
6
7
|
|
|
7
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -171,7 +172,8 @@ var commonSelectors = {
|
|
|
171
172
|
toastMessage: dataCy("toastr-message-container"),
|
|
172
173
|
toastCloseButton: ".neeto-ui-toastr__close-button",
|
|
173
174
|
windowAlert: "#alert-box",
|
|
174
|
-
body: "body"
|
|
175
|
+
body: "body",
|
|
176
|
+
toastIcon: ".Toastify__toast-icon"
|
|
175
177
|
};
|
|
176
178
|
var tableSelectors = {
|
|
177
179
|
nthColumn: function nthColumn(n) {
|
|
@@ -190,125 +192,132 @@ var profileSelectors = {
|
|
|
190
192
|
|
|
191
193
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
192
194
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
Cypress.Commands.add("clearAndTypeFast", function (selector, text) {
|
|
197
|
-
cy.get(selector).clear().type(text, {
|
|
198
|
-
delay: 0
|
|
195
|
+
var initCustomCommands = function initCustomCommands() {
|
|
196
|
+
Cypress.Commands.add("clearAndType", function (selector, text) {
|
|
197
|
+
cy.get(selector).clear().type(text);
|
|
199
198
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
199
|
+
Cypress.Commands.add("clearAndTypeFast", function (selector, text) {
|
|
200
|
+
cy.get(selector).clear().type(text, {
|
|
201
|
+
delay: 0
|
|
202
|
+
});
|
|
204
203
|
});
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
Cypress.Commands.add("clearByClickAndTypeFast", function (selector, text) {
|
|
205
|
+
cy.get(selector).click().clear().type(text, {
|
|
206
|
+
delay: 0
|
|
207
|
+
});
|
|
209
208
|
});
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
|
|
209
|
+
Cypress.Commands.add("typeFast", function (selector, text) {
|
|
210
|
+
cy.get(selector).type(text, {
|
|
211
|
+
delay: 0
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
Cypress.Commands.add("typeAndEnter", function (selector, text) {
|
|
215
|
+
cy.get(selector).clear().type("".concat(text, "{enter}"));
|
|
216
|
+
});
|
|
217
|
+
Cypress.Commands.add("verifyToastMessage", function (message) {
|
|
218
|
+
cy.get(commonSelectors.toastMessage).should("be.visible").should("have.text", message);
|
|
216
219
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
});
|
|
221
|
-
Cypress.Commands.add("continueOnAlert", function (args) {
|
|
222
|
-
var props = _typeof(args) === "object" ? args : {
|
|
223
|
-
alias: args
|
|
224
|
-
};
|
|
225
|
-
var alias = props.alias,
|
|
226
|
-
title = props.title,
|
|
227
|
-
description = props.description,
|
|
228
|
-
_props$requestCount = props.requestCount,
|
|
229
|
-
requestCount = _props$requestCount === void 0 ? 1 : _props$requestCount,
|
|
230
|
-
toastMessage = props.toastMessage;
|
|
231
|
-
var hasMoreThanOneRequest = requestCount > 1;
|
|
232
|
-
title && cy.get(commonSelectors.alertTitle).should("have.text", title);
|
|
233
|
-
description && cy.get(commonSelectors.alertModalMessage).should("have.text", description);
|
|
234
|
-
cy.interceptApi(alias, requestCount);
|
|
235
|
-
cy.get(commonSelectors.alertModalSubmitButton).click();
|
|
236
|
-
cy.wait("@".concat(alias));
|
|
237
|
-
toastMessage && cy.verifyToastMessage(toastMessage);
|
|
238
|
-
hasMoreThanOneRequest && cy.waitForMultipleRequest("@".concat(alias), requestCount - 1);
|
|
239
|
-
});
|
|
240
|
-
Cypress.Commands.add("interceptApi", function (alias) {
|
|
241
|
-
var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
242
|
-
return cy.intercept({
|
|
243
|
-
url: requestApis.allPath,
|
|
244
|
-
times: times
|
|
245
|
-
}).as(alias);
|
|
246
|
-
});
|
|
247
|
-
Cypress.Commands.add("waitForMultipleRequest", function (alias) {
|
|
248
|
-
var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
249
|
-
return cy.wrap(_toConsumableArray(new Array(times))).each(function () {
|
|
250
|
-
return cy.wait(alias);
|
|
220
|
+
// close toast message
|
|
221
|
+
cy.get(commonSelectors.toastCloseButton).click();
|
|
222
|
+
cy.get(commonSelectors.toastMessage).should("not.exist");
|
|
251
223
|
});
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
headers: requestHeaders
|
|
257
|
-
})) : cy.log("No request headers found");
|
|
224
|
+
Cypress.Commands.add("verifyToastIcon", function () {
|
|
225
|
+
cy.get(commonSelectors.toastIcon).should("have.text", common.commonTexts.toastIcon);
|
|
226
|
+
cy.get(commonSelectors.toastCloseButton).click();
|
|
227
|
+
cy.get(commonSelectors.toastIcon).should("not.exist");
|
|
258
228
|
});
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
selector = _ref.selector;
|
|
290
|
-
cy.window().then(function (win) {
|
|
291
|
-
cy.stub(win, "open").as(alias).callsFake(function (newUrl) {
|
|
292
|
-
return win.location.href = newUrl;
|
|
229
|
+
Cypress.Commands.add("continueOnAlert", function (args) {
|
|
230
|
+
var props = _typeof(args) === "object" ? args : {
|
|
231
|
+
alias: args
|
|
232
|
+
};
|
|
233
|
+
var alias = props.alias,
|
|
234
|
+
title = props.title,
|
|
235
|
+
_props$requestCount = props.requestCount,
|
|
236
|
+
requestCount = _props$requestCount === void 0 ? 1 : _props$requestCount,
|
|
237
|
+
verifyToastIcon = props.verifyToastIcon,
|
|
238
|
+
toastMessage = props.toastMessage;
|
|
239
|
+
var hasMoreThanOneRequest = requestCount > 1;
|
|
240
|
+
title && cy.get(commonSelectors.alertTitle).should("have.text", title);
|
|
241
|
+
cy.interceptApi(alias, requestCount);
|
|
242
|
+
cy.get(commonSelectors.alertModalSubmitButton).click();
|
|
243
|
+
cy.wait("@".concat(alias));
|
|
244
|
+
verifyToastIcon && cy.verifyToastIcon();
|
|
245
|
+
toastMessage && cy.verifyToastMessage(toastMessage);
|
|
246
|
+
hasMoreThanOneRequest && cy.waitForMultipleRequest("@".concat(alias), requestCount - 1);
|
|
247
|
+
});
|
|
248
|
+
Cypress.Commands.add("interceptApi", function (alias) {
|
|
249
|
+
var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
250
|
+
return cy.intercept({
|
|
251
|
+
url: requestApis.allPath,
|
|
252
|
+
times: times
|
|
253
|
+
}).as(alias);
|
|
254
|
+
});
|
|
255
|
+
Cypress.Commands.add("waitForMultipleRequest", function (alias) {
|
|
256
|
+
var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
257
|
+
return cy.wrap(_toConsumableArray(new Array(times))).each(function () {
|
|
258
|
+
return cy.wait(alias);
|
|
293
259
|
});
|
|
294
260
|
});
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
});
|
|
302
|
-
Cypress.Commands.add("ifExist", function (selector, callback) {
|
|
303
|
-
cy.get(commonSelectors.body).then(function ($body) {
|
|
304
|
-
if ($body.find(selector).length) callback();
|
|
261
|
+
Cypress.Commands.add("apiRequest", function (options) {
|
|
262
|
+
return cy.get("@requestHeaders").then(function (requestHeaders) {
|
|
263
|
+
return requestHeaders ? cy.request(_objectSpread(_objectSpread({}, options), {}, {
|
|
264
|
+
headers: requestHeaders
|
|
265
|
+
})) : cy.log("No request headers found");
|
|
266
|
+
});
|
|
305
267
|
});
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
268
|
+
Cypress.Commands.add("reloadAndWait", function () {
|
|
269
|
+
var requestCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
270
|
+
if (requestCount > 0) {
|
|
271
|
+
cy.interceptApi("reloadAllRequests", requestCount);
|
|
272
|
+
cy.reload();
|
|
273
|
+
cy.waitForMultipleRequest("@reloadAllRequests", requestCount);
|
|
274
|
+
}
|
|
310
275
|
});
|
|
311
|
-
|
|
276
|
+
Cypress.Commands.add("selectOption", function (containerSelector, optionText) {
|
|
277
|
+
cy.get(containerSelector).click().type(optionText);
|
|
278
|
+
cy.contains(commonSelectors.selectOption, optionText).invoke("click");
|
|
279
|
+
});
|
|
280
|
+
Cypress.Commands.add("clickDropdownOption", function (optionText) {
|
|
281
|
+
var dropdownSelector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : commonSelectors.dropdownIcon;
|
|
282
|
+
cy.get(dropdownSelector).click();
|
|
283
|
+
cy.get(commonSelectors.dropdownContainer).contains(optionText).invoke("click");
|
|
284
|
+
});
|
|
285
|
+
Cypress.Commands.add("getText", function (selector) {
|
|
286
|
+
return cy.get(selector).invoke("text");
|
|
287
|
+
});
|
|
288
|
+
Cypress.Commands.add("getValue", function (selector) {
|
|
289
|
+
return cy.get(selector).invoke("val");
|
|
290
|
+
});
|
|
291
|
+
Cypress.Commands.add("getIframe", function (iframeSelector) {
|
|
292
|
+
return cy.get(iframeSelector).its("0.contentDocument.body").should("not.be.empty");
|
|
293
|
+
});
|
|
294
|
+
Cypress.Commands.add("openInSameTabOnClick", function (_ref) {
|
|
295
|
+
var url = _ref.url,
|
|
296
|
+
alias = _ref.alias,
|
|
297
|
+
selector = _ref.selector;
|
|
298
|
+
cy.window().then(function (win) {
|
|
299
|
+
cy.stub(win, "open").as(alias).callsFake(function (newUrl) {
|
|
300
|
+
return win.location.href = newUrl;
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
cy.get(selector).click();
|
|
304
|
+
cy.get("@".concat(alias)).should("be.called");
|
|
305
|
+
cy.url().should("include", url);
|
|
306
|
+
});
|
|
307
|
+
Cypress.Commands.add("globalState", function (key) {
|
|
308
|
+
return cy.task("getGlobalState", key);
|
|
309
|
+
});
|
|
310
|
+
Cypress.Commands.add("ifExist", function (selector, callback) {
|
|
311
|
+
cy.get(commonSelectors.body).then(function ($body) {
|
|
312
|
+
if ($body.find(selector).length) callback();
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
Cypress.Commands.add("ifNotExist", function (selector, callback) {
|
|
316
|
+
cy.get(commonSelectors.body).then(function ($body) {
|
|
317
|
+
if (!$body.find(selector).length) callback();
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
};
|
|
312
321
|
|
|
313
322
|
var loginSelectors = {
|
|
314
323
|
appleAuthenticationButton: dataCy("apple-authentication-button"),
|
|
@@ -372,7 +381,8 @@ var commonTexts = {
|
|
|
372
381
|
logout: "Log out",
|
|
373
382
|
"new": "New",
|
|
374
383
|
takeAction: "Take action",
|
|
375
|
-
unblock: "Unblock"
|
|
384
|
+
unblock: "Unblock",
|
|
385
|
+
toastIcon: "👍"
|
|
376
386
|
};
|
|
377
387
|
|
|
378
388
|
var memberTexts = {
|
|
@@ -695,7 +705,7 @@ var memberUtils = {
|
|
|
695
705
|
verifyMemberDetails: verifyMemberDetails
|
|
696
706
|
};
|
|
697
707
|
|
|
698
|
-
var updateSubdmainIfExit = function updateSubdmainIfExit(subdomainName) {
|
|
708
|
+
var updateSubdmainIfExit = function updateSubdmainIfExit(appName, subdomainName) {
|
|
699
709
|
cy.ifExist(signUpSelectors.subdomainError, function () {
|
|
700
710
|
var lastDigit = Number(subdomainName.charAt(subdomainName.length - 1));
|
|
701
711
|
var newOrganizationName = subdomainName.slice(0, -1) + (lastDigit + 1);
|
|
@@ -714,9 +724,7 @@ var updateSubdmainIfExit = function updateSubdmainIfExit(subdomainName) {
|
|
|
714
724
|
key: "businessName",
|
|
715
725
|
value: newOrganizationName
|
|
716
726
|
});
|
|
717
|
-
var
|
|
718
|
-
var domain = baseUrl.split(".")[1];
|
|
719
|
-
var newBaseUrl = "https://".concat(newOrganizationName, ".").concat(domain, ".net");
|
|
727
|
+
var newBaseUrl = "https://".concat(newOrganizationName, ".").concat(appName, ".net");
|
|
720
728
|
Cypress.config("baseUrl", newBaseUrl);
|
|
721
729
|
cy.clearAndType(signUpSelectors.organizationNameTextField, newOrganizationName);
|
|
722
730
|
});
|
|
@@ -731,10 +739,15 @@ var createOrganization = function createOrganization(_ref) {
|
|
|
731
739
|
subdomainName = _ref.subdomainName,
|
|
732
740
|
firstName = _ref.firstName,
|
|
733
741
|
lastName = _ref.lastName,
|
|
734
|
-
|
|
742
|
+
appName = _ref.appName;
|
|
735
743
|
var otp = "123456";
|
|
736
|
-
|
|
737
|
-
|
|
744
|
+
var appNameInLowerCase = appName.toLowerCase();
|
|
745
|
+
var isNeetoAuth = appNameInLowerCase === "neetoauth";
|
|
746
|
+
if (isNeetoAuth) cy.visit("https://app.neetoauth.net/signups/new");else {
|
|
747
|
+
var startingUrl = "https://www.neeto.com/".concat(appNameInLowerCase, "?env=staging");
|
|
748
|
+
cy.visit(startingUrl);
|
|
749
|
+
cy.get(signUpSelectors.tryFreeButton).invoke("removeAttr", "target").click();
|
|
750
|
+
}
|
|
738
751
|
cy.get(signUpSelectors.signupViaEmailButton).should("contain.text", signUpTexts.email).click();
|
|
739
752
|
cy.clearAndType(signUpSelectors.emailTextField, email);
|
|
740
753
|
cy.intercept({
|
|
@@ -752,7 +765,7 @@ var createOrganization = function createOrganization(_ref) {
|
|
|
752
765
|
cy.clearAndType(signUpSelectors.organizationNameTextField, businessName);
|
|
753
766
|
cy.clearAndType(signUpSelectors.subdomainNameTextField, subdomainName);
|
|
754
767
|
cy.wait("@subdomainRequest");
|
|
755
|
-
updateSubdmainIfExit(subdomainName);
|
|
768
|
+
updateSubdmainIfExit(appNameInLowerCase, subdomainName);
|
|
756
769
|
cy.intercept({
|
|
757
770
|
url: requestApis.signUp,
|
|
758
771
|
times: 1
|
|
@@ -794,6 +807,7 @@ exports.dateUtils = dateUtils;
|
|
|
794
807
|
exports.environment = environment;
|
|
795
808
|
exports.getTestTitle = getTestTitle;
|
|
796
809
|
exports.getUrl = getUrl;
|
|
810
|
+
exports.initCustomCommands = initCustomCommands;
|
|
797
811
|
exports.initializeCredentials = initializeCredentials;
|
|
798
812
|
exports.isStagingEnv = isStagingEnv;
|
|
799
813
|
exports.joinHyphenCase = joinHyphenCase;
|
package/cypress-utils.d.ts
CHANGED
|
@@ -141,6 +141,8 @@ function futureDate(numberOfDays: number = 1): String;
|
|
|
141
141
|
function pastDate(numberOfDays: number = 1): String;
|
|
142
142
|
|
|
143
143
|
// Utils: common
|
|
144
|
+
export function initCustomCommands(): Void;
|
|
145
|
+
|
|
144
146
|
export function dataCy(dataCyId: string): String;
|
|
145
147
|
|
|
146
148
|
export function getTestTitle(): String;
|
|
@@ -166,7 +168,7 @@ export function verifyListCount(countSelector: string, count: number): String;
|
|
|
166
168
|
|
|
167
169
|
// Utils: organization
|
|
168
170
|
export function createOrganization(props: {
|
|
169
|
-
|
|
171
|
+
appName: string;
|
|
170
172
|
businessName: string;
|
|
171
173
|
email: string;
|
|
172
174
|
firstName: string;
|
package/cypress-utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { commonTexts as commonTexts$1 } from 'constants/texts/common';
|
|
1
2
|
import dayjs from 'dayjs';
|
|
2
3
|
|
|
3
4
|
function _typeof(obj) {
|
|
@@ -163,7 +164,8 @@ var commonSelectors = {
|
|
|
163
164
|
toastMessage: dataCy("toastr-message-container"),
|
|
164
165
|
toastCloseButton: ".neeto-ui-toastr__close-button",
|
|
165
166
|
windowAlert: "#alert-box",
|
|
166
|
-
body: "body"
|
|
167
|
+
body: "body",
|
|
168
|
+
toastIcon: ".Toastify__toast-icon"
|
|
167
169
|
};
|
|
168
170
|
var tableSelectors = {
|
|
169
171
|
nthColumn: function nthColumn(n) {
|
|
@@ -182,125 +184,132 @@ var profileSelectors = {
|
|
|
182
184
|
|
|
183
185
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
184
186
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
Cypress.Commands.add("clearAndTypeFast", function (selector, text) {
|
|
189
|
-
cy.get(selector).clear().type(text, {
|
|
190
|
-
delay: 0
|
|
187
|
+
var initCustomCommands = function initCustomCommands() {
|
|
188
|
+
Cypress.Commands.add("clearAndType", function (selector, text) {
|
|
189
|
+
cy.get(selector).clear().type(text);
|
|
191
190
|
});
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
Cypress.Commands.add("clearAndTypeFast", function (selector, text) {
|
|
192
|
+
cy.get(selector).clear().type(text, {
|
|
193
|
+
delay: 0
|
|
194
|
+
});
|
|
196
195
|
});
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
Cypress.Commands.add("clearByClickAndTypeFast", function (selector, text) {
|
|
197
|
+
cy.get(selector).click().clear().type(text, {
|
|
198
|
+
delay: 0
|
|
199
|
+
});
|
|
201
200
|
});
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
|
|
201
|
+
Cypress.Commands.add("typeFast", function (selector, text) {
|
|
202
|
+
cy.get(selector).type(text, {
|
|
203
|
+
delay: 0
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
Cypress.Commands.add("typeAndEnter", function (selector, text) {
|
|
207
|
+
cy.get(selector).clear().type("".concat(text, "{enter}"));
|
|
208
|
+
});
|
|
209
|
+
Cypress.Commands.add("verifyToastMessage", function (message) {
|
|
210
|
+
cy.get(commonSelectors.toastMessage).should("be.visible").should("have.text", message);
|
|
208
211
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
});
|
|
213
|
-
Cypress.Commands.add("continueOnAlert", function (args) {
|
|
214
|
-
var props = _typeof(args) === "object" ? args : {
|
|
215
|
-
alias: args
|
|
216
|
-
};
|
|
217
|
-
var alias = props.alias,
|
|
218
|
-
title = props.title,
|
|
219
|
-
description = props.description,
|
|
220
|
-
_props$requestCount = props.requestCount,
|
|
221
|
-
requestCount = _props$requestCount === void 0 ? 1 : _props$requestCount,
|
|
222
|
-
toastMessage = props.toastMessage;
|
|
223
|
-
var hasMoreThanOneRequest = requestCount > 1;
|
|
224
|
-
title && cy.get(commonSelectors.alertTitle).should("have.text", title);
|
|
225
|
-
description && cy.get(commonSelectors.alertModalMessage).should("have.text", description);
|
|
226
|
-
cy.interceptApi(alias, requestCount);
|
|
227
|
-
cy.get(commonSelectors.alertModalSubmitButton).click();
|
|
228
|
-
cy.wait("@".concat(alias));
|
|
229
|
-
toastMessage && cy.verifyToastMessage(toastMessage);
|
|
230
|
-
hasMoreThanOneRequest && cy.waitForMultipleRequest("@".concat(alias), requestCount - 1);
|
|
231
|
-
});
|
|
232
|
-
Cypress.Commands.add("interceptApi", function (alias) {
|
|
233
|
-
var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
234
|
-
return cy.intercept({
|
|
235
|
-
url: requestApis.allPath,
|
|
236
|
-
times: times
|
|
237
|
-
}).as(alias);
|
|
238
|
-
});
|
|
239
|
-
Cypress.Commands.add("waitForMultipleRequest", function (alias) {
|
|
240
|
-
var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
241
|
-
return cy.wrap(_toConsumableArray(new Array(times))).each(function () {
|
|
242
|
-
return cy.wait(alias);
|
|
212
|
+
// close toast message
|
|
213
|
+
cy.get(commonSelectors.toastCloseButton).click();
|
|
214
|
+
cy.get(commonSelectors.toastMessage).should("not.exist");
|
|
243
215
|
});
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
headers: requestHeaders
|
|
249
|
-
})) : cy.log("No request headers found");
|
|
216
|
+
Cypress.Commands.add("verifyToastIcon", function () {
|
|
217
|
+
cy.get(commonSelectors.toastIcon).should("have.text", commonTexts$1.toastIcon);
|
|
218
|
+
cy.get(commonSelectors.toastCloseButton).click();
|
|
219
|
+
cy.get(commonSelectors.toastIcon).should("not.exist");
|
|
250
220
|
});
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
selector = _ref.selector;
|
|
282
|
-
cy.window().then(function (win) {
|
|
283
|
-
cy.stub(win, "open").as(alias).callsFake(function (newUrl) {
|
|
284
|
-
return win.location.href = newUrl;
|
|
221
|
+
Cypress.Commands.add("continueOnAlert", function (args) {
|
|
222
|
+
var props = _typeof(args) === "object" ? args : {
|
|
223
|
+
alias: args
|
|
224
|
+
};
|
|
225
|
+
var alias = props.alias,
|
|
226
|
+
title = props.title,
|
|
227
|
+
_props$requestCount = props.requestCount,
|
|
228
|
+
requestCount = _props$requestCount === void 0 ? 1 : _props$requestCount,
|
|
229
|
+
verifyToastIcon = props.verifyToastIcon,
|
|
230
|
+
toastMessage = props.toastMessage;
|
|
231
|
+
var hasMoreThanOneRequest = requestCount > 1;
|
|
232
|
+
title && cy.get(commonSelectors.alertTitle).should("have.text", title);
|
|
233
|
+
cy.interceptApi(alias, requestCount);
|
|
234
|
+
cy.get(commonSelectors.alertModalSubmitButton).click();
|
|
235
|
+
cy.wait("@".concat(alias));
|
|
236
|
+
verifyToastIcon && cy.verifyToastIcon();
|
|
237
|
+
toastMessage && cy.verifyToastMessage(toastMessage);
|
|
238
|
+
hasMoreThanOneRequest && cy.waitForMultipleRequest("@".concat(alias), requestCount - 1);
|
|
239
|
+
});
|
|
240
|
+
Cypress.Commands.add("interceptApi", function (alias) {
|
|
241
|
+
var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
242
|
+
return cy.intercept({
|
|
243
|
+
url: requestApis.allPath,
|
|
244
|
+
times: times
|
|
245
|
+
}).as(alias);
|
|
246
|
+
});
|
|
247
|
+
Cypress.Commands.add("waitForMultipleRequest", function (alias) {
|
|
248
|
+
var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
249
|
+
return cy.wrap(_toConsumableArray(new Array(times))).each(function () {
|
|
250
|
+
return cy.wait(alias);
|
|
285
251
|
});
|
|
286
252
|
});
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
});
|
|
294
|
-
Cypress.Commands.add("ifExist", function (selector, callback) {
|
|
295
|
-
cy.get(commonSelectors.body).then(function ($body) {
|
|
296
|
-
if ($body.find(selector).length) callback();
|
|
253
|
+
Cypress.Commands.add("apiRequest", function (options) {
|
|
254
|
+
return cy.get("@requestHeaders").then(function (requestHeaders) {
|
|
255
|
+
return requestHeaders ? cy.request(_objectSpread(_objectSpread({}, options), {}, {
|
|
256
|
+
headers: requestHeaders
|
|
257
|
+
})) : cy.log("No request headers found");
|
|
258
|
+
});
|
|
297
259
|
});
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
260
|
+
Cypress.Commands.add("reloadAndWait", function () {
|
|
261
|
+
var requestCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
262
|
+
if (requestCount > 0) {
|
|
263
|
+
cy.interceptApi("reloadAllRequests", requestCount);
|
|
264
|
+
cy.reload();
|
|
265
|
+
cy.waitForMultipleRequest("@reloadAllRequests", requestCount);
|
|
266
|
+
}
|
|
302
267
|
});
|
|
303
|
-
|
|
268
|
+
Cypress.Commands.add("selectOption", function (containerSelector, optionText) {
|
|
269
|
+
cy.get(containerSelector).click().type(optionText);
|
|
270
|
+
cy.contains(commonSelectors.selectOption, optionText).invoke("click");
|
|
271
|
+
});
|
|
272
|
+
Cypress.Commands.add("clickDropdownOption", function (optionText) {
|
|
273
|
+
var dropdownSelector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : commonSelectors.dropdownIcon;
|
|
274
|
+
cy.get(dropdownSelector).click();
|
|
275
|
+
cy.get(commonSelectors.dropdownContainer).contains(optionText).invoke("click");
|
|
276
|
+
});
|
|
277
|
+
Cypress.Commands.add("getText", function (selector) {
|
|
278
|
+
return cy.get(selector).invoke("text");
|
|
279
|
+
});
|
|
280
|
+
Cypress.Commands.add("getValue", function (selector) {
|
|
281
|
+
return cy.get(selector).invoke("val");
|
|
282
|
+
});
|
|
283
|
+
Cypress.Commands.add("getIframe", function (iframeSelector) {
|
|
284
|
+
return cy.get(iframeSelector).its("0.contentDocument.body").should("not.be.empty");
|
|
285
|
+
});
|
|
286
|
+
Cypress.Commands.add("openInSameTabOnClick", function (_ref) {
|
|
287
|
+
var url = _ref.url,
|
|
288
|
+
alias = _ref.alias,
|
|
289
|
+
selector = _ref.selector;
|
|
290
|
+
cy.window().then(function (win) {
|
|
291
|
+
cy.stub(win, "open").as(alias).callsFake(function (newUrl) {
|
|
292
|
+
return win.location.href = newUrl;
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
cy.get(selector).click();
|
|
296
|
+
cy.get("@".concat(alias)).should("be.called");
|
|
297
|
+
cy.url().should("include", url);
|
|
298
|
+
});
|
|
299
|
+
Cypress.Commands.add("globalState", function (key) {
|
|
300
|
+
return cy.task("getGlobalState", key);
|
|
301
|
+
});
|
|
302
|
+
Cypress.Commands.add("ifExist", function (selector, callback) {
|
|
303
|
+
cy.get(commonSelectors.body).then(function ($body) {
|
|
304
|
+
if ($body.find(selector).length) callback();
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
Cypress.Commands.add("ifNotExist", function (selector, callback) {
|
|
308
|
+
cy.get(commonSelectors.body).then(function ($body) {
|
|
309
|
+
if (!$body.find(selector).length) callback();
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
};
|
|
304
313
|
|
|
305
314
|
var loginSelectors = {
|
|
306
315
|
appleAuthenticationButton: dataCy("apple-authentication-button"),
|
|
@@ -364,7 +373,8 @@ var commonTexts = {
|
|
|
364
373
|
logout: "Log out",
|
|
365
374
|
"new": "New",
|
|
366
375
|
takeAction: "Take action",
|
|
367
|
-
unblock: "Unblock"
|
|
376
|
+
unblock: "Unblock",
|
|
377
|
+
toastIcon: "👍"
|
|
368
378
|
};
|
|
369
379
|
|
|
370
380
|
var memberTexts = {
|
|
@@ -687,7 +697,7 @@ var memberUtils = {
|
|
|
687
697
|
verifyMemberDetails: verifyMemberDetails
|
|
688
698
|
};
|
|
689
699
|
|
|
690
|
-
var updateSubdmainIfExit = function updateSubdmainIfExit(subdomainName) {
|
|
700
|
+
var updateSubdmainIfExit = function updateSubdmainIfExit(appName, subdomainName) {
|
|
691
701
|
cy.ifExist(signUpSelectors.subdomainError, function () {
|
|
692
702
|
var lastDigit = Number(subdomainName.charAt(subdomainName.length - 1));
|
|
693
703
|
var newOrganizationName = subdomainName.slice(0, -1) + (lastDigit + 1);
|
|
@@ -706,9 +716,7 @@ var updateSubdmainIfExit = function updateSubdmainIfExit(subdomainName) {
|
|
|
706
716
|
key: "businessName",
|
|
707
717
|
value: newOrganizationName
|
|
708
718
|
});
|
|
709
|
-
var
|
|
710
|
-
var domain = baseUrl.split(".")[1];
|
|
711
|
-
var newBaseUrl = "https://".concat(newOrganizationName, ".").concat(domain, ".net");
|
|
719
|
+
var newBaseUrl = "https://".concat(newOrganizationName, ".").concat(appName, ".net");
|
|
712
720
|
Cypress.config("baseUrl", newBaseUrl);
|
|
713
721
|
cy.clearAndType(signUpSelectors.organizationNameTextField, newOrganizationName);
|
|
714
722
|
});
|
|
@@ -723,10 +731,15 @@ var createOrganization = function createOrganization(_ref) {
|
|
|
723
731
|
subdomainName = _ref.subdomainName,
|
|
724
732
|
firstName = _ref.firstName,
|
|
725
733
|
lastName = _ref.lastName,
|
|
726
|
-
|
|
734
|
+
appName = _ref.appName;
|
|
727
735
|
var otp = "123456";
|
|
728
|
-
|
|
729
|
-
|
|
736
|
+
var appNameInLowerCase = appName.toLowerCase();
|
|
737
|
+
var isNeetoAuth = appNameInLowerCase === "neetoauth";
|
|
738
|
+
if (isNeetoAuth) cy.visit("https://app.neetoauth.net/signups/new");else {
|
|
739
|
+
var startingUrl = "https://www.neeto.com/".concat(appNameInLowerCase, "?env=staging");
|
|
740
|
+
cy.visit(startingUrl);
|
|
741
|
+
cy.get(signUpSelectors.tryFreeButton).invoke("removeAttr", "target").click();
|
|
742
|
+
}
|
|
730
743
|
cy.get(signUpSelectors.signupViaEmailButton).should("contain.text", signUpTexts.email).click();
|
|
731
744
|
cy.clearAndType(signUpSelectors.emailTextField, email);
|
|
732
745
|
cy.intercept({
|
|
@@ -744,7 +757,7 @@ var createOrganization = function createOrganization(_ref) {
|
|
|
744
757
|
cy.clearAndType(signUpSelectors.organizationNameTextField, businessName);
|
|
745
758
|
cy.clearAndType(signUpSelectors.subdomainNameTextField, subdomainName);
|
|
746
759
|
cy.wait("@subdomainRequest");
|
|
747
|
-
updateSubdmainIfExit(subdomainName);
|
|
760
|
+
updateSubdmainIfExit(appNameInLowerCase, subdomainName);
|
|
748
761
|
cy.intercept({
|
|
749
762
|
url: requestApis.signUp,
|
|
750
763
|
times: 1
|
|
@@ -777,4 +790,4 @@ var verifyCrossSiteScript = function verifyCrossSiteScript(inputSelector, submit
|
|
|
777
790
|
cy.get(commonSelectors.windowAlert).should("not.exist");
|
|
778
791
|
};
|
|
779
792
|
|
|
780
|
-
export { authUtils, commonSelectors, commonTexts, createOrganization, dataCy, dateUtils, environment, getTestTitle, getUrl, initializeCredentials, isStagingEnv, joinHyphenCase, loginSelectors, memberFormSelectors, memberSelectors, memberTableTexts, memberTexts, memberUtils, profileSelectors, setListCount, signUpSelectors, signUpTexts, tableSelectors, verifyCrossSiteScript, verifyListCount };
|
|
793
|
+
export { authUtils, commonSelectors, commonTexts, createOrganization, dataCy, dateUtils, environment, getTestTitle, getUrl, initCustomCommands, initializeCredentials, isStagingEnv, joinHyphenCase, loginSelectors, memberFormSelectors, memberSelectors, memberTableTexts, memberTexts, memberUtils, profileSelectors, setListCount, signUpSelectors, signUpTexts, tableSelectors, verifyCrossSiteScript, verifyListCount };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-commons-frontend",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.44",
|
|
4
4
|
"description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
|
|
6
6
|
"author": "Amaljith K <amaljith.k@bigbinary.com>",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"@babel/preset-env": "^7.17.10",
|
|
57
57
|
"@babel/preset-react": "^7.16.7",
|
|
58
58
|
"@bigbinary/neeto-commons-frontend": "latest",
|
|
59
|
-
"@bigbinary/neeto-editor": "1.23.
|
|
60
|
-
"@bigbinary/neeto-icons": "^1.9.
|
|
61
|
-
"@bigbinary/neetoui": "4.
|
|
59
|
+
"@bigbinary/neeto-editor": "1.23.3",
|
|
60
|
+
"@bigbinary/neeto-icons": "^1.9.15",
|
|
61
|
+
"@bigbinary/neetoui": "4.4.3",
|
|
62
62
|
"@honeybadger-io/react": "2.0.1",
|
|
63
63
|
"@rollup/plugin-alias": "^3.1.9",
|
|
64
64
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -136,8 +136,8 @@
|
|
|
136
136
|
"dependencies": {},
|
|
137
137
|
"peerDependencies": {
|
|
138
138
|
"@bigbinary/neeto-commons-frontend": "latest",
|
|
139
|
-
"@bigbinary/neeto-icons": "^1.9.
|
|
140
|
-
"@bigbinary/neetoui": "^4.
|
|
139
|
+
"@bigbinary/neeto-icons": "^1.9.15",
|
|
140
|
+
"@bigbinary/neetoui": "^4.4.3",
|
|
141
141
|
"@honeybadger-io/react": "2.0.1",
|
|
142
142
|
"@svgr/webpack": "^6.5.1",
|
|
143
143
|
"antd": "4.18.7",
|
package/react-utils.cjs.js
CHANGED
|
@@ -126638,14 +126638,29 @@ var ErrorPage = function ErrorPage(_ref) {
|
|
|
126638
126638
|
var _ref$homeUrl = _ref.homeUrl,
|
|
126639
126639
|
homeUrl = _ref$homeUrl === void 0 ? "/" : _ref$homeUrl,
|
|
126640
126640
|
status = _ref.status;
|
|
126641
|
-
var storeStatusCode = reactUtils.useErrorDisplayStore(ramda.prop("statusCode"));
|
|
126642
|
-
status = status || storeStatusCode;
|
|
126643
126641
|
var _useTranslation = reactI18next.useTranslation(),
|
|
126644
126642
|
t = _useTranslation.t;
|
|
126643
|
+
var _useErrorDisplayStore = reactUtils.useErrorDisplayStore(ramda.pick(["statusCode", "showErrorPage"]), shallow),
|
|
126644
|
+
storeStatusCode = _useErrorDisplayStore.statusCode,
|
|
126645
|
+
showErrorPage = _useErrorDisplayStore.showErrorPage;
|
|
126646
|
+
status = status || storeStatusCode;
|
|
126645
126647
|
var _ref2 = ERRORS[status] || ERRORS[404],
|
|
126646
126648
|
Image = _ref2.Image,
|
|
126647
126649
|
errorKey = _ref2.errorKey,
|
|
126648
126650
|
titleKey = _ref2.titleKey;
|
|
126651
|
+
React.useEffect(function () {
|
|
126652
|
+
var onBackButtonPress = function onBackButtonPress() {
|
|
126653
|
+
if (showErrorPage) {
|
|
126654
|
+
reactUtils.useErrorDisplayStore.setState({
|
|
126655
|
+
showErrorPage: false
|
|
126656
|
+
});
|
|
126657
|
+
}
|
|
126658
|
+
};
|
|
126659
|
+
window.addEventListener("popstate", onBackButtonPress);
|
|
126660
|
+
return function () {
|
|
126661
|
+
window.removeEventListener("popstate", onBackButtonPress);
|
|
126662
|
+
};
|
|
126663
|
+
}, []);
|
|
126649
126664
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
126650
126665
|
className: "flex min-h-screen w-full flex-col items-center justify-center",
|
|
126651
126666
|
"data-cy": "error-page-container"
|
package/react-utils.js
CHANGED
|
@@ -126600,14 +126600,29 @@ var ErrorPage = function ErrorPage(_ref) {
|
|
|
126600
126600
|
var _ref$homeUrl = _ref.homeUrl,
|
|
126601
126601
|
homeUrl = _ref$homeUrl === void 0 ? "/" : _ref$homeUrl,
|
|
126602
126602
|
status = _ref.status;
|
|
126603
|
-
var storeStatusCode = useErrorDisplayStore$1(prop$1("statusCode"));
|
|
126604
|
-
status = status || storeStatusCode;
|
|
126605
126603
|
var _useTranslation = useTranslation(),
|
|
126606
126604
|
t = _useTranslation.t;
|
|
126605
|
+
var _useErrorDisplayStore = useErrorDisplayStore$1(pick(["statusCode", "showErrorPage"]), shallow),
|
|
126606
|
+
storeStatusCode = _useErrorDisplayStore.statusCode,
|
|
126607
|
+
showErrorPage = _useErrorDisplayStore.showErrorPage;
|
|
126608
|
+
status = status || storeStatusCode;
|
|
126607
126609
|
var _ref2 = ERRORS[status] || ERRORS[404],
|
|
126608
126610
|
Image = _ref2.Image,
|
|
126609
126611
|
errorKey = _ref2.errorKey,
|
|
126610
126612
|
titleKey = _ref2.titleKey;
|
|
126613
|
+
useEffect(function () {
|
|
126614
|
+
var onBackButtonPress = function onBackButtonPress() {
|
|
126615
|
+
if (showErrorPage) {
|
|
126616
|
+
useErrorDisplayStore$1.setState({
|
|
126617
|
+
showErrorPage: false
|
|
126618
|
+
});
|
|
126619
|
+
}
|
|
126620
|
+
};
|
|
126621
|
+
window.addEventListener("popstate", onBackButtonPress);
|
|
126622
|
+
return function () {
|
|
126623
|
+
window.removeEventListener("popstate", onBackButtonPress);
|
|
126624
|
+
};
|
|
126625
|
+
}, []);
|
|
126611
126626
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
126612
126627
|
className: "flex min-h-screen w-full flex-col items-center justify-center",
|
|
126613
126628
|
"data-cy": "error-page-container"
|