@bigbinary/neeto-playwright-commons 1.3.2 → 1.4.0

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/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as _playwright_test from '@playwright/test';
2
2
  import { Page, APIRequestContext, Response, APIResponse, Fixtures, PlaywrightWorkerArgs, PlaywrightWorkerOptions, PlaywrightTestArgs, PlaywrightTestOptions } from '@playwright/test';
3
- import * as playwright_test from 'playwright/test';
4
- import * as playwright_i18next_fixture from 'playwright-i18next-fixture';
3
+ import { I18nPlaywrightFixture } from 'playwright-i18next-fixture';
5
4
 
6
5
  interface InterceptMultipleResponsesParams {
7
6
  responseUrl: string;
@@ -68,7 +67,7 @@ declare const generateStagingData: (product?: string) => {
68
67
  email: string;
69
68
  };
70
69
 
71
- declare const i18nFixture: playwright_test.Fixtures<playwright_i18next_fixture.I18nPlaywrightFixture, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions, playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
70
+ declare const i18nFixture: Fixtures<I18nPlaywrightFixture, PlaywrightWorkerArgs & PlaywrightWorkerOptions, PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
72
71
 
73
72
  interface CreateOrganizationProps {
74
73
  email: string;
@@ -349,14 +348,13 @@ declare const readFileSyncIfExists: ReadFileSyncIfExists;
349
348
  declare const writeDataToFile: WriteDataToFile;
350
349
  declare const updateCredentials: UpdateCredentials;
351
350
  declare const clearCredentials: ClearCredentials;
352
- declare const readTranslations: () => Record<string, unknown>;
353
351
  declare const hyphenize: Hyphenize;
354
352
  declare const joinHyphenCase: JoinHyphenCase;
355
353
 
356
354
  interface LoginProps {
357
355
  page: Page;
358
356
  neetoPlaywrightUtilities: CustomCommands;
359
- loginPath: string;
357
+ loginPath?: string;
360
358
  }
361
359
  declare const loginWithoutSSO: ({ page, neetoPlaywrightUtilities, loginPath, }: LoginProps) => Promise<void>;
362
360
  declare const login: ({ page, neetoPlaywrightUtilities, loginPath, }: LoginProps) => Promise<false | void>;
@@ -372,4 +370,4 @@ interface Overrides {
372
370
  }
373
371
  declare const definePlaywrightConfig: (overrides: Overrides) => _playwright_test.PlaywrightTestConfig<{}, {}>;
374
372
 
375
- export { BASE_URL, CHAT_WIDGET_SELECTORS, COMMON_SELECTORS, CREDENTIALS, CustomCommands, type CustomFixture, ENVIRONMENT, GLOBAL_TRANSLATIONS_PATTERN, HELP_CENTER_SELECTORS, IS_STAGING_ENV, LOGIN_SELECTORS, MEMBER_FORM_SELECTORS, MEMBER_SELECTORS, MERGE_TAGS_SELECTORS, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, OrganizationPage, PROJECT_TRANSLATIONS_PATH, ROLES_SELECTORS, ROUTES, SIGNUP_SELECTORS, STORAGE_STATE, TAGS_SELECTORS, clearCredentials, commands, definePlaywrightConfig, generateStagingData, hyphenize, i18nFixture, initializeCredentials, joinHyphenCase, joinString, login, loginWithoutSSO, readFileSyncIfExists, readTranslations, updateCredentials, writeDataToFile };
373
+ export { BASE_URL, CHAT_WIDGET_SELECTORS, COMMON_SELECTORS, CREDENTIALS, CustomCommands, type CustomFixture, ENVIRONMENT, GLOBAL_TRANSLATIONS_PATTERN, HELP_CENTER_SELECTORS, IS_STAGING_ENV, LOGIN_SELECTORS, MEMBER_FORM_SELECTORS, MEMBER_SELECTORS, MERGE_TAGS_SELECTORS, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, OrganizationPage, PROJECT_TRANSLATIONS_PATH, ROLES_SELECTORS, ROUTES, SIGNUP_SELECTORS, STORAGE_STATE, TAGS_SELECTORS, clearCredentials, commands, definePlaywrightConfig, generateStagingData, hyphenize, i18nFixture, initializeCredentials, joinHyphenCase, joinString, login, loginWithoutSSO, readFileSyncIfExists, updateCredentials, writeDataToFile };
package/index.js CHANGED
@@ -1,16 +1,249 @@
1
1
  import { expect, defineConfig, devices } from '@playwright/test';
2
2
  import * as require$$0 from 'fs';
3
3
  import require$$0__default from 'fs';
4
+ import dayjs from 'dayjs';
5
+ import { getI18nInstance, initI18n } from 'playwright-i18next-fixture';
4
6
  import require$$2 from 'os';
5
7
  import require$$0$1 from 'path';
6
8
  import require$$0$2 from 'util';
7
9
  import require$$0$3 from 'stream';
8
10
  import require$$0$4 from 'events';
9
11
  import { mergeDeepLeft, mergeAll } from 'ramda';
10
- import dayjs from 'dayjs';
11
- import { createI18nFixture } from 'playwright-i18next-fixture';
12
12
  import require$$3 from 'crypto';
13
13
 
14
+ const ENVIRONMENT = {
15
+ development: "development",
16
+ staging: "staging",
17
+ review: "review",
18
+ };
19
+ const IS_STAGING_ENV = process.env.TEST_ENV === "staging";
20
+ const STORAGE_STATE = "./e2e/auth/user.json";
21
+ const GLOBAL_TRANSLATIONS_PATTERN = "../node_modules/@bigbinary/**/translations/en.json";
22
+ const PROJECT_TRANSLATIONS_PATH = "../app/javascript/src/translations/en.json";
23
+ const CREDENTIALS = {
24
+ name: "Oliver Smith",
25
+ email: "oliver@example.com",
26
+ password: "welcome",
27
+ };
28
+
29
+ const joinString = (string1, string2, string3 = "", separator = " ") => {
30
+ if (string3 === "") {
31
+ return string1 + separator + string2;
32
+ }
33
+ return string1 + separator + string2 + separator + string3;
34
+ };
35
+ const readFileSyncIfExists = (path = STORAGE_STATE) => {
36
+ try {
37
+ return JSON.parse(require$$0.readFileSync(path, "utf8"));
38
+ }
39
+ catch (error) {
40
+ return {};
41
+ }
42
+ };
43
+ const writeDataToFile = data => {
44
+ try {
45
+ require$$0.writeFileSync(STORAGE_STATE, data, "utf8");
46
+ }
47
+ catch (error) {
48
+ console.log(error); // eslint-disable-line
49
+ }
50
+ return true;
51
+ };
52
+ const updateCredentials = ({ key, value }) => {
53
+ const data = readFileSyncIfExists();
54
+ data["user"][key] = value;
55
+ return writeDataToFile(JSON.stringify(data));
56
+ };
57
+ const clearCredentials = () => {
58
+ require$$0.unlink(STORAGE_STATE, error => {
59
+ if (!error)
60
+ return;
61
+ console.log(error); // eslint-disable-line
62
+ });
63
+ };
64
+ const hyphenize = input => {
65
+ const fallbackString = "";
66
+ if (typeof input === "number")
67
+ return String(input);
68
+ if (input && typeof input === "string" && input.replace) {
69
+ return input
70
+ .replace(/[\s_]/g, "-")
71
+ .replace(/([a-z])([A-Z])/g, "$1-$2")
72
+ .replace(/-+/g, "-")
73
+ .toLowerCase();
74
+ }
75
+ return fallbackString;
76
+ };
77
+ const joinHyphenCase = (...args) => args.join(" ").replace(/\s+/g, "-").toLowerCase();
78
+
79
+ const COMMON_SELECTORS = {
80
+ spinner: ".neeto-ui-spinner",
81
+ subheaderText: "subheader-left",
82
+ alertTitle: "alert-title",
83
+ alertModalMessage: "alert-message",
84
+ alertModalSubmitButton: "alert-submit-button",
85
+ checkbox: "nui-checkbox-input",
86
+ checkboxLabel: "nui-checkbox-label",
87
+ dropdownContainer: "nui-dropdown-container",
88
+ dropdownIcon: "nui-dropdown-icon",
89
+ heading: "main-header",
90
+ paneBody: "pane-body",
91
+ paneHeader: "pane-header",
92
+ profileSidebar: "profile-section",
93
+ selectOption: (label) => `${hyphenize(label)}-select-option`,
94
+ toastMessage: "toastr-message-container",
95
+ toastCloseButton: "toastr-close-button",
96
+ windowAlert: "#alert-box",
97
+ body: "body",
98
+ toastIcon: ".Toastify__toast-icon",
99
+ paneModalCrossIcon: "pane-close-button",
100
+ inputField: "nui-input-field",
101
+ alertConfirmationText: "alert-confirmation-text",
102
+ alertCancelButton: "alert-cancel-button",
103
+ alertModalCrossIcon: "modal-close-button",
104
+ saveChangesButton: "save-changes-button",
105
+ cancelButton: "cancel-button",
106
+ inputFieldError: "nui-input-error",
107
+ selectDropDownError: "nui-select-error",
108
+ subTitleHeading: "menubar-subtitle-heading",
109
+ noDataTitle: "no-data-title",
110
+ noDataDescription: "no-data-description",
111
+ backdrop: "neeto-backdrop",
112
+ menuBarHeading: "menubar-heading",
113
+ dropdownWrapper: "nui-select-container-wrapper",
114
+ toggleButton: "menubar-toggle-button",
115
+ tooltip: "tooltip-box",
116
+ articlePageTitle: ".serene-article__title",
117
+ tabItem: "tab-item",
118
+ labelInputError: "label-input-error",
119
+ urlInputError: "url-input-error",
120
+ noDataPrimaryButton: "no-data-primary-button",
121
+ modalHeader: "modal-header",
122
+ nameInputError: "name-input-error",
123
+ selectContainer: "nui-select-container",
124
+ dropdownMenu: "nui-select-menu",
125
+ sidebarToggle: "neeto-molecules-sidebar-toggler",
126
+ subheader: "subheader",
127
+ settingsLink: "Settings",
128
+ ticketFieldTextInput: (label) => `${hyphenize(label)}-text-input`,
129
+ };
130
+
131
+ class CustomCommands {
132
+ constructor(page, request) {
133
+ this.interceptMultipleResponses = ({ responseUrl = "", times = 1, baseUrl, }) => Promise.all([...new Array(times)].map(() => this.page.waitForResponse((response) => {
134
+ var _a, _b, _c;
135
+ if (response.request().resourceType() === "xhr" &&
136
+ response.status() === 200 &&
137
+ response.url().includes(responseUrl) &&
138
+ response
139
+ .url()
140
+ .startsWith((_a = baseUrl !== null && baseUrl !== void 0 ? baseUrl : process.env.BASE_URL) !== null && _a !== void 0 ? _a : "") &&
141
+ !this.responses.includes((_b = response.headers()) === null || _b === void 0 ? void 0 : _b["x-request-id"])) {
142
+ this.responses.push((_c = response.headers()) === null || _c === void 0 ? void 0 : _c["x-request-id"]);
143
+ return true;
144
+ }
145
+ return false;
146
+ }, { timeout: 10000 })));
147
+ this.recursiveMethod = async (callback, condition, timeout, startTime) => {
148
+ if (Date.now() - timeout >= startTime) {
149
+ return false;
150
+ }
151
+ else if (await condition()) {
152
+ return await callback();
153
+ }
154
+ return await this.recursiveMethod(callback, condition, timeout, startTime);
155
+ };
156
+ this.executeRecursively = async ({ callback, condition, timeout = 5000, }) => {
157
+ const startTime = Date.now();
158
+ await this.recursiveMethod(callback, condition, timeout, startTime);
159
+ };
160
+ this.verifySuccessToast = async ({ message, closeAfterVerification = true, }) => {
161
+ if (message) {
162
+ await expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toHaveValue(message);
163
+ }
164
+ else {
165
+ await expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toHaveValue("👍");
166
+ closeAfterVerification &&
167
+ (await this.page
168
+ .getByTestId(COMMON_SELECTORS.toastCloseButton)
169
+ .click());
170
+ }
171
+ };
172
+ this.reloadAndWait = async (requestCount) => {
173
+ const reloadRequests = this.interceptMultipleResponses({
174
+ times: requestCount,
175
+ });
176
+ await this.page.reload();
177
+ await reloadRequests;
178
+ };
179
+ this.apiRequest = async ({ url, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
180
+ const csrfToken = await this.page
181
+ .locator("[name='csrf-token']")
182
+ .getAttribute("content");
183
+ const requestOptions = {
184
+ headers: {
185
+ ...additionalHeaders,
186
+ "accept-encoding": "gzip",
187
+ "x-csrf-token": csrfToken !== null && csrfToken !== void 0 ? csrfToken : "",
188
+ },
189
+ data,
190
+ params,
191
+ ...otherOptions,
192
+ };
193
+ const httpMethodsHandlers = {
194
+ get: () => this.request.get(url, requestOptions),
195
+ post: () => this.request.post(url, requestOptions),
196
+ put: () => this.request.put(url, requestOptions),
197
+ delete: () => this.request.delete(url, requestOptions),
198
+ };
199
+ return await httpMethodsHandlers[method]();
200
+ };
201
+ this.verifyFieldValue = values => {
202
+ const verifyEachFieldValue = ({ field, value, }) => expect(this.page.getByTestId(field)).toHaveValue(value);
203
+ return Array.isArray(values)
204
+ ? Promise.all(values.map(value => verifyEachFieldValue(value)))
205
+ : verifyEachFieldValue(values);
206
+ };
207
+ this.page = page;
208
+ this.responses = [];
209
+ this.request = request;
210
+ }
211
+ }
212
+
213
+ const commands = {
214
+ neetoPlaywrightUtilities: async ({ page, request }, use) => {
215
+ const commands = new CustomCommands(page, request);
216
+ await use(commands);
217
+ },
218
+ page: async ({ page }, use) => {
219
+ await page.goto("/");
220
+ await page.waitForLoadState();
221
+ await use(page);
222
+ },
223
+ };
224
+
225
+ const generateStagingData = (product = "invoice") => {
226
+ const timestamp = dayjs().format("YYYYMMDDHH");
227
+ const firstName = "André";
228
+ const lastName = "O'Reilly";
229
+ const otpBypassKey = process.env.OTP_BYPASS_KEY;
230
+ const stagingOrganization = `cypresstest-${product}-${timestamp}`;
231
+ return {
232
+ firstName,
233
+ lastName,
234
+ otp: 111111,
235
+ domain: `neeto${product}.net`,
236
+ currentUserName: IS_STAGING_ENV
237
+ ? joinString(firstName, lastName)
238
+ : CREDENTIALS.name,
239
+ businessName: stagingOrganization,
240
+ subdomainName: IS_STAGING_ENV ? stagingOrganization : "spinkart",
241
+ email: IS_STAGING_ENV
242
+ ? `cypresstest${otpBypassKey}+${product}+${timestamp}-playwright@bigbinary.com`
243
+ : "oliver@example.com",
244
+ };
245
+ };
246
+
14
247
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
15
248
 
16
249
  var tasks = {};
@@ -6709,56 +6942,6 @@ function assertPatternsInput(input) {
6709
6942
  }
6710
6943
  var out = FastGlob;
6711
6944
 
6712
- const ENVIRONMENT = {
6713
- development: "development",
6714
- staging: "staging",
6715
- review: "review",
6716
- };
6717
- const IS_STAGING_ENV = process.env.TEST_ENV === "staging";
6718
- const STORAGE_STATE = "./e2e/auth/user.json";
6719
- const GLOBAL_TRANSLATIONS_PATTERN = "../node_modules/@bigbinary/**/translations/en.json";
6720
- const PROJECT_TRANSLATIONS_PATH = "../app/javascript/src/translations/en.json";
6721
- const CREDENTIALS = {
6722
- name: "Oliver Smith",
6723
- email: "oliver@example.com",
6724
- password: "welcome",
6725
- };
6726
-
6727
- const joinString = (string1, string2, string3 = "", separator = " ") => {
6728
- if (string3 === "") {
6729
- return string1 + separator + string2;
6730
- }
6731
- return string1 + separator + string2 + separator + string3;
6732
- };
6733
- const readFileSyncIfExists = (path = STORAGE_STATE) => {
6734
- try {
6735
- return JSON.parse(require$$0.readFileSync(path, "utf8"));
6736
- }
6737
- catch (error) {
6738
- return {};
6739
- }
6740
- };
6741
- const writeDataToFile = data => {
6742
- try {
6743
- require$$0.writeFileSync(STORAGE_STATE, data, "utf8");
6744
- }
6745
- catch (error) {
6746
- console.log(error); // eslint-disable-line
6747
- }
6748
- return true;
6749
- };
6750
- const updateCredentials = ({ key, value }) => {
6751
- const data = readFileSyncIfExists();
6752
- data["user"][key] = value;
6753
- return writeDataToFile(JSON.stringify(data));
6754
- };
6755
- const clearCredentials = () => {
6756
- require$$0.unlink(STORAGE_STATE, error => {
6757
- if (!error)
6758
- return;
6759
- console.log(error); // eslint-disable-line
6760
- });
6761
- };
6762
6945
  const readTranslations = () => {
6763
6946
  let translations = readFileSyncIfExists(PROJECT_TRANSLATIONS_PATH);
6764
6947
  const paths = out.sync(GLOBAL_TRANSLATIONS_PATTERN);
@@ -6768,204 +6951,70 @@ const readTranslations = () => {
6768
6951
  });
6769
6952
  return translations;
6770
6953
  };
6771
- const hyphenize = input => {
6772
- const fallbackString = "";
6773
- if (typeof input === "number")
6774
- return String(input);
6775
- if (input && typeof input === "string" && input.replace) {
6776
- return input
6777
- .replace(/[\s_]/g, "-")
6778
- .replace(/([a-z])([A-Z])/g, "$1-$2")
6779
- .replace(/-+/g, "-")
6780
- .toLowerCase();
6954
+ const getter = (key) => () => getI18nInstance().t(`taxonomyDefaultLabels.${key}`);
6955
+ const replaceNullValuesWithGetter = (inputObject, parentKey = "") => {
6956
+ const result = {};
6957
+ for (const [key, value] of Object.entries(inputObject)) {
6958
+ const transKey = parentKey ? `${parentKey}.${key}` : key;
6959
+ if (value === null) {
6960
+ Object.defineProperty(result, key, {
6961
+ get: getter(transKey),
6962
+ });
6963
+ }
6964
+ else if (typeof value === "object") {
6965
+ result[key] = replaceNullValuesWithGetter(value, transKey);
6966
+ }
6967
+ else {
6968
+ result[key] = value;
6969
+ }
6781
6970
  }
6782
- return fallbackString;
6971
+ return result;
6783
6972
  };
6784
- const joinHyphenCase = (...args) => args.join(" ").replace(/\s+/g, "-").toLowerCase();
6785
-
6786
- const COMMON_SELECTORS = {
6787
- spinner: ".neeto-ui-spinner",
6788
- subheaderText: "subheader-left",
6789
- alertTitle: "alert-title",
6790
- alertModalMessage: "alert-message",
6791
- alertModalSubmitButton: "alert-submit-button",
6792
- checkbox: "nui-checkbox-input",
6793
- checkboxLabel: "nui-checkbox-label",
6794
- dropdownContainer: "nui-dropdown-container",
6795
- dropdownIcon: "nui-dropdown-icon",
6796
- heading: "main-header",
6797
- paneBody: "pane-body",
6798
- paneHeader: "pane-header",
6799
- profileSidebar: "profile-section",
6800
- selectOption: (label) => `${hyphenize(label)}-select-option`,
6801
- toastMessage: "toastr-message-container",
6802
- toastCloseButton: "toastr-close-button",
6803
- windowAlert: "#alert-box",
6804
- body: "body",
6805
- toastIcon: ".Toastify__toast-icon",
6806
- paneModalCrossIcon: "pane-close-button",
6807
- inputField: "nui-input-field",
6808
- alertConfirmationText: "alert-confirmation-text",
6809
- alertCancelButton: "alert-cancel-button",
6810
- alertModalCrossIcon: "modal-close-button",
6811
- saveChangesButton: "save-changes-button",
6812
- cancelButton: "cancel-button",
6813
- inputFieldError: "nui-input-error",
6814
- selectDropDownError: "nui-select-error",
6815
- subTitleHeading: "menubar-subtitle-heading",
6816
- noDataTitle: "no-data-title",
6817
- noDataDescription: "no-data-description",
6818
- backdrop: "neeto-backdrop",
6819
- menuBarHeading: "menubar-heading",
6820
- dropdownWrapper: "nui-select-container-wrapper",
6821
- toggleButton: "menubar-toggle-button",
6822
- tooltip: "tooltip-box",
6823
- articlePageTitle: ".serene-article__title",
6824
- tabItem: "tab-item",
6825
- labelInputError: "label-input-error",
6826
- urlInputError: "url-input-error",
6827
- noDataPrimaryButton: "no-data-primary-button",
6828
- modalHeader: "modal-header",
6829
- nameInputError: "name-input-error",
6830
- selectContainer: "nui-select-container",
6831
- dropdownMenu: "nui-select-menu",
6832
- sidebarToggle: "neeto-molecules-sidebar-toggler",
6833
- subheader: "subheader",
6834
- settingsLink: "Settings",
6835
- ticketFieldTextInput: (label) => `${hyphenize(label)}-text-input`,
6973
+ const mergeTaxonomies = async (translations, page) => {
6974
+ const defaultTaxonomyKeys = Object.keys(translations.taxonomyDefaultLabels || {});
6975
+ const defaultTaxonomies = Object.fromEntries(defaultTaxonomyKeys.map(key => [key, { singular: null, plural: null }]));
6976
+ const hostTaxonomies = (await page.evaluate(() => { var _a; return (_a = window.globalProps) === null || _a === void 0 ? void 0 : _a.taxonomies; }));
6977
+ return replaceNullValuesWithGetter(mergeDeepLeft(hostTaxonomies, defaultTaxonomies));
6836
6978
  };
6837
6979
 
6838
- class CustomCommands {
6839
- constructor(page, request) {
6840
- this.interceptMultipleResponses = ({ responseUrl = "", times = 1, baseUrl, }) => Promise.all([...new Array(times)].map(() => this.page.waitForResponse((response) => {
6841
- var _a, _b, _c;
6842
- if (response.request().resourceType() === "xhr" &&
6843
- response.status() === 200 &&
6844
- response.url().includes(responseUrl) &&
6845
- response
6846
- .url()
6847
- .startsWith((_a = baseUrl !== null && baseUrl !== void 0 ? baseUrl : process.env.BASE_URL) !== null && _a !== void 0 ? _a : "") &&
6848
- !this.responses.includes((_b = response.headers()) === null || _b === void 0 ? void 0 : _b["x-request-id"])) {
6849
- this.responses.push((_c = response.headers()) === null || _c === void 0 ? void 0 : _c["x-request-id"]);
6850
- return true;
6851
- }
6852
- return false;
6853
- }, { timeout: 10000 })));
6854
- this.recursiveMethod = async (callback, condition, timeout, startTime) => {
6855
- if (Date.now() - timeout >= startTime) {
6856
- return false;
6857
- }
6858
- else if (await condition()) {
6859
- return await callback();
6860
- }
6861
- return await this.recursiveMethod(callback, condition, timeout, startTime);
6862
- };
6863
- this.executeRecursively = async ({ callback, condition, timeout = 5000, }) => {
6864
- const startTime = Date.now();
6865
- await this.recursiveMethod(callback, condition, timeout, startTime);
6866
- };
6867
- this.verifySuccessToast = async ({ message, closeAfterVerification = true, }) => {
6868
- if (message) {
6869
- await expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toHaveValue(message);
6870
- }
6871
- else {
6872
- await expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toHaveValue("👍");
6873
- closeAfterVerification &&
6874
- (await this.page
6875
- .getByTestId(COMMON_SELECTORS.toastCloseButton)
6876
- .click());
6877
- }
6878
- };
6879
- this.reloadAndWait = async (requestCount) => {
6880
- const reloadRequests = this.interceptMultipleResponses({
6881
- times: requestCount,
6882
- });
6883
- await this.page.reload();
6884
- await reloadRequests;
6885
- };
6886
- this.apiRequest = async ({ url, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
6887
- const csrfToken = await this.page
6888
- .locator("[name='csrf-token']")
6889
- .getAttribute("content");
6890
- const requestOptions = {
6891
- headers: {
6892
- ...additionalHeaders,
6893
- "accept-encoding": "gzip",
6894
- "x-csrf-token": csrfToken !== null && csrfToken !== void 0 ? csrfToken : "",
6980
+ const i18nFixture = {
6981
+ i18n: [
6982
+ async ({ page }, use) => {
6983
+ const translation = readTranslations();
6984
+ const taxonomies = await mergeTaxonomies(translation, page);
6985
+ const options = {
6986
+ debug: false,
6987
+ fallbackLng: "en",
6988
+ resources: { en: { translation } },
6989
+ interpolation: {
6990
+ defaultVariables: { taxonomies },
6895
6991
  },
6896
- data,
6897
- params,
6898
- ...otherOptions,
6899
- };
6900
- const httpMethodsHandlers = {
6901
- get: () => this.request.get(url, requestOptions),
6902
- post: () => this.request.post(url, requestOptions),
6903
- put: () => this.request.put(url, requestOptions),
6904
- delete: () => this.request.delete(url, requestOptions),
6992
+ postProcess: "removeTags",
6905
6993
  };
6906
- return await httpMethodsHandlers[method]();
6907
- };
6908
- this.verifyFieldValue = values => {
6909
- const verifyEachFieldValue = ({ field, value, }) => expect(this.page.getByTestId(field)).toHaveValue(value);
6910
- return Array.isArray(values)
6911
- ? Promise.all(values.map(value => verifyEachFieldValue(value)))
6912
- : verifyEachFieldValue(values);
6913
- };
6914
- this.page = page;
6915
- this.responses = [];
6916
- this.request = request;
6917
- }
6918
- }
6919
-
6920
- const commands = {
6921
- neetoPlaywrightUtilities: async ({ page, request }, use) => {
6922
- const commands = new CustomCommands(page, request);
6923
- await use(commands);
6924
- },
6925
- page: async ({ page }, use) => {
6926
- await page.goto("/");
6927
- await page.waitForLoadState();
6928
- await use(page);
6994
+ const i18nInitialized = await initI18n({
6995
+ plugins: [
6996
+ {
6997
+ type: "postProcessor",
6998
+ name: "removeTags",
6999
+ process: function (value) {
7000
+ return value.replace(/<\/?[^>]+(>|$)/g, "");
7001
+ },
7002
+ },
7003
+ ],
7004
+ options,
7005
+ // Fetch translations in every test or fetch once
7006
+ cache: true,
7007
+ });
7008
+ await use(i18nInitialized);
7009
+ },
7010
+ // Run as auto fixture to be available through all tests by getI18nInstance()
7011
+ { auto: true },
7012
+ ],
7013
+ t: async ({ i18n }, use) => {
7014
+ await use(i18n.t);
6929
7015
  },
6930
7016
  };
6931
7017
 
6932
- const generateStagingData = (product = "invoice") => {
6933
- const timestamp = dayjs().format("YYYYMMDDHH");
6934
- const firstName = "André";
6935
- const lastName = "O'Reilly";
6936
- const otpBypassKey = process.env.OTP_BYPASS_KEY;
6937
- const stagingOrganization = `cypresstest-${product}-${timestamp}`;
6938
- return {
6939
- firstName,
6940
- lastName,
6941
- otp: 111111,
6942
- domain: `neeto${product}.net`,
6943
- currentUserName: IS_STAGING_ENV
6944
- ? joinString(firstName, lastName)
6945
- : CREDENTIALS.name,
6946
- businessName: stagingOrganization,
6947
- subdomainName: IS_STAGING_ENV ? stagingOrganization : "spinkart",
6948
- email: IS_STAGING_ENV
6949
- ? `cypresstest${otpBypassKey}+${product}+${timestamp}-playwright@bigbinary.com`
6950
- : "oliver@example.com",
6951
- };
6952
- };
6953
-
6954
- const i18nFixture = createI18nFixture({
6955
- // i18n configuration options
6956
- options: {
6957
- debug: false,
6958
- fallbackLng: "en",
6959
- resources: { en: { translation: readTranslations() } },
6960
- },
6961
- // Fetch translations in every test or fetch once
6962
- // Default: true
6963
- cache: true,
6964
- // Run as auto fixture to be available through all tests by getI18nInstance()
6965
- // Default: true
6966
- auto: true,
6967
- });
6968
-
6969
7018
  const BASE_URL = "/api/v1";
6970
7019
  const ROUTES = {
6971
7020
  neetoAuth: "https://app.neetoauth.net",
@@ -7278,8 +7327,7 @@ const initializeCredentials = (product) => {
7278
7327
  };
7279
7328
 
7280
7329
  const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/", }) => {
7281
- var _a;
7282
- await page.goto((_a = `${process.env.BASE_URL}${loginPath}`) !== null && _a !== void 0 ? _a : "");
7330
+ await page.goto(loginPath);
7283
7331
  await page.getByTestId("login-email-text-field").fill(CREDENTIALS.email);
7284
7332
  await page
7285
7333
  .getByTestId("login-password-text-field")
@@ -7291,10 +7339,7 @@ const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/"
7291
7339
  await login;
7292
7340
  const userCredentials = readFileSyncIfExists();
7293
7341
  await page.context().storageState({ path: STORAGE_STATE });
7294
- const mergedCredentials = mergeAll([
7295
- readFileSyncIfExists(),
7296
- userCredentials,
7297
- ]);
7342
+ const mergedCredentials = mergeAll([readFileSyncIfExists(), userCredentials]);
7298
7343
  writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
7299
7344
  };
7300
7345
  const login = async ({ page, neetoPlaywrightUtilities, loginPath, }) => !IS_STAGING_ENV &&
@@ -7718,7 +7763,6 @@ const definePlaywrightConfig = (overrides) => {
7718
7763
  forbidOnly: isCI,
7719
7764
  retries: isCI ? 1 : 0,
7720
7765
  timeout: 0,
7721
- workers: 1,
7722
7766
  reporter: isCI
7723
7767
  ? [["@currents/playwright", { ...currentsConfig, ...currentsOverrides }]]
7724
7768
  : [["line"]],
@@ -7748,5 +7792,5 @@ const definePlaywrightConfig = (overrides) => {
7748
7792
  });
7749
7793
  };
7750
7794
 
7751
- export { BASE_URL, CHAT_WIDGET_SELECTORS, COMMON_SELECTORS, CREDENTIALS, CustomCommands, ENVIRONMENT, GLOBAL_TRANSLATIONS_PATTERN, HELP_CENTER_SELECTORS, IS_STAGING_ENV, LOGIN_SELECTORS, MEMBER_FORM_SELECTORS, MEMBER_SELECTORS, MERGE_TAGS_SELECTORS, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, OrganizationPage, PROJECT_TRANSLATIONS_PATH, ROLES_SELECTORS, ROUTES, SIGNUP_SELECTORS, STORAGE_STATE, TAGS_SELECTORS, clearCredentials, commands, definePlaywrightConfig, generateStagingData, hyphenize, i18nFixture, initializeCredentials, joinHyphenCase, joinString, login, loginWithoutSSO, readFileSyncIfExists, readTranslations, updateCredentials, writeDataToFile };
7795
+ export { BASE_URL, CHAT_WIDGET_SELECTORS, COMMON_SELECTORS, CREDENTIALS, CustomCommands, ENVIRONMENT, GLOBAL_TRANSLATIONS_PATTERN, HELP_CENTER_SELECTORS, IS_STAGING_ENV, LOGIN_SELECTORS, MEMBER_FORM_SELECTORS, MEMBER_SELECTORS, MERGE_TAGS_SELECTORS, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, OrganizationPage, PROJECT_TRANSLATIONS_PATH, ROLES_SELECTORS, ROUTES, SIGNUP_SELECTORS, STORAGE_STATE, TAGS_SELECTORS, clearCredentials, commands, definePlaywrightConfig, generateStagingData, hyphenize, i18nFixture, initializeCredentials, joinHyphenCase, joinString, login, loginWithoutSSO, readFileSyncIfExists, updateCredentials, writeDataToFile };
7752
7796
  //# sourceMappingURL=index.js.map