@bigbinary/neeto-playwright-commons 1.3.2 → 1.4.1

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,247 @@
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)).toContainText(message);
163
+ }
164
+ else {
165
+ await expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toContainText("👍");
166
+ }
167
+ closeAfterVerification &&
168
+ (await this.page.getByTestId(COMMON_SELECTORS.toastCloseButton).click());
169
+ };
170
+ this.reloadAndWait = async (requestCount) => {
171
+ const reloadRequests = this.interceptMultipleResponses({
172
+ times: requestCount,
173
+ });
174
+ await this.page.reload();
175
+ await reloadRequests;
176
+ };
177
+ this.apiRequest = async ({ url, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
178
+ const csrfToken = await this.page
179
+ .locator("[name='csrf-token']")
180
+ .getAttribute("content");
181
+ const requestOptions = {
182
+ headers: {
183
+ ...additionalHeaders,
184
+ "accept-encoding": "gzip",
185
+ "x-csrf-token": csrfToken !== null && csrfToken !== void 0 ? csrfToken : "",
186
+ },
187
+ data,
188
+ params,
189
+ ...otherOptions,
190
+ };
191
+ const httpMethodsHandlers = {
192
+ get: () => this.request.get(url, requestOptions),
193
+ post: () => this.request.post(url, requestOptions),
194
+ put: () => this.request.put(url, requestOptions),
195
+ delete: () => this.request.delete(url, requestOptions),
196
+ };
197
+ return await httpMethodsHandlers[method]();
198
+ };
199
+ this.verifyFieldValue = values => {
200
+ const verifyEachFieldValue = ({ field, value, }) => expect(this.page.getByTestId(field)).toHaveValue(value);
201
+ return Array.isArray(values)
202
+ ? Promise.all(values.map(value => verifyEachFieldValue(value)))
203
+ : verifyEachFieldValue(values);
204
+ };
205
+ this.page = page;
206
+ this.responses = [];
207
+ this.request = request;
208
+ }
209
+ }
210
+
211
+ const commands = {
212
+ neetoPlaywrightUtilities: async ({ page, request }, use) => {
213
+ const commands = new CustomCommands(page, request);
214
+ await use(commands);
215
+ },
216
+ page: async ({ page }, use) => {
217
+ await page.goto("/");
218
+ await page.waitForLoadState();
219
+ await use(page);
220
+ },
221
+ };
222
+
223
+ const generateStagingData = (product = "invoice") => {
224
+ const timestamp = dayjs().format("YYYYMMDDHH");
225
+ const firstName = "André";
226
+ const lastName = "O'Reilly";
227
+ const otpBypassKey = process.env.OTP_BYPASS_KEY;
228
+ const stagingOrganization = `cypresstest-${product}-${timestamp}`;
229
+ return {
230
+ firstName,
231
+ lastName,
232
+ otp: 111111,
233
+ domain: `neeto${product}.net`,
234
+ currentUserName: IS_STAGING_ENV
235
+ ? joinString(firstName, lastName)
236
+ : CREDENTIALS.name,
237
+ businessName: stagingOrganization,
238
+ subdomainName: IS_STAGING_ENV ? stagingOrganization : "spinkart",
239
+ email: IS_STAGING_ENV
240
+ ? `cypresstest${otpBypassKey}+${product}+${timestamp}-playwright@bigbinary.com`
241
+ : "oliver@example.com",
242
+ };
243
+ };
244
+
14
245
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
15
246
 
16
247
  var tasks = {};
@@ -6709,56 +6940,6 @@ function assertPatternsInput(input) {
6709
6940
  }
6710
6941
  var out = FastGlob;
6711
6942
 
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
6943
  const readTranslations = () => {
6763
6944
  let translations = readFileSyncIfExists(PROJECT_TRANSLATIONS_PATH);
6764
6945
  const paths = out.sync(GLOBAL_TRANSLATIONS_PATTERN);
@@ -6768,204 +6949,70 @@ const readTranslations = () => {
6768
6949
  });
6769
6950
  return translations;
