@mablhq/playwright-tools 2.77.1 → 2.77.2
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/README.md +32 -0
- package/api/mablApiClient.js +9 -0
- package/execution/index.js +1 -1
- package/index.d.ts +16 -1
- package/package.json +1 -1
- package/util/analytics-events.js +1 -0
package/README.md
CHANGED
|
@@ -110,6 +110,8 @@ test('Validate emails can be received using mabl sandbox app', async ({
|
|
|
110
110
|
|
|
111
111
|
### Generative AI testing
|
|
112
112
|
|
|
113
|
+
#### Validating page state
|
|
114
|
+
|
|
113
115
|
```typescript
|
|
114
116
|
import {expect, test} from '../utils/fixtures';
|
|
115
117
|
|
|
@@ -131,6 +133,36 @@ test('Evaluate a GenAI assertion to validate the state of a page', async ({
|
|
|
131
133
|
});
|
|
132
134
|
```
|
|
133
135
|
|
|
136
|
+
#### Validating downloaded files
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import {expect, test} from '../utils/fixtures';
|
|
140
|
+
|
|
141
|
+
test('Evaluate a GenAI assertion with a downloaded file', async ({
|
|
142
|
+
page,
|
|
143
|
+
mabl,
|
|
144
|
+
}) => {
|
|
145
|
+
await page.goto('https://sandbox.mabl.com/downloads-pdfs');
|
|
146
|
+
|
|
147
|
+
// Wait for the download button and trigger download
|
|
148
|
+
const downloadPromise = page.waitForEvent('download');
|
|
149
|
+
await page.getByText('Download CSV').click();
|
|
150
|
+
const download = await downloadPromise;
|
|
151
|
+
|
|
152
|
+
// Use the mabl tools to evaluate the downloaded file content with a GenAI assertion
|
|
153
|
+
// This works with various file types including CSV, text files, and more
|
|
154
|
+
const result = await mabl.evaluateGenAiAssertionInFile(
|
|
155
|
+
page,
|
|
156
|
+
'Outdoor Patio Chair is in stock',
|
|
157
|
+
download,
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
// The result includes both success status and an explanation of the evaluation
|
|
161
|
+
console.log(`GEN AI FILE EXPLANATION: [${result.explanation}]`);
|
|
162
|
+
expect(result.success).toBe(true);
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
134
166
|
### Database testing
|
|
135
167
|
|
|
136
168
|
```typescript
|
package/api/mablApiClient.js
CHANGED
|
@@ -747,6 +747,15 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
747
747
|
throw toApiError('Failed to generate steps', error);
|
|
748
748
|
}
|
|
749
749
|
}
|
|
750
|
+
async checkFileMetadataForGenAIAssertion(workspaceId, mimeType) {
|
|
751
|
+
try {
|
|
752
|
+
const uri = `${this.baseApiUrl}/agent/checkFileMetadataForGenAIAssertion?workspaceId=${encodeURIComponent(workspaceId)}&mimeType=${encodeURIComponent(mimeType)}`;
|
|
753
|
+
return await this.makeGetRequest(uri);
|
|
754
|
+
}
|
|
755
|
+
catch (error) {
|
|
756
|
+
throw toApiError('Failed to check file metadata for GenAI assertion', error);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
750
759
|
async evaluateAiAssertion(workspaceId, testRunId, screenshot, userPrompt, metaPrompt, criteria, test, variables, retryConfig, files) {
|
|
751
760
|
const requestUrl = `${this.baseApiUrl}/agent/assertion?workspaceId=${workspaceId}`;
|
|
752
761
|
return this.evaluateAiAssertionInternal(requestUrl, testRunId, screenshot, userPrompt, metaPrompt, criteria, test, variables, retryConfig, files);
|