@checksum-ai/runtime 1.1.48 → 1.1.49
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 +43 -2
- package/cli.js +4 -3
- package/index.d.ts +14 -25
- package/index.js +78 -77
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,41 @@
|
|
|
17
17
|
2. We recommend using a consistent seeded user for every test. For example, before each test, call a webhook that creates a user, seeds it with data, and returns the username and password. This approach ensures test reliability and allows parallel test execution. Configure this webhook [in your project](https://app.checksum.ai/#/settings/wizard) for consistent test generation.
|
|
18
18
|
3. After logging in, assert that the login was successful. Playwright waits for assertions to be correct, ensuring that the page is ready for interaction before proceeding.
|
|
19
19
|
4. To reuse authentication states between tests, refer to the Playwright guide on [authentication](https://playwright.dev/docs/auth). At the start of the login function, check if the user is already authenticated and return if so.
|
|
20
|
+
5. Use the ChecksumLoginFunction type to correctly implement the login function, as following
|
|
21
|
+
```
|
|
22
|
+
import {
|
|
23
|
+
ChecksumLoginFunction,
|
|
24
|
+
ChecksumConfigEnvironment,
|
|
25
|
+
EnvironmentUser,
|
|
26
|
+
ChecksumConfig
|
|
27
|
+
} from "@checksum-ai/runtime"
|
|
28
|
+
|
|
29
|
+
const login: ChecksumLoginFunction<PayloadType> = async (
|
|
30
|
+
page,
|
|
31
|
+
{
|
|
32
|
+
environment, /* selected environment */
|
|
33
|
+
user, /* selected user */
|
|
34
|
+
config /* loaded config from checksum.config.ts */,
|
|
35
|
+
payload /* allowing externally provided payload */
|
|
36
|
+
}: {
|
|
37
|
+
environment: ChecksumConfigEnvironment,
|
|
38
|
+
user: EnvironmentUser,
|
|
39
|
+
config: ChecksumConfig,
|
|
40
|
+
payload: PayloadType
|
|
41
|
+
}
|
|
42
|
+
): Promise<void> => {
|
|
43
|
+
const email = user.username;
|
|
44
|
+
const password = user.password;
|
|
45
|
+
const token = payload.token;
|
|
46
|
+
const url = environment.baseURL;
|
|
47
|
+
await page.goto(url);
|
|
48
|
+
...
|
|
49
|
+
console.log("Login Successful");
|
|
50
|
+
return;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
exports.default = login;
|
|
54
|
+
```
|
|
20
55
|
|
|
21
56
|
## Checksum AI Magic
|
|
22
57
|
|
|
@@ -166,7 +201,10 @@ function init(base: ChecksumTestType<PlaywrightTestArgs>): {
|
|
|
166
201
|
/**
|
|
167
202
|
* The login method which calls the user defined login function
|
|
168
203
|
*/
|
|
169
|
-
login:
|
|
204
|
+
login: (
|
|
205
|
+
page: Page,
|
|
206
|
+
{ role, environment }?: { role?: string; environment?: string }
|
|
207
|
+
) => Promise<void>;
|
|
170
208
|
/**
|
|
171
209
|
* The test title definition along with the test id
|
|
172
210
|
* used by Checksum to identify the test
|
|
@@ -195,7 +233,10 @@ function init(base: ChecksumTestType<PlaywrightTestArgs>): {
|
|
|
195
233
|
}) => {
|
|
196
234
|
environment: ChecksumConfigEnvironment;
|
|
197
235
|
user: EnvironmentUser;
|
|
198
|
-
login:
|
|
236
|
+
login: (
|
|
237
|
+
page: Page,
|
|
238
|
+
{ role }?: { role?: string }
|
|
239
|
+
) => Promise<void>;
|
|
199
240
|
};
|
|
200
241
|
};
|
|
201
242
|
```
|