6770
6951
  };
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();
6952
+ const getter = (key) => () => getI18nInstance().t(`taxonomyDefaultLabels.${key}`);
6953
+ const replaceNullValuesWithGetter = (inputObject, parentKey = "") => {
6954
+ const result = {};
6955
+ for (const [key, value] of Object.entries(inputObject)) {
6956
+ const transKey = parentKey ? `${parentKey}.${key}` : key;
6957
+ if (value === null) {
6958
+ Object.defineProperty(result, key, {
6959
+ get: getter(transKey),
6960
+ });
6961
+ }
6962
+ else if (typeof value === "object") {
6963
+ result[key] = replaceNullValuesWithGetter(value, transKey);
6964
+ }
6965
+ else {
6966
+ result[key] = value;
6967
+ }
6781
6968
  }
6782
- return fallbackString;
6969
+ return result;
6783
6970
  };
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`,
6971
+ const mergeTaxonomies = async (translations, page) => {
6972
+ const defaultTaxonomyKeys = Object.keys(translations.taxonomyDefaultLabels || {});
6973
+ const defaultTaxonomies = Object.fromEntries(defaultTaxonomyKeys.map(key => [key, { singular: null, plural: null }]));
6974
+ const hostTaxonomies = (await page.evaluate(() => { var _a; return (_a = window.globalProps) === null || _a === void 0 ? void 0 : _a.taxonomies; }));
6975
+ return replaceNullValuesWithGetter(mergeDeepLeft(hostTaxonomies, defaultTaxonomies));
6836
6976
  };
6837
6977
 
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 : "",
6978
+ const i18nFixture = {
6979
+ i18n: [
6980
+ async ({ page }, use) => {
6981
+ const translation = readTranslations();
6982
+ const taxonomies = await mergeTaxonomies(translation, page);
6983
+ const options = {
6984
+ debug: false,
6985
+ fallbackLng: "en",
6986
+ resources: { en: { translation } },
6987
+ interpolation: {
6988
+ defaultVariables: { taxonomies },
6895
6989
  },
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),
6990
+ postProcess: "removeTags",
6905
6991
  };
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);
6992
+ const i18nInitialized = await initI18n({
6993
+ plugins: [
6994
+ {
6995
+ type: "postProcessor",
6996
+ name: "removeTags",
6997
+ process: function (value) {
6998
+ return value.replace(/<\/?[^>]+(>|$)/g, "");
6999
+ },
7000
+ },
7001
+ ],
7002
+ options,
7003
+ // Fetch translations in every test or fetch once
7004
+ cache: true,
7005
+ });
7006
+ await use(i18nInitialized);
7007
+ },
7008
+ // Run as auto fixture to be available through all tests by getI18nInstance()
7009
+ { auto: true },
7010
+ ],
7011
+ t: async ({ i18n }, use) => {
7012
+ await use(i18n.t);
6929
7013
  },
6930
7014
  };
6931
7015
 
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
7016
  const BASE_URL = "/api/v1";
6970
7017
  const ROUTES = {
6971
7018
  neetoAuth: "https://app.neetoauth.net",
@@ -7278,8 +7325,7 @@ const initializeCredentials = (product) => {
7278
7325
  };
7279
7326
 
7280
7327
  const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/", }) => {
7281
- var _a;
7282
- await page.goto((_a = `${process.env.BASE_URL}${loginPath}`) !== null && _a !== void 0 ? _a : "");
7328
+ await page.goto(loginPath);
7283
7329
  await page.getByTestId("login-email-text-field").fill(CREDENTIALS.email);
7284
7330
  await page
7285
7331
  .getByTestId("login-password-text-field")
@@ -7291,10 +7337,7 @@ const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/"
7291
7337
  await login;
7292
7338
  const userCredentials = readFileSyncIfExists();
7293
7339
  await page.context().storageState({ path: STORAGE_STATE });
7294
- const mergedCredentials = mergeAll([
7295
- readFileSyncIfExists(),
7296
- userCredentials,
7297
- ]);
7340
+ const mergedCredentials = mergeAll([readFileSyncIfExists(), userCredentials]);
7298
7341
  writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
7299
7342
  };
7300
7343
  const login = async ({ page, neetoPlaywrightUtilities, loginPath, }) => !IS_STAGING_ENV &&
@@ -7718,7 +7761,6 @@ const definePlaywrightConfig = (overrides) => {
7718
7761
  forbidOnly: isCI,
7719
7762
  retries: isCI ? 1 : 0,
7720
7763
  timeout: 0,
7721
- workers: 1,
7722
7764
  reporter: isCI
7723
7765
  ? [["@currents/playwright", { ...currentsConfig, ...currentsOverrides }]]
7724
7766
  : [["line"]],
@@ -7748,5 +7790,5 @@ const definePlaywrightConfig = (overrides) => {
7748
7790
  });
7749
7791
  };
7750
7792
 
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 };
7793
+ 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
7794
  //# sourceMappingURL=index.js.map