@fluxenginejp/sftest 1.3.0 → 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/LICENSE +21 -21
- package/dist/cli/sftest.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/pages/common/BrowserDialogs.d.ts +0 -8
- package/dist/pages/common/BrowserDialogs.js +10 -1
- package/dist/pages/common/DataImportWizard.d.ts +3 -19
- package/dist/pages/common/DataImportWizard.js +11 -8
- package/dist/pages/common/ElementStates.d.ts +0 -8
- package/dist/pages/common/ElementStates.js +4 -3
- package/dist/pages/common/FileRelatedListPage.d.ts +0 -6
- package/dist/pages/common/FileRelatedListPage.js +6 -4
- package/dist/pages/common/ListViewPage.d.ts +6 -9
- package/dist/pages/common/ListViewPage.js +22 -7
- package/dist/pages/common/LoginAsPage.d.ts +14 -13
- package/dist/pages/common/LoginAsPage.js +63 -8
- package/dist/pages/common/PageButtons.d.ts +0 -13
- package/dist/pages/common/PageButtons.js +14 -9
- package/dist/pages/common/PageLinks.d.ts +24 -0
- package/dist/pages/common/PageLinks.js +87 -0
- package/dist/pages/common/RecordData.js +2 -1
- package/dist/pages/common/RecordDetailPage.d.ts +48 -18
- package/dist/pages/common/RecordDetailPage.js +121 -28
- package/dist/pages/common/RecordFields.d.ts +81 -20
- package/dist/pages/common/RecordFields.js +268 -28
- package/dist/pages/common/RecordFormDialog.d.ts +0 -7
- package/dist/pages/common/RecordFormDialog.js +23 -10
- package/dist/pages/common/RecordPage.d.ts +5 -3
- package/dist/pages/common/RecordPage.js +18 -8
- package/dist/pages/common/ScreenDialog.d.ts +23 -8
- package/dist/pages/common/ScreenDialog.js +80 -3
- package/dist/pages/common/fieldSections.d.ts +53 -0
- package/dist/pages/common/fieldSections.js +89 -0
- package/dist/pages/common/listViewPicker.d.ts +0 -5
- package/dist/pages/common/listViewPicker.js +3 -2
- package/dist/pages/common/relatedLists.d.ts +0 -5
- package/dist/pages/common/relatedLists.js +2 -1
- package/dist/pages/common/saveErrors.d.ts +0 -10
- package/dist/pages/common/saveErrors.js +2 -3
- package/dist/steps/common/apex.steps.js +6 -2
- package/dist/steps/common/button.steps.js +14 -8
- package/dist/steps/common/common.steps.js +33 -20
- package/dist/steps/common/dialog.steps.js +29 -9
- package/dist/steps/common/file.steps.js +18 -12
- package/dist/steps/common/import.steps.js +22 -5
- package/dist/steps/common/record.steps.js +18 -6
- package/dist/steps/common/state.steps.js +2 -0
- package/dist/steps/common/window.steps.d.ts +1 -0
- package/dist/steps/common/window.steps.js +35 -0
- package/dist/support/FileDownloads.d.ts +0 -6
- package/dist/support/FileDownloads.js +8 -1
- package/dist/support/UploadErrors.d.ts +0 -6
- package/dist/support/UploadErrors.js +15 -7
- package/dist/support/activePages.d.ts +89 -0
- package/dist/support/activePages.js +182 -0
- package/dist/support/apexBatch.js +6 -6
- package/dist/support/consoleReporter.d.ts +142 -0
- package/dist/support/consoleReporter.js +381 -0
- package/dist/support/executionControl.d.ts +102 -0
- package/dist/support/executionControl.js +275 -0
- package/dist/support/fileInputs.js +7 -4
- package/dist/support/fixtures.d.ts +62 -66
- package/dist/support/fixtures.js +87 -47
- package/dist/support/globalSetup.js +30 -20
- package/dist/support/loginState.d.ts +31 -0
- package/dist/support/loginState.js +26 -0
- package/dist/support/mismatch.d.ts +7 -0
- package/dist/support/mismatch.js +22 -9
- package/dist/support/operationTargets.d.ts +22 -0
- package/dist/support/operationTargets.js +26 -0
- package/dist/support/playwrightConfig.d.ts +5 -13
- package/dist/support/playwrightConfig.js +11 -2
- package/dist/support/settings.d.ts +4 -0
- package/dist/support/settings.js +61 -21
- package/dist/support/sf.d.ts +14 -0
- package/dist/support/sf.js +89 -4
- package/dist/support/sobjects.js +5 -4
- package/dist/support/stepArguments.d.ts +38 -0
- package/dist/support/stepArguments.js +74 -0
- package/docs/CHANGELOG.md +209 -169
- package/docs/EXTENSIONS.html +540 -0
- package/docs/SPEC.html +5761 -1490
- package/package.json +82 -81
- package/readme.md +95 -96
- package/sftest.config.jsonc +5 -0
- package/templates/env +8 -8
- package/templates/gitignore +7 -7
- package/templates/playwright.config.ts +17 -17
- package/templates/vscode-settings.json +4 -4
package/dist/support/fixtures.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fieldValues = exports.Then = exports.StandardThen = exports.
|
|
3
|
+
exports.fieldValues = exports.Then = exports.StandardThen = exports.When = exports.Given = exports.BeforeStep = exports.test = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* フィクスチャ(ステップから使う部品)を登録し、ステップ定義で使う Given・When・Then・BeforeStep を提供する。
|
|
6
6
|
*
|
|
@@ -20,17 +20,20 @@ const FileRelatedListPage_1 = require("../pages/common/FileRelatedListPage");
|
|
|
20
20
|
const ListViewPage_1 = require("../pages/common/ListViewPage");
|
|
21
21
|
const LoginAsPage_1 = require("../pages/common/LoginAsPage");
|
|
22
22
|
const PageButtons_1 = require("../pages/common/PageButtons");
|
|
23
|
+
const PageLinks_1 = require("../pages/common/PageLinks");
|
|
23
24
|
const RecordData_1 = require("../pages/common/RecordData");
|
|
24
25
|
const RecordDetailPage_1 = require("../pages/common/RecordDetailPage");
|
|
25
26
|
const RecordFormDialog_1 = require("../pages/common/RecordFormDialog");
|
|
26
27
|
const RecordPage_1 = require("../pages/common/RecordPage");
|
|
27
28
|
const saveErrors_1 = require("../pages/common/saveErrors");
|
|
28
29
|
const ScreenDialog_1 = require("../pages/common/ScreenDialog");
|
|
30
|
+
const activePages_1 = require("./activePages");
|
|
29
31
|
const createdRecords_1 = require("./createdRecords");
|
|
30
32
|
const evidenceId_1 = require("./evidenceId");
|
|
31
33
|
const FileDownloads_1 = require("./FileDownloads");
|
|
32
34
|
const UploadErrors_1 = require("./UploadErrors");
|
|
33
35
|
const mismatch_1 = require("./mismatch");
|
|
36
|
+
const executionControl_1 = require("./executionControl");
|
|
34
37
|
const startupTiming_1 = require("./startupTiming");
|
|
35
38
|
// SFTEST_STARTUP_TIMING=1 の場合、ワーカー以外のプロセス(BDD の生成・テストの探索)とワーカー(シナリオの実行の準備)がステップ定義を読み込んだ時点を表示する。
|
|
36
39
|
(0, startupTiming_1.startupNote)(process.env.TEST_WORKER_INDEX ? 'ステップ定義の読み込み(ワーカーの準備)' : 'ステップ定義の読み込み(BDD の生成・テストの探索)');
|
|
@@ -40,6 +43,15 @@ const startupTiming_1 = require("./startupTiming");
|
|
|
40
43
|
* フィクスチャはシナリオごとに作成され、同じシナリオの中では共有される。
|
|
41
44
|
*/
|
|
42
45
|
exports.test = playwright_bdd_1.test.extend({
|
|
46
|
+
/**
|
|
47
|
+
* シナリオの画面。ステップの部品には、呼び出しのたびにアクティブな画面(新しく開いたタブ・ウィンドウ。閉じた後は開いた元の画面)へ
|
|
48
|
+
* 処理を渡す代理の Page を渡す(20261016-011。support/activePages.ts)。新しい画面を開かない操作の動作は変わらない。
|
|
49
|
+
*/
|
|
50
|
+
page: async ({ page }, use) => {
|
|
51
|
+
await use(new activePages_1.ActivePages(page).page);
|
|
52
|
+
},
|
|
53
|
+
/** アクティブな画面をたどる部品(新しい画面が開くのを待つステップで使う)。 */
|
|
54
|
+
activePages: async ({ page }, use) => { await use((0, activePages_1.activePagesOf)(page)); },
|
|
43
55
|
/**
|
|
44
56
|
* Salesforce のアプリケーション内ガイダンス(新機能の案内などのポップアップ)が表示されたら閉じる(全シナリオで自動)。
|
|
45
57
|
*
|
|
@@ -100,8 +112,10 @@ exports.test = playwright_bdd_1.test.extend({
|
|
|
100
112
|
contentType: 'text/plain',
|
|
101
113
|
});
|
|
102
114
|
const failed = results.filter((r) => r.error);
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
(0, executionControl_1.runRequired)('scenario-teardown', () => {
|
|
116
|
+
if (failed.length)
|
|
117
|
+
throw new executionControl_1.ExecutionFailure('runtime-error', `テストデータの片付けに失敗しました: ${failed.map((r) => `${r.sobject} ${r.id}`).join(', ')}`);
|
|
118
|
+
});
|
|
105
119
|
},
|
|
106
120
|
/**
|
|
107
121
|
* 保存エラー(入力規則など)を記録する。
|
|
@@ -113,9 +127,11 @@ exports.test = playwright_bdd_1.test.extend({
|
|
|
113
127
|
saveErrors: async ({ evidence }, use, testInfo) => {
|
|
114
128
|
const saveErrors = new saveErrors_1.SaveErrors(testInfo, evidence);
|
|
115
129
|
await use(saveErrors);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
130
|
+
(0, executionControl_1.runRequired)('scenario-teardown', () => {
|
|
131
|
+
if (saveErrors.pendingMessage && shouldJudgeLeftovers(testInfo)) {
|
|
132
|
+
throw new executionControl_1.ExecutionFailure('scenario-invalid', `保存エラーが修正されないままシナリオが終了しました: ${saveErrors.pendingMessage}`);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
119
135
|
},
|
|
120
136
|
/** ダウンロードの保存・確認結果をシナリオ単位で保持する。 */
|
|
121
137
|
fileDownloads: async ({ evidenceDir, evidenceId }, use, testInfo) => {
|
|
@@ -130,8 +146,11 @@ exports.test = playwright_bdd_1.test.extend({
|
|
|
130
146
|
// 実際がpassedかで判定し、expectedStatus(@failではfailed)との一致は使わない。
|
|
131
147
|
// ステップがすでに中断で失敗した場合は、その失敗理由を終了時の検査で上書きしない。検査の不一致を記録して続けた
|
|
132
148
|
// シナリオは、中断していなければ判定する(20261013-002)。
|
|
133
|
-
|
|
134
|
-
|
|
149
|
+
(0, executionControl_1.runRequired)('scenario-teardown', () => {
|
|
150
|
+
if (problem && (testInfo.status === 'passed' || ((0, mismatch_1.mismatchCount)(testInfo) > 0 && !(0, mismatch_1.wasInterrupted)(testInfo)))) {
|
|
151
|
+
throw new executionControl_1.ExecutionFailure('scenario-invalid', problem);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
135
154
|
},
|
|
136
155
|
/** 標準のファイル関連リスト。新規文書・取得結果・画面エラーを同じシナリオへ記録する。 */
|
|
137
156
|
fileRelatedList: async ({ page, createdRecords, fileDownloads, uploadErrors }, use) => {
|
|
@@ -148,8 +167,10 @@ exports.test = playwright_bdd_1.test.extend({
|
|
|
148
167
|
const browserDialogs = new BrowserDialogs_1.BrowserDialogs(page, testInfo);
|
|
149
168
|
await use(browserDialogs);
|
|
150
169
|
const problem = browserDialogs.remainingProblem();
|
|
151
|
-
|
|
152
|
-
|
|
170
|
+
(0, executionControl_1.runRequired)('scenario-teardown', () => {
|
|
171
|
+
if (problem && shouldJudgeLeftovers(testInfo))
|
|
172
|
+
throw new executionControl_1.ExecutionFailure('scenario-invalid', problem);
|
|
173
|
+
});
|
|
153
174
|
},
|
|
154
175
|
{ auto: true },
|
|
155
176
|
],
|
|
@@ -157,6 +178,8 @@ exports.test = playwright_bdd_1.test.extend({
|
|
|
157
178
|
screenDialog: async ({ page }, use) => { await use(new ScreenDialog_1.ScreenDialog(page)); },
|
|
158
179
|
/** 画面のボタンを名前で押下する部品。 */
|
|
159
180
|
pageButtons: async ({ page }, use) => { await use(new PageButtons_1.PageButtons(page)); },
|
|
181
|
+
/** アクティブな画面のリンクを名前で押下する部品。 */
|
|
182
|
+
pageLinks: async ({ activePages }, use) => { await use(new PageLinks_1.PageLinks(activePages)); },
|
|
160
183
|
/** データインポートウィザード。新規追加したレコードを createdRecords に記録する。 */
|
|
161
184
|
dataImportWizard: async ({ page, createdRecords }, use) => { await use(new DataImportWizard_1.DataImportWizard(page, createdRecords)); },
|
|
162
185
|
/** データ(SOQL)での値の確認。 */
|
|
@@ -194,7 +217,8 @@ exports.test = playwright_bdd_1.test.extend({
|
|
|
194
217
|
/**
|
|
195
218
|
* シナリオの終了時に、未処理の保存エラー・ブラウザのダイアログを判定するかを返す(20261013-002)。
|
|
196
219
|
*
|
|
197
|
-
* 従来どおり、結果が期待どおり(通常は成功、@fail
|
|
220
|
+
* 従来どおり、結果が期待どおり(通常は成功、@fail では失敗)の場合に判定する。加えて、ステップが最後まで通った場合は、
|
|
221
|
+
* @fail のシナリオでも判定する(ほかに失敗がないため。アップロードエラーの判定と同じ。20261015-010)。検査の不一致を記録して続けた
|
|
198
222
|
* シナリオは、中断していなければ判定する。中断(例外)で終わった場合は、元の失敗の原因を残すため判定しない。
|
|
199
223
|
*
|
|
200
224
|
* @param testInfo - シナリオの TestInfo。
|
|
@@ -203,41 +227,55 @@ exports.test = playwright_bdd_1.test.extend({
|
|
|
203
227
|
function shouldJudgeLeftovers(testInfo) {
|
|
204
228
|
if ((0, mismatch_1.wasInterrupted)(testInfo))
|
|
205
229
|
return false;
|
|
206
|
-
return testInfo.status === testInfo.expectedStatus || (0, mismatch_1.mismatchCount)(testInfo) > 0;
|
|
230
|
+
return testInfo.status === 'passed' || testInfo.status === testInfo.expectedStatus || (0, mismatch_1.mismatchCount)(testInfo) > 0;
|
|
207
231
|
}
|
|
208
232
|
/** sfTest のフィクスチャを使うステップ定義・フックの登録関数。 */
|
|
209
233
|
const bdd = (0, playwright_bdd_1.createBdd)(exports.test);
|
|
210
|
-
({
|
|
234
|
+
({ BeforeStep: exports.BeforeStep } = bdd);
|
|
235
|
+
exports.Given = controlledDefinition(bdd.Given, false);
|
|
236
|
+
exports.When = controlledDefinition(bdd.When, false);
|
|
211
237
|
/**
|
|
212
|
-
* sfTest
|
|
213
|
-
*
|
|
238
|
+
* sfTestの検査ステップを定義する。明示的に通知された分類へ共通方針を適用する。
|
|
239
|
+
* 操作の準備にもexpectを使うため、素のexpect例外を自動でNGとはしない。
|
|
214
240
|
*/
|
|
215
|
-
exports.StandardThen = bdd.Then;
|
|
241
|
+
exports.StandardThen = controlledDefinition(bdd.Then, false);
|
|
216
242
|
/**
|
|
217
|
-
* 利用者が作るステップを定義する
|
|
243
|
+
* 利用者が作るステップを定義するThen。素のexpectの失敗をNGとして受け取る既存の契約を維持する。
|
|
218
244
|
*
|
|
219
245
|
* 利用者の関数を包み、Playwright の expect の失敗(期待と異なる値)は不一致として記録して後続のステップへ進み、
|
|
220
|
-
*
|
|
246
|
+
* 明示的に分類された例外をexpectの失敗へ戻さず、それ以外の例外は実行時エラーとして扱う。
|
|
221
247
|
* playwright-bdd は、関数の文字列(toString)からフィクスチャの名前を、関数の引数の数(length)をステップの文言の引数の数と照合するため、
|
|
222
248
|
* 包む関数のこの2つを元の関数に合わせる(playwright-bdd の更新の際は、この照合の方法が変わっていないことを確かめる)。
|
|
223
249
|
* ステップの定義の位置は、この関数の行として登録される(元の例外の呼び出し履歴には利用者の行が残る)。
|
|
224
250
|
*/
|
|
225
|
-
exports.Then = (
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
251
|
+
exports.Then = controlledDefinition(bdd.Then, true);
|
|
252
|
+
/**
|
|
253
|
+
* 登録関数を包み、利用者の関数のfixture検出・引数数を維持して共通方針へ接続する。
|
|
254
|
+
*
|
|
255
|
+
* @param define - playwright-bddの登録関数。
|
|
256
|
+
* @param acceptsExpectNg - 素のexpectの失敗をNGとして受け取る既存の互換指定。方針の切替ではない。
|
|
257
|
+
* @returns 元の登録関数と同じ型の登録関数。
|
|
258
|
+
*/
|
|
259
|
+
function controlledDefinition(define, acceptsExpectNg) {
|
|
260
|
+
return ((...args) => {
|
|
261
|
+
const fn = args[args.length - 1];
|
|
262
|
+
const wrapped = async function (...fnArgs) {
|
|
263
|
+
await (0, executionControl_1.runControlled)('step', async () => {
|
|
264
|
+
try {
|
|
265
|
+
await fn.apply(this, fnArgs);
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
if (acceptsExpectNg && (0, mismatch_1.isExpectFailure)(error))
|
|
269
|
+
throw new executionControl_1.ExecutionFailure('test-ng', error.message, { cause: error });
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
}, mismatch_1.recordNgResult);
|
|
273
|
+
};
|
|
274
|
+
wrapped.toString = () => fn.toString();
|
|
275
|
+
Object.defineProperty(wrapped, 'length', { value: fn.length });
|
|
276
|
+
return define(...args.slice(0, -1), wrapped);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
241
279
|
/**
|
|
242
280
|
* 各ステップの前に、保存・アップロードエラーとブラウザ標準のダイアログの状態を確認する。
|
|
243
281
|
*
|
|
@@ -246,19 +284,21 @@ exports.Then = ((...args) => {
|
|
|
246
284
|
* 「ID」のステップは何も操作しないため対象外とする(保存エラーと修正の間や、ダイアログの指示とボタンの間に書いてもよい)。
|
|
247
285
|
*/
|
|
248
286
|
(0, exports.BeforeStep)(async ({ $step, saveErrors, browserDialogs, uploadErrors }) => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
287
|
+
await (0, executionControl_1.runControlled)('step', async () => {
|
|
288
|
+
// SFTEST_STARTUP_TIMING=1 の場合、このプロセスの最初のステップの開始を表示し、以後は表示しない。
|
|
289
|
+
(0, startupTiming_1.finishStartupTiming)('最初のステップの開始');
|
|
290
|
+
if (/^ID "/.test($step.title))
|
|
291
|
+
return;
|
|
292
|
+
const uploadProblem = uploadErrors.checkBeforeStep($step.title);
|
|
293
|
+
if (uploadProblem)
|
|
294
|
+
throw new executionControl_1.ExecutionFailure('scenario-invalid', uploadProblem);
|
|
295
|
+
const dialogProblem = browserDialogs.checkBeforeStep();
|
|
296
|
+
if (dialogProblem)
|
|
297
|
+
throw new executionControl_1.ExecutionFailure('scenario-invalid', dialogProblem);
|
|
298
|
+
if (saveErrors.pendingMessage && !(0, saveErrors_1.handlesSaveError)($step.title)) {
|
|
299
|
+
throw new executionControl_1.ExecutionFailure('scenario-invalid', `保存エラーが出たままです。「${saveErrors_1.FIX_STEP}」で修正するか、保存エラーになるのが正しい場合は「保存エラー "…" が表示される」で確認してください: ${saveErrors.pendingMessage}`);
|
|
300
|
+
}
|
|
301
|
+
}, mismatch_1.recordNgResult);
|
|
262
302
|
});
|
|
263
303
|
/**
|
|
264
304
|
* シナリオの表(| 項目 | 値 |)を、項目ラベルと値の組に変換する。
|
|
@@ -4,6 +4,7 @@ exports.default = globalSetup;
|
|
|
4
4
|
const session_1 = require("./session");
|
|
5
5
|
const sf_1 = require("./sf");
|
|
6
6
|
const startupTiming_1 = require("./startupTiming");
|
|
7
|
+
const executionControl_1 = require("./executionControl");
|
|
7
8
|
/**
|
|
8
9
|
* ログインしてセッションを保存し、テスト全体の終了後に実行する削除処理を返す。
|
|
9
10
|
*
|
|
@@ -12,24 +13,33 @@ const startupTiming_1 = require("./startupTiming");
|
|
|
12
13
|
* @throws baseURL が設定されていない場合、またはログインに失敗した場合(失敗した場合は、残っているセッションファイルを削除してから失敗する)。
|
|
13
14
|
*/
|
|
14
15
|
async function globalSetup(config) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
// 開始・終了工程ではNGによる継続を許さないため、この記録先には到達しない。
|
|
17
|
+
const noNg = (failure) => { throw failure; };
|
|
18
|
+
await (0, executionControl_1.runControlled)('test-setup', async () => {
|
|
19
|
+
const baseURL = config.projects[0]?.use.baseURL;
|
|
20
|
+
if (!baseURL)
|
|
21
|
+
throw new executionControl_1.ExecutionFailure('scenario-invalid', 'SF_BASE_URL が設定されていません。プロジェクト直下の .env に書いてください');
|
|
22
|
+
// 今回の実行の ID を決める。強制終了などで残った前回の接続情報(組織や CLI のユーザが今と異なる可能性がある)は使わない。
|
|
23
|
+
(0, sf_1.startConnectionRun)();
|
|
24
|
+
(0, startupTiming_1.startStartupClock)();
|
|
25
|
+
(0, startupTiming_1.startupNote)('前処理(ログイン)の開始');
|
|
26
|
+
try {
|
|
27
|
+
await (0, session_1.saveSession)(baseURL);
|
|
28
|
+
// ログインで取得した接続情報を保存し、シナリオを実行するプロセスが sf を呼ばずに使えるようにする。
|
|
29
|
+
(0, sf_1.saveConnection)();
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
(0, startupTiming_1.finishStartupTiming)('前処理(ログイン)の失敗');
|
|
33
|
+
// 終了時の後処理は実行されないため、前回の実行で残ったファイルを含めてここで削除する。
|
|
34
|
+
try {
|
|
35
|
+
await (0, session_1.removeSession)();
|
|
36
|
+
}
|
|
37
|
+
catch (cleanup) {
|
|
38
|
+
throw new executionControl_1.ExecutionFailure('runtime-error', '前処理とセッションの削除に失敗しました', { cause: new AggregateError([e, cleanup], '前処理・後処理の原因') });
|
|
39
|
+
}
|
|
40
|
+
throw e;
|
|
41
|
+
}
|
|
42
|
+
(0, startupTiming_1.finishStartupTiming)('前処理(ログイン)の終了');
|
|
43
|
+
}, noNg);
|
|
44
|
+
return async () => { await (0, executionControl_1.runControlled)('test-teardown', session_1.removeSession, noNg); };
|
|
35
45
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ログインの状態(管理者か、だれに代理ログインしているか)を、シナリオの画面(Page)ごとに記録する(20261018-003)。
|
|
3
|
+
*
|
|
4
|
+
* 代理ログインできていても、Salesforce が画面上部の「〇〇 (ユーザ名) でログインしています」バナーを表示しないことがある。
|
|
5
|
+
* そのため、代理ログイン中かをバナーだけで判断せず、ログイン・代理ログインのステップが確かめた結果を、後続の画面の処理(一覧を開くなど)でも使う。
|
|
6
|
+
*
|
|
7
|
+
* @author Fluxengine.co.jp
|
|
8
|
+
*/
|
|
9
|
+
import { Page } from '@playwright/test';
|
|
10
|
+
/** ログインの状態。admin は Salesforce CLI のユーザ(システム管理者)、proxy は代理ログイン中。 */
|
|
11
|
+
export type LoginState = {
|
|
12
|
+
kind: 'admin';
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'proxy';
|
|
15
|
+
username: string;
|
|
16
|
+
userId: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* 画面のログインの状態を記録する。
|
|
20
|
+
*
|
|
21
|
+
* @param page - シナリオの画面。
|
|
22
|
+
* @param state - 確かめたログインの状態。undefined の場合は記録を消す(後続の判断はバナーに戻る)。
|
|
23
|
+
*/
|
|
24
|
+
export declare function setLoginState(page: Page, state: LoginState | undefined): void;
|
|
25
|
+
/**
|
|
26
|
+
* 画面のログインの状態を返す。ログイン・代理ログインのステップをまだ実行していない場合は undefined。
|
|
27
|
+
*
|
|
28
|
+
* @param page - シナリオの画面。
|
|
29
|
+
* @returns 記録したログインの状態。
|
|
30
|
+
*/
|
|
31
|
+
export declare function loginState(page: Page): LoginState | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setLoginState = setLoginState;
|
|
4
|
+
exports.loginState = loginState;
|
|
5
|
+
const states = new WeakMap();
|
|
6
|
+
/**
|
|
7
|
+
* 画面のログインの状態を記録する。
|
|
8
|
+
*
|
|
9
|
+
* @param page - シナリオの画面。
|
|
10
|
+
* @param state - 確かめたログインの状態。undefined の場合は記録を消す(後続の判断はバナーに戻る)。
|
|
11
|
+
*/
|
|
12
|
+
function setLoginState(page, state) {
|
|
13
|
+
if (state)
|
|
14
|
+
states.set(page, state);
|
|
15
|
+
else
|
|
16
|
+
states.delete(page);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 画面のログインの状態を返す。ログイン・代理ログインのステップをまだ実行していない場合は undefined。
|
|
20
|
+
*
|
|
21
|
+
* @param page - シナリオの画面。
|
|
22
|
+
* @returns 記録したログインの状態。
|
|
23
|
+
*/
|
|
24
|
+
function loginState(page) {
|
|
25
|
+
return states.get(page);
|
|
26
|
+
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @author Fluxengine.co.jp
|
|
9
9
|
*/
|
|
10
10
|
import { Locator, TestInfo } from '@playwright/test';
|
|
11
|
+
import { ExecutionFailure } from './executionControl';
|
|
11
12
|
/**
|
|
12
13
|
* 検査の不一致を記録する。例外は投げず、シナリオの後続のステップを続ける。
|
|
13
14
|
*
|
|
@@ -15,6 +16,12 @@ import { Locator, TestInfo } from '@playwright/test';
|
|
|
15
16
|
* @returns 戻り値なし。記録した時点で終わる。
|
|
16
17
|
*/
|
|
17
18
|
export declare function recordMismatch(message: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* 共通方針から渡されたNGをPlaywrightの実行結果へ記録する。
|
|
21
|
+
*
|
|
22
|
+
* @param failure - 記録するNG。継続・中断の判断は呼出元の共通方針が担う。
|
|
23
|
+
*/
|
|
24
|
+
export declare function recordNgResult(failure: ExecutionFailure): void;
|
|
18
25
|
/**
|
|
19
26
|
* Playwright の expect の失敗(期待と異なる値)の例外かを返す。expect の失敗の例外には matcherResult が付く。
|
|
20
27
|
*
|
package/dist/support/mismatch.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.recordMismatch = recordMismatch;
|
|
4
|
+
exports.recordNgResult = recordNgResult;
|
|
4
5
|
exports.isExpectFailure = isExpectFailure;
|
|
5
6
|
exports.continueOnMismatch = continueOnMismatch;
|
|
6
7
|
exports.becomesVisible = becomesVisible;
|
|
@@ -17,6 +18,7 @@ exports.wasInterrupted = wasInterrupted;
|
|
|
17
18
|
* @author Fluxengine.co.jp
|
|
18
19
|
*/
|
|
19
20
|
const test_1 = require("@playwright/test");
|
|
21
|
+
const executionControl_1 = require("./executionControl");
|
|
20
22
|
/** シナリオ(TestInfo)ごとの、記録した不一致の数。終了時の判定で「中断で終わったか」を見分けるために使う。 */
|
|
21
23
|
const recordedCounts = new WeakMap();
|
|
22
24
|
/** 記録した不一致を、渡したメッセージだけで表示する独自の判定(常に不一致)。 */
|
|
@@ -38,9 +40,17 @@ const sfExpect = test_1.expect.extend({
|
|
|
38
40
|
* @returns 戻り値なし。記録した時点で終わる。
|
|
39
41
|
*/
|
|
40
42
|
function recordMismatch(message) {
|
|
43
|
+
(0, executionControl_1.applyFailure)(new executionControl_1.ExecutionFailure('test-ng', message), 'step', recordNgResult);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 共通方針から渡されたNGをPlaywrightの実行結果へ記録する。
|
|
47
|
+
*
|
|
48
|
+
* @param failure - 記録するNG。継続・中断の判断は呼出元の共通方針が担う。
|
|
49
|
+
*/
|
|
50
|
+
function recordNgResult(failure) {
|
|
41
51
|
const testInfo = test_1.test.info();
|
|
42
52
|
recordedCounts.set(testInfo, (recordedCounts.get(testInfo) ?? 0) + 1);
|
|
43
|
-
sfExpect.soft(message).toBeRecordedMismatch();
|
|
53
|
+
sfExpect.soft(failure.message).toBeRecordedMismatch();
|
|
44
54
|
}
|
|
45
55
|
/**
|
|
46
56
|
* Playwright の expect の失敗(期待と異なる値)の例外かを返す。expect の失敗の例外には matcherResult が付く。
|
|
@@ -49,7 +59,8 @@ function recordMismatch(message) {
|
|
|
49
59
|
* @returns expect の失敗なら true。
|
|
50
60
|
*/
|
|
51
61
|
function isExpectFailure(error) {
|
|
52
|
-
|
|
62
|
+
// 実行時エラーにも診断用のmatcherResultが残るため、明示的な分類を最優先する。
|
|
63
|
+
return !(0, executionControl_1.isExecutionFailure)(error) && error instanceof Error && 'matcherResult' in error;
|
|
53
64
|
}
|
|
54
65
|
/**
|
|
55
66
|
* 検査で、期待と異なる値の例外(expect の失敗)だけを不一致として記録して続け、それ以外の例外は投げ直す(中断する)。
|
|
@@ -59,14 +70,16 @@ function isExpectFailure(error) {
|
|
|
59
70
|
* @throws expect の失敗以外の例外(対象を特定できない、操作の失敗など)。
|
|
60
71
|
*/
|
|
61
72
|
async function continueOnMismatch(check) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
await (0, executionControl_1.runControlled)('step', async () => {
|
|
74
|
+
try {
|
|
75
|
+
await check();
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (isExpectFailure(error))
|
|
79
|
+
throw new executionControl_1.ExecutionFailure('test-ng', error.message, { cause: error });
|
|
67
80
|
throw error;
|
|
68
|
-
|
|
69
|
-
}
|
|
81
|
+
}
|
|
82
|
+
}, recordNgResult);
|
|
70
83
|
}
|
|
71
84
|
/**
|
|
72
85
|
* 要素が表示されるまで待ち、制限時間内に表示されなければ false を返す(20261013-002)。
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 入力・押下する対象を画面で確かめる expect の不成立を、シナリオ不正として通知する(20261018-009。PO の案B)。
|
|
3
|
+
*
|
|
4
|
+
* 入力・押下する対象(項目・ボタン・リンク・関連リストなど)が画面にない場合や、複数あって1つに特定できない場合は、
|
|
5
|
+
* 画面側に原因があってもシナリオ不正とする(利用者向け仕様書 4.3)。画面を開けない・読み込みが終わらない・選べないなど、
|
|
6
|
+
* 操作が完了しない場合は対象にしない(実行時エラーのまま)。
|
|
7
|
+
*
|
|
8
|
+
* @author Fluxengine.co.jp
|
|
9
|
+
*/
|
|
10
|
+
import type { Page } from '@playwright/test';
|
|
11
|
+
/**
|
|
12
|
+
* 対象を確かめる expect を実行し、不成立ならシナリオ不正として投げ直す。
|
|
13
|
+
*
|
|
14
|
+
* ページが閉じている場合は、対象がないのではなく画面を読み取れないため、元の例外のまま投げる(実行時エラー)。
|
|
15
|
+
* expect の不成立以外の例外(ページの終了など)も、元の例外のまま投げる。
|
|
16
|
+
*
|
|
17
|
+
* @param page - 対象を探す画面。閉じているかの判定に使う。
|
|
18
|
+
* @param check - 対象を確かめる expect(例: `() => expect(input, '項目 "…" が入力画面にありません').toHaveCount(1)`)。
|
|
19
|
+
* @returns 戻り値なし。対象を確かめた時点で解決する。
|
|
20
|
+
* @throws 対象を確かめられない場合(シナリオ不正)、またはそれ以外の失敗(元の例外)。
|
|
21
|
+
*/
|
|
22
|
+
export declare function requireTarget(page: Page, check: () => Promise<void>): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requireTarget = requireTarget;
|
|
4
|
+
const executionControl_1 = require("./executionControl");
|
|
5
|
+
const mismatch_1 = require("./mismatch");
|
|
6
|
+
/**
|
|
7
|
+
* 対象を確かめる expect を実行し、不成立ならシナリオ不正として投げ直す。
|
|
8
|
+
*
|
|
9
|
+
* ページが閉じている場合は、対象がないのではなく画面を読み取れないため、元の例外のまま投げる(実行時エラー)。
|
|
10
|
+
* expect の不成立以外の例外(ページの終了など)も、元の例外のまま投げる。
|
|
11
|
+
*
|
|
12
|
+
* @param page - 対象を探す画面。閉じているかの判定に使う。
|
|
13
|
+
* @param check - 対象を確かめる expect(例: `() => expect(input, '項目 "…" が入力画面にありません').toHaveCount(1)`)。
|
|
14
|
+
* @returns 戻り値なし。対象を確かめた時点で解決する。
|
|
15
|
+
* @throws 対象を確かめられない場合(シナリオ不正)、またはそれ以外の失敗(元の例外)。
|
|
16
|
+
*/
|
|
17
|
+
async function requireTarget(page, check) {
|
|
18
|
+
try {
|
|
19
|
+
await check();
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if ((0, mismatch_1.isExpectFailure)(error) && !page.isClosed())
|
|
23
|
+
throw (0, executionControl_1.withCategory)('scenario-invalid', error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Playwright と playwright-bdd の共通の設定を作る。
|
|
3
|
-
*
|
|
4
|
-
* 利用者の作業フォルダの設定(sftest init で配置する playwright.config.ts)、開発元の利用者用サンプルの設定(playwright.config.ts)、
|
|
5
|
-
* 内部検証用の設定(develop/tests/playwright.config.ts)から使う。
|
|
6
|
-
* シナリオ・設定・生成したテストコードは、作業フォルダ(コマンドを実行するフォルダ)を基準にする。
|
|
7
|
-
* テストの出力(成果物・レポート・結果・エビデンス・認証状態)は、出力の基準フォルダ(省略時は作業フォルダ。support/outputPaths.ts)を基準にする。
|
|
8
|
-
* 標準のステップ定義・フィクスチャ・テスト全体の前後処理(ログインとセッションの削除)は、ツール本体(このファイルがあるパッケージ)から読み込む。
|
|
9
|
-
* 制限時間は sftest.config.jsonc で変えられる(support/settings.ts)。
|
|
10
|
-
* テストデータが衝突しないよう、workers: 1(直列実行)に設定する。
|
|
11
|
-
*
|
|
12
|
-
* @author Fluxengine.co.jp
|
|
13
|
-
*/
|
|
14
1
|
import 'dotenv/config';
|
|
15
2
|
import { PlaywrightTestConfig } from '@playwright/test';
|
|
16
3
|
import type { RecordPageClass } from '../pages/common/RecordPage';
|
|
@@ -32,6 +19,11 @@ export interface SfTestConfigOptions {
|
|
|
32
19
|
* 省略時は作業フォルダ(利用者の既定)。開発元の内部検証が develop/tests/output を指定するための開発用の指定であり、利用者向けの仕様書には載せない(20261012-006)。
|
|
33
20
|
*/
|
|
34
21
|
outputDir?: string;
|
|
22
|
+
/**
|
|
23
|
+
* 実行の最後に示す、詳しい結果(HTML レポート)を開くコマンド。省略時は npx sftest report。
|
|
24
|
+
* 開発元の内部検証が npm run report:dev を示すための開発用の指定であり、利用者向けの仕様書には載せない(20261015-011)。
|
|
25
|
+
*/
|
|
26
|
+
reportCommand?: string;
|
|
35
27
|
}
|
|
36
28
|
/**
|
|
37
29
|
* sfTest の Playwright の設定を作る。
|
|
@@ -17,6 +17,7 @@ exports.sfTestConfig = sfTestConfig;
|
|
|
17
17
|
*
|
|
18
18
|
* @author Fluxengine.co.jp
|
|
19
19
|
*/
|
|
20
|
+
const executionControl_1 = require("./executionControl");
|
|
20
21
|
require("dotenv/config");
|
|
21
22
|
const test_1 = require("@playwright/test");
|
|
22
23
|
const playwright_bdd_1 = require("playwright-bdd");
|
|
@@ -66,7 +67,7 @@ function sfTestConfig(options) {
|
|
|
66
67
|
// .env の設定値を確認する。設定されていなければ、テストを始める前にエラーにする。
|
|
67
68
|
const missing = ['SF_ORG_ALIAS', 'SF_BASE_URL'].filter((name) => !process.env[name]);
|
|
68
69
|
if (missing.length) {
|
|
69
|
-
throw new
|
|
70
|
+
throw new executionControl_1.ExecutionFailure('scenario-invalid', `${missing.join('、')} が設定されていません。プロジェクト直下の .env に書いてください`);
|
|
70
71
|
}
|
|
71
72
|
// テストの出力の基準フォルダを決め、環境変数でテスト全体の前後処理とワーカーに引き継ぐ(support/outputPaths.ts)。
|
|
72
73
|
// 設定ファイルは実行の最初と各ワーカーで読み込まれ、どちらも同じ指定から同じ値を設定する。
|
|
@@ -98,7 +99,12 @@ function sfTestConfig(options) {
|
|
|
98
99
|
expect: { timeout: (0, settings_1.timeoutMs)('expect') },
|
|
99
100
|
workers: 1,
|
|
100
101
|
outputDir: (0, outputPaths_1.outputPath)('test-results'),
|
|
101
|
-
|
|
102
|
+
// 実行中の経過は、ステップごとに1行ずつ表示する(support/consoleReporter.ts。20261015-011)。詳しい結果は HTML レポートで確認する。
|
|
103
|
+
reporter: [
|
|
104
|
+
[node_path_1.default.join(toolRoot, 'support', `consoleReporter${toolExt}`), { reportCommand: options.reportCommand ?? 'npx sftest report' }],
|
|
105
|
+
['html', { open: 'never', outputFolder: (0, outputPaths_1.outputPath)('playwright-report') }],
|
|
106
|
+
['junit', { outputFile: (0, outputPaths_1.outputPath)('results', 'junit.xml') }],
|
|
107
|
+
],
|
|
102
108
|
// テスト全体の前にログインしてセッションを保存し、終了後に削除する(support/globalSetup.ts)。
|
|
103
109
|
globalSetup: node_path_1.default.join(toolRoot, 'support', `globalSetup${toolExt}`),
|
|
104
110
|
use: {
|
|
@@ -106,6 +112,9 @@ function sfTestConfig(options) {
|
|
|
106
112
|
storageState: (0, session_1.authFile)(), // 各シナリオは、前後処理で保存したセッションで始まる。
|
|
107
113
|
locale: 'ja-JP',
|
|
108
114
|
navigationTimeout: (0, settings_1.timeoutMs)('pageLoad'),
|
|
115
|
+
// 画面の操作(クリック・入力・画面キャプチャーなど)の制限時間。操作の対象が見つからない場合に、シナリオの制限時間まで
|
|
116
|
+
// 待ち続けず、どの対象が見つからないかを示して失敗にする(20261015-010)。個別に制限時間を指定した操作は、その値を使う。
|
|
117
|
+
actionTimeout: (0, settings_1.timeoutMs)('pageLoad'),
|
|
109
118
|
trace: 'retain-on-failure',
|
|
110
119
|
screenshot: 'on', // エビデンスとして、成功時もテスト終了時の画面を残す。
|
|
111
120
|
customPages: options.customPages ?? {},
|
|
@@ -12,8 +12,12 @@ export declare const DEFAULT_TIMEOUTS: {
|
|
|
12
12
|
};
|
|
13
13
|
/** 制限時間の項目名。 */
|
|
14
14
|
export type TimeoutName = keyof typeof DEFAULT_TIMEOUTS;
|
|
15
|
+
/** 項目名の「セクション名」と「項目名」を区切る文字(列)の初期値(20261016-012)。 */
|
|
16
|
+
export declare const DEFAULT_SECTION_SEPARATOR = "/";
|
|
15
17
|
/** 設定ファイルを反映した制限時間(秒)。 */
|
|
16
18
|
export declare const timeouts: Record<"apexBatch" | "batchFile" | "dataImportJob" | "expect" | "expectSlow" | "pageLoad" | "scenario", number>;
|
|
19
|
+
/** 設定ファイルを反映した、項目名の「セクション名」と「項目名」の区切り(20261016-012)。 */
|
|
20
|
+
export declare const sectionSeparator: string;
|
|
17
21
|
/**
|
|
18
22
|
* 制限時間をミリ秒で返す。Playwright の timeout に渡す値として使う。
|
|
19
23
|
*
|