@checksum-ai/runtime 1.1.45-alpha → 1.1.46
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 +2 -43
- package/cli.js +34 -35
- package/index.d.ts +25 -14
- package/index.js +51 -52
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,41 +17,6 @@
|
|
|
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
|
-
```
|
|
55
20
|
|
|
56
21
|
## Checksum AI Magic
|
|
57
22
|
|
|
@@ -201,10 +166,7 @@ function init(base: ChecksumTestType<PlaywrightTestArgs>): {
|
|
|
201
166
|
/**
|
|
202
167
|
* The login method which calls the user defined login function
|
|
203
168
|
*/
|
|
204
|
-
login:
|
|
205
|
-
page: Page,
|
|
206
|
-
{ role, environment }?: { role?: string; environment?: string }
|
|
207
|
-
) => Promise<void>;
|
|
169
|
+
login: ReturnType<typeof getLogin>;
|
|
208
170
|
/**
|
|
209
171
|
* The test title definition along with the test id
|
|
210
172
|
* used by Checksum to identify the test
|
|
@@ -233,10 +195,7 @@ function init(base: ChecksumTestType<PlaywrightTestArgs>): {
|
|
|
233
195
|
}) => {
|
|
234
196
|
environment: ChecksumConfigEnvironment;
|
|
235
197
|
user: EnvironmentUser;
|
|
236
|
-
login:
|
|
237
|
-
page: Page,
|
|
238
|
-
{ role }?: { role?: string }
|
|
239
|
-
) => Promise<void>;
|
|
198
|
+
login: ReturnType<typeof getLogin>;
|
|
240
199
|
};
|
|
241
200
|
};
|
|
242
201
|
```
|