@bigbinary/neeto-commons-frontend 2.1.10 → 2.1.12

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.
@@ -6,9 +6,9 @@ const defineCypressConfig = (overrides = {}) => {
6
6
  return defineConfig({
7
7
  execTimeout: 1800000,
8
8
  defaultCommandTimeout: 8000,
9
- requestTimeout: 5000,
9
+ requestTimeout: 15000,
10
10
  pageLoadTimeout: 30000,
11
- responseTimeout: 30000,
11
+ responseTimeout: 45000,
12
12
  viewportWidth: 1440,
13
13
  viewportHeight: 960,
14
14
  chromeWebSecurity: false,
@@ -1396,6 +1396,161 @@ var verifyCrossSiteScript = function verifyCrossSiteScript(inputSelector, submit
1396
1396
  cy.get(commonSelectors.windowAlert).should("not.exist");
1397
1397
  };
1398
1398
 
1399
+ var hostname = "api.fastmail.com";
1400
+ var username = Cypress.env("CYPRESS_FASTMAIL_USERNAME") || "cypress@mixarrow.com";
1401
+ var token = Cypress.env("CYPRESS_FASTMAIL_TOKEN");
1402
+ var authUrl = "https://".concat(hostname, "/.well-known/jmap");
1403
+ var headers = {
1404
+ "Content-Type": "application/json",
1405
+ Authorization: "Bearer ".concat(token)
1406
+ };
1407
+ var getSession = function getSession() {
1408
+ return cy.request({
1409
+ url: authUrl,
1410
+ method: "GET",
1411
+ headers: headers
1412
+ });
1413
+ };
1414
+ var getDraftId = function getDraftId(_ref) {
1415
+ var apiUrl = _ref.apiUrl,
1416
+ accountId = _ref.accountId;
1417
+ cy.request({
1418
+ url: apiUrl,
1419
+ method: "POST",
1420
+ headers: headers,
1421
+ body: JSON.stringify({
1422
+ using: ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
1423
+ methodCalls: [["Mailbox/query", {
1424
+ accountId: accountId,
1425
+ filter: {
1426
+ name: "Drafts"
1427
+ }
1428
+ }, "a"]]
1429
+ })
1430
+ }).then(function (_ref2) {
1431
+ var data = _ref2.body;
1432
+ return cy.wrap(data["methodResponses"][0][1].ids[0]).as("draftId");
1433
+ });
1434
+ };
1435
+ var getIdentityId = function getIdentityId(_ref3) {
1436
+ var apiUrl = _ref3.apiUrl,
1437
+ accountId = _ref3.accountId;
1438
+ cy.request({
1439
+ url: apiUrl,
1440
+ method: "POST",
1441
+ headers: headers,
1442
+ body: JSON.stringify({
1443
+ using: ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail", "urn:ietf:params:jmap:submission"],
1444
+ methodCalls: [["Identity/get", {
1445
+ accountId: accountId,
1446
+ ids: null
1447
+ }, "a"]]
1448
+ })
1449
+ }).then(function (_ref4) {
1450
+ var data = _ref4.body;
1451
+ var identities = data["methodResponses"][0][1].list;
1452
+ var identityId = identities.find(function (_ref5) {
1453
+ var email = _ref5.email;
1454
+ return email === username;
1455
+ }).id;
1456
+ cy.wrap(identityId).as("identityId");
1457
+ });
1458
+ };
1459
+ var composeEmail = function composeEmail(_ref6) {
1460
+ var apiUrl = _ref6.apiUrl,
1461
+ accountId = _ref6.accountId,
1462
+ draftId = _ref6.draftId,
1463
+ identityId = _ref6.identityId,
1464
+ emailDetails = _ref6.emailDetails;
1465
+ var subject = emailDetails.subject,
1466
+ body = emailDetails.body,
1467
+ to = emailDetails.to,
1468
+ senderName = emailDetails.senderName;
1469
+ var draftObject = {
1470
+ from: [{
1471
+ email: username,
1472
+ name: senderName
1473
+ }],
1474
+ to: [{
1475
+ email: to
1476
+ }],
1477
+ subject: subject,
1478
+ keywords: {
1479
+ $draft: true
1480
+ },
1481
+ mailboxIds: _defineProperty({}, draftId, true),
1482
+ bodyValues: {
1483
+ body: {
1484
+ value: body,
1485
+ charset: "utf-8"
1486
+ }
1487
+ },
1488
+ textBody: [{
1489
+ partId: "body",
1490
+ type: "text/plain"
1491
+ }]
1492
+ };
1493
+ cy.request({
1494
+ url: apiUrl,
1495
+ method: "POST",
1496
+ headers: headers,
1497
+ body: JSON.stringify({
1498
+ using: ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail", "urn:ietf:params:jmap:submission"],
1499
+ methodCalls: [["Email/set", {
1500
+ accountId: accountId,
1501
+ create: {
1502
+ draft: draftObject
1503
+ }
1504
+ }, "a"], ["EmailSubmission/set", {
1505
+ accountId: accountId,
1506
+ onSuccessDestroyEmail: ["#sendIt"],
1507
+ create: {
1508
+ sendIt: {
1509
+ emailId: "#draft",
1510
+ identityId: identityId
1511
+ }
1512
+ }
1513
+ }, "b"]]
1514
+ })
1515
+ });
1516
+ };
1517
+ var checkForEnvs = function checkForEnvs() {
1518
+ if (!username || !token) {
1519
+ throw new Error("Please provide CYPRESS_FASTMAIL_USERNAME and CYPRESS_FASTMAIL_TOKEN as environment variables");
1520
+ }
1521
+ };
1522
+ var sendEmail = function sendEmail(emailDetails) {
1523
+ checkForEnvs();
1524
+ getSession().then(function (_ref7) {
1525
+ var session = _ref7.body;
1526
+ var apiUrl = session.apiUrl,
1527
+ primaryAccounts = session.primaryAccounts;
1528
+ var accountId = primaryAccounts["urn:ietf:params:jmap:mail"];
1529
+ getDraftId({
1530
+ apiUrl: apiUrl,
1531
+ accountId: accountId
1532
+ });
1533
+ getIdentityId({
1534
+ apiUrl: apiUrl,
1535
+ accountId: accountId
1536
+ });
1537
+ cy.get("@draftId").then(function (draftId) {
1538
+ cy.get("@identityId").then(function (identityId) {
1539
+ return composeEmail({
1540
+ apiUrl: apiUrl,
1541
+ accountId: accountId,
1542
+ draftId: draftId,
1543
+ identityId: identityId,
1544
+ emailDetails: emailDetails
1545
+ });
1546
+ });
1547
+ });
1548
+ });
1549
+ };
1550
+ var emailUtils = {
1551
+ sendEmail: sendEmail
1552
+ };
1553
+
1399
1554
  exports.authUtils = authUtils;
1400
1555
  exports.chatWidgetSelectors = chatWidgetSelectors;
1401
1556
  exports.commonSelectors = commonSelectors;
@@ -1404,6 +1559,7 @@ exports.createOrganization = createOrganization;
1404
1559
  exports.dataCy = dataCy;
1405
1560
  exports.dataTestId = dataTestId;
1406
1561
  exports.dateUtils = dateUtils;
1562
+ exports.emailUtils = emailUtils;
1407
1563
  exports.env = env;
1408
1564
  exports.environment = environment;
1409
1565
  exports.getTestTitle = getTestTitle;
@@ -1424,6 +1580,7 @@ exports.memberUtils = memberUtils;
1424
1580
  exports.navigationUtils = navigationUtils;
1425
1581
  exports.profileSelectors = profileSelectors;
1426
1582
  exports.profileTexts = profileTexts;
1583
+ exports.sendEmail = sendEmail;
1427
1584
  exports.setListCount = setListCount;
1428
1585
  exports.signUpSelectors = signUpSelectors;
1429
1586
  exports.signUpTexts = signUpTexts;