@bigbinary/neeto-playwright-commons 1.1.2 → 1.2.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.cjs.js +151 -148
- package/index.cjs.js.map +1 -1
- package/index.d.ts +12 -9
- package/index.js +150 -148
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -19,13 +19,13 @@ interface VerifySuccessToastParams {
|
|
|
19
19
|
closeAfterVerification: boolean;
|
|
20
20
|
}
|
|
21
21
|
type VerifySuccessToast = (params: VerifySuccessToastParams) => Promise<void>;
|
|
22
|
-
declare const HTTP_METHODS: readonly ["get", "post", "put", "delete", "GET", "POST", "PUT", "DELETE"];
|
|
23
22
|
type BasicTypesInterface = Record<string, number | string | boolean>;
|
|
23
|
+
type HttpMethods = "get" | "post" | "put" | "delete";
|
|
24
24
|
interface ApiRequestProps {
|
|
25
25
|
url: string;
|
|
26
26
|
headers?: BasicTypesInterface;
|
|
27
27
|
data?: Record<string, unknown>;
|
|
28
|
-
method?:
|
|
28
|
+
method?: HttpMethods;
|
|
29
29
|
params?: BasicTypesInterface;
|
|
30
30
|
}
|
|
31
31
|
type ApiRequest = (props: ApiRequestProps & Record<string, unknown>) => Promise<APIResponse | undefined>;
|
|
@@ -55,7 +55,7 @@ interface CustomFixture {
|
|
|
55
55
|
type Commands = Fixtures<CustomFixture, PlaywrightWorkerArgs & PlaywrightWorkerOptions, PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
|
|
56
56
|
declare const commands: Commands;
|
|
57
57
|
|
|
58
|
-
declare const
|
|
58
|
+
declare const generateStagingData: (product?: string) => {
|
|
59
59
|
firstName: string;
|
|
60
60
|
lastName: string;
|
|
61
61
|
otp: number;
|
|
@@ -93,7 +93,7 @@ declare class OrganizationPage {
|
|
|
93
93
|
neetoPlaywrightUtilities: CustomCommands;
|
|
94
94
|
constructor(page: Page, neetoPlaywrightUtilities: CustomCommands);
|
|
95
95
|
createOrganization: ({ email, businessName, subdomainName, firstName, lastName, appName, }: CreateOrganizationProps) => Promise<void>;
|
|
96
|
-
setupOrganization: () => Promise<void>;
|
|
96
|
+
setupOrganization: (product: string) => Promise<void>;
|
|
97
97
|
updateSubdomainIfExists: (appName: string) => Promise<void>;
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -107,10 +107,12 @@ declare const STORAGE_STATE = "./e2e/auth/user.json";
|
|
|
107
107
|
declare const GLOBAL_TRANSLATIONS_PATTERN = "../node_modules/@bigbinary/**/translations/en.json";
|
|
108
108
|
declare const PROJECT_TRANSLATIONS_PATH = "../app/javascript/src/translations/en.json";
|
|
109
109
|
declare const CREDENTIALS: {
|
|
110
|
+
name: string;
|
|
110
111
|
email: string;
|
|
111
112
|
password: string;
|
|
112
113
|
};
|
|
113
114
|
|
|
115
|
+
declare const BASE_URL = "/api/v1";
|
|
114
116
|
declare const ROUTES: {
|
|
115
117
|
neetoAuth: string;
|
|
116
118
|
profile: string;
|
|
@@ -118,7 +120,7 @@ declare const ROUTES: {
|
|
|
118
120
|
signup: string;
|
|
119
121
|
subdomainAvailability: string;
|
|
120
122
|
countries: string;
|
|
121
|
-
|
|
123
|
+
neetoApps: string;
|
|
122
124
|
};
|
|
123
125
|
|
|
124
126
|
declare const COMMON_SELECTORS: {
|
|
@@ -165,7 +167,7 @@ declare const COMMON_TEXTS: {
|
|
|
165
167
|
edit: string;
|
|
166
168
|
};
|
|
167
169
|
|
|
168
|
-
declare const initializeCredentials: () => void;
|
|
170
|
+
declare const initializeCredentials: (product: string) => void;
|
|
169
171
|
|
|
170
172
|
interface KeyValue {
|
|
171
173
|
key: string;
|
|
@@ -190,9 +192,10 @@ declare const readTranslations: () => Record<string, unknown>;
|
|
|
190
192
|
interface LoginProps {
|
|
191
193
|
page: Page;
|
|
192
194
|
neetoPlaywrightUtilities: CustomCommands;
|
|
195
|
+
loginPath: string;
|
|
193
196
|
}
|
|
194
|
-
declare const loginWithoutSSO: ({ page, neetoPlaywrightUtilities, }: LoginProps) => Promise<void>;
|
|
195
|
-
declare const login: ({ page, neetoPlaywrightUtilities }: LoginProps) => Promise<false | void>;
|
|
197
|
+
declare const loginWithoutSSO: ({ page, neetoPlaywrightUtilities, loginPath, }: LoginProps) => Promise<void>;
|
|
198
|
+
declare const login: ({ page, neetoPlaywrightUtilities, loginPath, }: LoginProps) => Promise<false | void>;
|
|
196
199
|
|
|
197
200
|
interface CurrentsOverrides {
|
|
198
201
|
projectId: string;
|
|
@@ -205,4 +208,4 @@ interface Overrides {
|
|
|
205
208
|
}
|
|
206
209
|
declare const definePlaywrightConfig: (overrides: Overrides) => _playwright_test.PlaywrightTestConfig<{}, {}>;
|
|
207
210
|
|
|
208
|
-
export { COMMON_SELECTORS, COMMON_TEXTS, CREDENTIALS, CustomCommands, type CustomFixture, ENVIRONMENT, GLOBAL_TRANSLATIONS_PATTERN, IS_STAGING_ENV, LOGIN_SELECTORS, OrganizationPage, PROJECT_TRANSLATIONS_PATH, ROUTES, SIGNUP_SELECTORS, STORAGE_STATE, clearCredentials, commands, definePlaywrightConfig, i18n, initializeCredentials, joinString, login, loginWithoutSSO, readFileSyncIfExists, readTranslations,
|
|
211
|
+
export { BASE_URL, COMMON_SELECTORS, COMMON_TEXTS, CREDENTIALS, CustomCommands, type CustomFixture, ENVIRONMENT, GLOBAL_TRANSLATIONS_PATTERN, IS_STAGING_ENV, LOGIN_SELECTORS, OrganizationPage, PROJECT_TRANSLATIONS_PATH, ROUTES, SIGNUP_SELECTORS, STORAGE_STATE, clearCredentials, commands, definePlaywrightConfig, generateStagingData, i18n, initializeCredentials, joinString, login, loginWithoutSSO, readFileSyncIfExists, readTranslations, updateCredentials, writeDataToFile };
|
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { expect, defineConfig, devices } from '@playwright/test';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
2
3
|
import * as require$$0 from 'fs';
|
|
3
4
|
import require$$0__default from 'fs';
|
|
4
5
|
import require$$2 from 'os';
|
|
@@ -6,8 +7,7 @@ import require$$0$1 from 'path';
|
|
|
6
7
|
import require$$0$2 from 'util';
|
|
7
8
|
import require$$0$3 from 'stream';
|
|
8
9
|
import require$$0$4 from 'events';
|
|
9
|
-
import { mergeDeepLeft } from 'ramda';
|
|
10
|
-
import dayjs from 'dayjs';
|
|
10
|
+
import { mergeDeepLeft, mergeAll } from 'ramda';
|
|
11
11
|
import require$$3 from 'crypto';
|
|
12
12
|
|
|
13
13
|
const COMMON_SELECTORS = {
|
|
@@ -23,6 +23,115 @@ const COMMON_SELECTORS = {
|
|
|
23
23
|
subheaderText: "subheader-left",
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
class CustomCommands {
|
|
27
|
+
constructor(page, request) {
|
|
28
|
+
this.interceptMultipleResponses = ({ responseUrl = "", times = 1, baseUrl, }) => Promise.all([...new Array(times)].map(() => this.page.waitForResponse((response) => {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
if (response.request().resourceType() === "xhr" &&
|
|
31
|
+
response.status() === 200 &&
|
|
32
|
+
response.url().includes(responseUrl) &&
|
|
33
|
+
response
|
|
34
|
+
.url()
|
|
35
|
+
.startsWith((_a = baseUrl !== null && baseUrl !== void 0 ? baseUrl : process.env.BASE_URL) !== null && _a !== void 0 ? _a : "") &&
|
|
36
|
+
!this.responses.includes((_b = response.headers()) === null || _b === void 0 ? void 0 : _b["x-request-id"])) {
|
|
37
|
+
this.responses.push((_c = response.headers()) === null || _c === void 0 ? void 0 : _c["x-request-id"]);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}, { timeout: 10000 })));
|
|
42
|
+
this.recursiveMethod = async (callback, condition, timeout, startTime) => {
|
|
43
|
+
if (Date.now() - timeout >= startTime) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
else if (await condition()) {
|
|
47
|
+
return await callback();
|
|
48
|
+
}
|
|
49
|
+
return await this.recursiveMethod(callback, condition, timeout, startTime);
|
|
50
|
+
};
|
|
51
|
+
this.executeRecursively = async ({ callback, condition, timeout = 5000, }) => {
|
|
52
|
+
const startTime = Date.now();
|
|
53
|
+
await this.recursiveMethod(callback, condition, timeout, startTime);
|
|
54
|
+
};
|
|
55
|
+
this.verifySuccessToast = async ({ message, closeAfterVerification = true, }) => {
|
|
56
|
+
if (message) {
|
|
57
|
+
await expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toHaveValue(message);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
await expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toHaveValue("👍");
|
|
61
|
+
closeAfterVerification &&
|
|
62
|
+
(await this.page
|
|
63
|
+
.getByTestId(COMMON_SELECTORS.toastCloseButton)
|
|
64
|
+
.click());
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
this.reloadAndWait = async (requestCount) => {
|
|
68
|
+
const reloadRequests = this.interceptMultipleResponses({
|
|
69
|
+
times: requestCount,
|
|
70
|
+
});
|
|
71
|
+
await this.page.reload();
|
|
72
|
+
await reloadRequests;
|
|
73
|
+
};
|
|
74
|
+
this.apiRequest = async ({ url, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
|
|
75
|
+
const csrfToken = await this.page
|
|
76
|
+
.locator("[name='csrf-token']")
|
|
77
|
+
.getAttribute("content");
|
|
78
|
+
const requestOptions = {
|
|
79
|
+
headers: {
|
|
80
|
+
...additionalHeaders,
|
|
81
|
+
"accept-encoding": "gzip",
|
|
82
|
+
"x-csrf-token": csrfToken !== null && csrfToken !== void 0 ? csrfToken : "",
|
|
83
|
+
},
|
|
84
|
+
data,
|
|
85
|
+
params,
|
|
86
|
+
...otherOptions,
|
|
87
|
+
};
|
|
88
|
+
const httpMethodsHandlers = {
|
|
89
|
+
get: () => this.request.get(url, requestOptions),
|
|
90
|
+
post: () => this.request.post(url, requestOptions),
|
|
91
|
+
put: () => this.request.put(url, requestOptions),
|
|
92
|
+
delete: () => this.request.delete(url, requestOptions),
|
|
93
|
+
};
|
|
94
|
+
return await httpMethodsHandlers[method]();
|
|
95
|
+
};
|
|
96
|
+
this.verifyFieldValue = values => {
|
|
97
|
+
const verifyEachFieldValue = ({ field, value, }) => expect(this.page.getByTestId(field)).toHaveValue(value);
|
|
98
|
+
return Array.isArray(values)
|
|
99
|
+
? Promise.all(values.map(value => verifyEachFieldValue(value)))
|
|
100
|
+
: verifyEachFieldValue(values);
|
|
101
|
+
};
|
|
102
|
+
this.page = page;
|
|
103
|
+
this.responses = [];
|
|
104
|
+
this.request = request;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const commands = {
|
|
109
|
+
neetoPlaywrightUtilities: async ({ page, request }, use) => {
|
|
110
|
+
const commands = new CustomCommands(page, request);
|
|
111
|
+
await use(commands);
|
|
112
|
+
},
|
|
113
|
+
page: async ({ page }, use) => {
|
|
114
|
+
await page.goto("/");
|
|
115
|
+
await page.waitForLoadState();
|
|
116
|
+
await use(page);
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const ENVIRONMENT = {
|
|
121
|
+
development: "development",
|
|
122
|
+
staging: "staging",
|
|
123
|
+
review: "review",
|
|
124
|
+
};
|
|
125
|
+
const IS_STAGING_ENV = process.env.TEST_ENV === "staging";
|
|
126
|
+
const STORAGE_STATE = "./e2e/auth/user.json";
|
|
127
|
+
const GLOBAL_TRANSLATIONS_PATTERN = "../node_modules/@bigbinary/**/translations/en.json";
|
|
128
|
+
const PROJECT_TRANSLATIONS_PATH = "../app/javascript/src/translations/en.json";
|
|
129
|
+
const CREDENTIALS = {
|
|
130
|
+
name: "Oliver Smith",
|
|
131
|
+
email: "oliver@example.com",
|
|
132
|
+
password: "welcome",
|
|
133
|
+
};
|
|
134
|
+
|
|
26
135
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
27
136
|
|
|
28
137
|
var tasks = {};
|
|
@@ -6721,17 +6830,6 @@ function assertPatternsInput(input) {
|
|
|
6721
6830
|
}
|
|
6722
6831
|
var out = FastGlob;
|
|
6723
6832
|
|
|
6724
|
-
const ENVIRONMENT = {
|
|
6725
|
-
development: "development",
|
|
6726
|
-
staging: "staging",
|
|
6727
|
-
review: "review",
|
|
6728
|
-
};
|
|
6729
|
-
const IS_STAGING_ENV = process.env.TEST_ENV === "staging";
|
|
6730
|
-
const STORAGE_STATE = "./e2e/auth/user.json";
|
|
6731
|
-
const GLOBAL_TRANSLATIONS_PATTERN = "../node_modules/@bigbinary/**/translations/en.json";
|
|
6732
|
-
const PROJECT_TRANSLATIONS_PATH = "../app/javascript/src/translations/en.json";
|
|
6733
|
-
const CREDENTIALS = { email: "oliver@example.com", password: "welcome" };
|
|
6734
|
-
|
|
6735
6833
|
const joinString = (string1, string2, string3 = "", separator = " ") => {
|
|
6736
6834
|
if (string3 === "") {
|
|
6737
6835
|
return string1 + separator + string2;
|
|
@@ -6777,111 +6875,26 @@ const readTranslations = () => {
|
|
|
6777
6875
|
return translations;
|
|
6778
6876
|
};
|
|
6779
6877
|
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
else if (await condition()) {
|
|
6801
|
-
return await callback();
|
|
6802
|
-
}
|
|
6803
|
-
return await this.recursiveMethod(callback, condition, timeout, startTime);
|
|
6804
|
-
};
|
|
6805
|
-
this.executeRecursively = async ({ callback, condition, timeout = 5000, }) => {
|
|
6806
|
-
const startTime = Date.now();
|
|
6807
|
-
await this.recursiveMethod(callback, condition, timeout, startTime);
|
|
6808
|
-
};
|
|
6809
|
-
this.verifySuccessToast = async ({ message, closeAfterVerification = true, }) => {
|
|
6810
|
-
if (message) {
|
|
6811
|
-
await expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toHaveValue(message);
|
|
6812
|
-
}
|
|
6813
|
-
else {
|
|
6814
|
-
await expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toHaveValue("👍");
|
|
6815
|
-
closeAfterVerification &&
|
|
6816
|
-
(await this.page
|
|
6817
|
-
.getByTestId(COMMON_SELECTORS.toastCloseButton)
|
|
6818
|
-
.click());
|
|
6819
|
-
}
|
|
6820
|
-
};
|
|
6821
|
-
this.reloadAndWait = async (requestCount) => {
|
|
6822
|
-
const reloadRequests = this.interceptMultipleResponses({
|
|
6823
|
-
times: requestCount,
|
|
6824
|
-
});
|
|
6825
|
-
await this.page.reload();
|
|
6826
|
-
await reloadRequests;
|
|
6827
|
-
};
|
|
6828
|
-
this.apiRequest = async ({ url, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
|
|
6829
|
-
const { headers } = readFileSyncIfExists();
|
|
6830
|
-
const requestOptions = {
|
|
6831
|
-
headers: { ...headers, ...additionalHeaders, "accept-encoding": "gzip" },
|
|
6832
|
-
data,
|
|
6833
|
-
params,
|
|
6834
|
-
...otherOptions,
|
|
6835
|
-
};
|
|
6836
|
-
return await {
|
|
6837
|
-
get: this.request.get(url, requestOptions),
|
|
6838
|
-
post: this.request.post(url, requestOptions),
|
|
6839
|
-
put: this.request.put(url, requestOptions),
|
|
6840
|
-
delete: this.request.delete(url, requestOptions),
|
|
6841
|
-
}[method.toLowerCase()];
|
|
6842
|
-
};
|
|
6843
|
-
this.verifyFieldValue = values => {
|
|
6844
|
-
const verifyEachFieldValue = ({ field, value, }) => expect(this.page.getByTestId(field)).toHaveValue(value);
|
|
6845
|
-
return Array.isArray(values)
|
|
6846
|
-
? Promise.all(values.map(value => verifyEachFieldValue(value)))
|
|
6847
|
-
: verifyEachFieldValue(values);
|
|
6848
|
-
};
|
|
6849
|
-
this.page = page;
|
|
6850
|
-
this.responses = [];
|
|
6851
|
-
this.request = request;
|
|
6852
|
-
}
|
|
6853
|
-
}
|
|
6854
|
-
|
|
6855
|
-
const commands = {
|
|
6856
|
-
neetoPlaywrightUtilities: async ({ page, request }, use) => {
|
|
6857
|
-
const commands = new CustomCommands(page, request);
|
|
6858
|
-
await use(commands);
|
|
6859
|
-
},
|
|
6860
|
-
page: async ({ page }, use) => {
|
|
6861
|
-
await page.goto("/");
|
|
6862
|
-
await page.waitForLoadState();
|
|
6863
|
-
await use(page);
|
|
6864
|
-
},
|
|
6865
|
-
};
|
|
6866
|
-
|
|
6867
|
-
const timestamp = dayjs().format("YYYYMMDDHH");
|
|
6868
|
-
const firstName = "André";
|
|
6869
|
-
const lastName = "O'Reilly";
|
|
6870
|
-
const stagingOrganization = `cypresstest-invoice-${timestamp}`;
|
|
6871
|
-
const otpBypassKey = process.env.OTP_BYPASS_KEY;
|
|
6872
|
-
const stagingData = {
|
|
6873
|
-
firstName,
|
|
6874
|
-
lastName,
|
|
6875
|
-
otp: 111111,
|
|
6876
|
-
domain: "neetoinvoice.net",
|
|
6877
|
-
currentUserName: IS_STAGING_ENV
|
|
6878
|
-
? joinString(firstName, lastName)
|
|
6879
|
-
: "Oliver Smith",
|
|
6880
|
-
businessName: stagingOrganization,
|
|
6881
|
-
subdomainName: IS_STAGING_ENV ? stagingOrganization : "spinkart",
|
|
6882
|
-
email: IS_STAGING_ENV
|
|
6883
|
-
? `cypresstest${otpBypassKey}+invoice+${timestamp}-playwright@bigbinary.com`
|
|
6884
|
-
: "oliver@example.com",
|
|
6878
|
+
const generateStagingData = (product = "invoice") => {
|
|
6879
|
+
const timestamp = dayjs().format("YYYYMMDDHH");
|
|
6880
|
+
const firstName = "André";
|
|
6881
|
+
const lastName = "O'Reilly";
|
|
6882
|
+
const otpBypassKey = process.env.OTP_BYPASS_KEY;
|
|
6883
|
+
const stagingOrganization = `cypresstest-${product}-${timestamp}`;
|
|
6884
|
+
return {
|
|
6885
|
+
firstName,
|
|
6886
|
+
lastName,
|
|
6887
|
+
otp: 111111,
|
|
6888
|
+
domain: `neeto${product}.net`,
|
|
6889
|
+
currentUserName: IS_STAGING_ENV
|
|
6890
|
+
? joinString(firstName, lastName)
|
|
6891
|
+
: CREDENTIALS.name,
|
|
6892
|
+
businessName: stagingOrganization,
|
|
6893
|
+
subdomainName: IS_STAGING_ENV ? stagingOrganization : "spinkart",
|
|
6894
|
+
email: IS_STAGING_ENV
|
|
6895
|
+
? `cypresstest${otpBypassKey}+${product}+${timestamp}-playwright@bigbinary.com`
|
|
6896
|
+
: "oliver@example.com",
|
|
6897
|
+
};
|
|
6885
6898
|
};
|
|
6886
6899
|
|
|
6887
6900
|
const i18n = {
|
|
@@ -6907,7 +6920,7 @@ const ROUTES = {
|
|
|
6907
6920
|
signup: `${BASE_URL}/signups`,
|
|
6908
6921
|
subdomainAvailability: `${BASE_URL}/subdomain_availability`,
|
|
6909
6922
|
countries: `${BASE_URL}/countries`,
|
|
6910
|
-
|
|
6923
|
+
neetoApps: `${BASE_URL}/neeto_apps`,
|
|
6911
6924
|
};
|
|
6912
6925
|
|
|
6913
6926
|
const SIGNUP_SELECTORS = {
|
|
@@ -6986,10 +6999,9 @@ class OrganizationPage {
|
|
|
6986
6999
|
await this.page.getByTestId(SIGNUP_SELECTORS.profileSubmitButton).click();
|
|
6987
7000
|
await submitProfile;
|
|
6988
7001
|
};
|
|
6989
|
-
this.setupOrganization = async () => {
|
|
7002
|
+
this.setupOrganization = async (product) => {
|
|
6990
7003
|
if (!IS_STAGING_ENV)
|
|
6991
7004
|
return;
|
|
6992
|
-
let headers = {};
|
|
6993
7005
|
const { user } = readFileSyncIfExists();
|
|
6994
7006
|
await this.createOrganization({
|
|
6995
7007
|
businessName: user.businessName,
|
|
@@ -6997,20 +7009,15 @@ class OrganizationPage {
|
|
|
6997
7009
|
firstName: user.firstName,
|
|
6998
7010
|
lastName: user.lastName,
|
|
6999
7011
|
subdomainName: user.subdomainName,
|
|
7000
|
-
appName:
|
|
7001
|
-
});
|
|
7002
|
-
await this.page.route(`**${ROUTES.neetoAps}`, async (route) => {
|
|
7003
|
-
headers = await route.request().allHeaders();
|
|
7004
|
-
await route.continue();
|
|
7012
|
+
appName: `neeto${product}`,
|
|
7005
7013
|
});
|
|
7006
7014
|
await expect(this.page.locator(COMMON_SELECTORS.spinner)).toBeHidden();
|
|
7007
7015
|
const userCredentials = readFileSyncIfExists();
|
|
7008
7016
|
await this.page.context().storageState({ path: STORAGE_STATE });
|
|
7009
|
-
const mergedCredentials =
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
};
|
|
7017
|
+
const mergedCredentials = mergeAll([
|
|
7018
|
+
readFileSyncIfExists(),
|
|
7019
|
+
userCredentials,
|
|
7020
|
+
]);
|
|
7014
7021
|
writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
|
|
7015
7022
|
};
|
|
7016
7023
|
this.updateSubdomainIfExists = async (appName) => {
|
|
@@ -7064,8 +7071,9 @@ const LOGIN_SELECTORS = {
|
|
|
7064
7071
|
|
|
7065
7072
|
const COMMON_TEXTS = { edit: "Edit" };
|
|
7066
7073
|
|
|
7067
|
-
const initializeCredentials = () => {
|
|
7074
|
+
const initializeCredentials = (product) => {
|
|
7068
7075
|
const { user } = readFileSyncIfExists();
|
|
7076
|
+
const stagingData = generateStagingData(product);
|
|
7069
7077
|
const newState = {
|
|
7070
7078
|
...user,
|
|
7071
7079
|
businessName: (user === null || user === void 0 ? void 0 : user.businessName) || stagingData.businessName,
|
|
@@ -7083,34 +7091,28 @@ const initializeCredentials = () => {
|
|
|
7083
7091
|
}
|
|
7084
7092
|
};
|
|
7085
7093
|
|
|
7086
|
-
const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, }) => {
|
|
7094
|
+
const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/", }) => {
|
|
7087
7095
|
var _a;
|
|
7088
|
-
await page.goto((_a = process.env.BASE_URL) !== null && _a !== void 0 ? _a : "");
|
|
7089
|
-
let headers = {};
|
|
7090
|
-
await page.route(`**${ROUTES.login}`, async (route) => {
|
|
7091
|
-
headers = await route.request().allHeaders();
|
|
7092
|
-
await route.continue();
|
|
7093
|
-
});
|
|
7096
|
+
await page.goto((_a = `${process.env.BASE_URL}${loginPath}`) !== null && _a !== void 0 ? _a : "");
|
|
7094
7097
|
await page.getByTestId("login-email-text-field").fill(CREDENTIALS.email);
|
|
7095
7098
|
await page
|
|
7096
7099
|
.getByTestId("login-password-text-field")
|
|
7097
7100
|
.fill(CREDENTIALS.password);
|
|
7098
7101
|
const login = neetoPlaywrightUtilities.interceptMultipleResponses({
|
|
7099
|
-
times:
|
|
7102
|
+
times: 1,
|
|
7100
7103
|
});
|
|
7101
7104
|
await page.getByTestId(LOGIN_SELECTORS.submitButton).click();
|
|
7102
7105
|
await login;
|
|
7103
7106
|
const userCredentials = readFileSyncIfExists();
|
|
7104
7107
|
await page.context().storageState({ path: STORAGE_STATE });
|
|
7105
|
-
const mergedCredentials =
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
};
|
|
7108
|
+
const mergedCredentials = mergeAll([
|
|
7109
|
+
readFileSyncIfExists(),
|
|
7110
|
+
userCredentials,
|
|
7111
|
+
]);
|
|
7110
7112
|
writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
|
|
7111
7113
|
};
|
|
7112
|
-
const login = async ({ page, neetoPlaywrightUtilities }) => !IS_STAGING_ENV &&
|
|
7113
|
-
(await loginWithoutSSO({ page, neetoPlaywrightUtilities }));
|
|
7114
|
+
const login = async ({ page, neetoPlaywrightUtilities, loginPath, }) => !IS_STAGING_ENV &&
|
|
7115
|
+
(await loginWithoutSSO({ page, neetoPlaywrightUtilities, loginPath }));
|
|
7114
7116
|
|
|
7115
7117
|
var main$1 = {exports: {}};
|
|
7116
7118
|
|
|
@@ -7560,5 +7562,5 @@ const definePlaywrightConfig = (overrides) => {
|
|
|
7560
7562
|
});
|
|
7561
7563
|
};
|
|
7562
7564
|
|
|
7563
|
-
export { COMMON_SELECTORS, COMMON_TEXTS, CREDENTIALS, CustomCommands, ENVIRONMENT, GLOBAL_TRANSLATIONS_PATTERN, IS_STAGING_ENV, LOGIN_SELECTORS, OrganizationPage, PROJECT_TRANSLATIONS_PATH, ROUTES, SIGNUP_SELECTORS, STORAGE_STATE, clearCredentials, commands, definePlaywrightConfig, i18n, initializeCredentials, joinString, login, loginWithoutSSO, readFileSyncIfExists, readTranslations,
|
|
7565
|
+
export { BASE_URL, COMMON_SELECTORS, COMMON_TEXTS, CREDENTIALS, CustomCommands, ENVIRONMENT, GLOBAL_TRANSLATIONS_PATTERN, IS_STAGING_ENV, LOGIN_SELECTORS, OrganizationPage, PROJECT_TRANSLATIONS_PATH, ROUTES, SIGNUP_SELECTORS, STORAGE_STATE, clearCredentials, commands, definePlaywrightConfig, generateStagingData, i18n, initializeCredentials, joinString, login, loginWithoutSSO, readFileSyncIfExists, readTranslations, updateCredentials, writeDataToFile };
|
|
7564
7566
|
//# sourceMappingURL=index.js.map
|