@augment-vir/test 31.50.1 → 31.50.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.
@@ -1,6 +1,6 @@
1
1
  import { RuntimeEnvError } from '@augment-vir/core';
2
2
  export { type MenuOptionOptions } from '../test-playwright/get-option.js';
3
- export { playwrightTeatNameUrlParam, type NavPath } from '../test-playwright/nav.js';
3
+ export { playwrightTeatNameUrlParam, type NavOptions } from '../test-playwright/nav.js';
4
4
  export { type LocatorScreenshotOptions, type SaveScreenshotOptions, type TakeScreenshotOptions, } from '../test-playwright/screenshot.js';
5
5
  declare function importPlaywrightTestApi(this: void): Promise<RuntimeEnvError | {
6
6
  navigation: {
@@ -1,21 +1,24 @@
1
1
  import { type GenericTreePaths } from 'spa-router-vir';
2
+ import { type UrlOverrides } from 'url-vir';
2
3
  import { type UniversalTestContext } from '../augments/universal-testing-suite/universal-test-context.js';
3
4
  /**
4
- * Converts {@link NavPath} into an actionable URL string.
5
+ * Converts {@link NavOptions} into an actionable URL string.
5
6
  *
6
7
  * @category Internal
7
8
  */
8
- export declare function extractNavUrl(frontendUrl: string, path: NavPath): string;
9
+ export declare function extractNavUrl(testContext: Readonly<UniversalTestContext>, options: Readonly<NavOptions>): string;
9
10
  /**
10
11
  * Used for the `path` argument of `testPlaywright.nav`.
11
12
  *
12
13
  * @category Internal
13
14
  */
14
- export type NavPath = /** A full URL to load, will not be appended to the auto detected frontend url. */ string
15
- /** Path array to append to the auto detected frontend url. */
16
- | string[]
17
- /** Prefer using tree paths with `frontendPathTree` */
18
- | GenericTreePaths;
15
+ export type NavOptions = Omit<UrlOverrides, 'paths'> & {
16
+ /** If not provided, the page's current URL will be used. */
17
+ baseFrontendUrl?: string | undefined;
18
+ paths?: string[]
19
+ /** Prefer using tree paths with `frontendPathTree` */
20
+ | GenericTreePaths;
21
+ };
19
22
  /**
20
23
  * The test name appended to the frontend when `testPlaywright.nav` is used.
21
24
  *
@@ -27,8 +30,4 @@ export declare const playwrightTeatNameUrlParam = "test-name";
27
30
  *
28
31
  * @category Internal
29
32
  */
30
- export declare function navigateTo(testContext: Readonly<UniversalTestContext>, { path, baseFrontendUrl, }: {
31
- path: NavPath;
32
- /** If not provided, the page's current URL will be used. */
33
- baseFrontendUrl?: string | undefined;
34
- }): Promise<void>;
33
+ export declare function navigateTo(testContext: Readonly<UniversalTestContext>, options: Readonly<NavOptions>): Promise<void>;
@@ -1,21 +1,26 @@
1
1
  import { check } from '@augment-vir/assert';
2
+ import { omitObjectKeys } from '@augment-vir/common';
2
3
  import { buildUrl } from 'url-vir';
3
- import { assertTestContext, extractTestNameAsDir, TestEnv, } from '../augments/universal-testing-suite/universal-test-context.js';
4
+ import { assertTestContext, assertWrapTestContext, extractTestNameAsDir, TestEnv, } from '../augments/universal-testing-suite/universal-test-context.js';
4
5
  /**
5
- * Converts {@link NavPath} into an actionable URL string.
6
+ * Converts {@link NavOptions} into an actionable URL string.
6
7
  *
7
8
  * @category Internal
8
9
  */
9
- export function extractNavUrl(frontendUrl, path) {
10
- return check.isString(path)
11
- ? path
12
- : check.isArray(path)
13
- ? buildUrl(frontendUrl, {
14
- paths: path,
15
- }).href
16
- : buildUrl(frontendUrl, {
17
- paths: path.fullPaths,
18
- }).href;
10
+ export function extractNavUrl(testContext, options) {
11
+ return buildUrl(options.baseFrontendUrl ||
12
+ assertWrapTestContext(testContext, TestEnv.Playwright).page.url(), {
13
+ ...omitObjectKeys(options, ['paths']),
14
+ ...(options.paths
15
+ ? check.isArray(options.paths)
16
+ ? {
17
+ paths: options.paths,
18
+ }
19
+ : {
20
+ paths: options.paths.fullPaths,
21
+ }
22
+ : {}),
23
+ }).href;
19
24
  }
20
25
  /**
21
26
  * The test name appended to the frontend when `testPlaywright.nav` is used.
@@ -28,11 +33,11 @@ export const playwrightTeatNameUrlParam = 'test-name';
28
33
  *
29
34
  * @category Internal
30
35
  */
31
- export async function navigateTo(testContext, { path, baseFrontendUrl, }) {
36
+ export async function navigateTo(testContext, options) {
32
37
  assertTestContext(testContext, TestEnv.Playwright);
33
38
  const page = testContext.page;
34
39
  const testName = extractTestNameAsDir(testContext);
35
- const finalPath = buildUrl(extractNavUrl(baseFrontendUrl || page.url(), path), {
40
+ const finalPath = buildUrl(extractNavUrl(testContext, options), {
36
41
  search: {
37
42
  [playwrightTeatNameUrlParam]: [testName],
38
43
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/test",
3
- "version": "31.50.1",
3
+ "version": "31.50.2",
4
4
  "description": "A universal testing suite that works with Mocha style test runners _and_ Node.js's built-in test runner.",
5
5
  "keywords": [
6
6
  "test",
@@ -44,8 +44,8 @@
44
44
  "test:web": "virmator test --no-deps web 'src/test-web/**/*.test.ts' 'src/augments/universal-testing-suite/**/*.test.ts'"
45
45
  },
46
46
  "dependencies": {
47
- "@augment-vir/assert": "^31.50.1",
48
- "@augment-vir/common": "^31.50.1",
47
+ "@augment-vir/assert": "^31.50.2",
48
+ "@augment-vir/common": "^31.50.2",
49
49
  "@open-wc/testing-helpers": "^3.0.1",
50
50
  "@virmator/test": "^14.2.2",
51
51
  "type-fest": "^5.2.0"