@verdaccio/e2e-ui 2.1.0 → 2.2.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.
Files changed (55) hide show
  1. package/README.md +134 -0
  2. package/build/cjs/commands/index.cjs +32 -0
  3. package/build/cjs/commands/index.cjs.map +1 -0
  4. package/build/cjs/index.cjs +128 -0
  5. package/build/cjs/index.cjs.map +1 -0
  6. package/build/cjs/tasks/publish.cjs +245 -0
  7. package/build/cjs/tasks/publish.cjs.map +1 -0
  8. package/build/cjs/testIds.cjs +104 -0
  9. package/build/cjs/testIds.cjs.map +1 -0
  10. package/build/cjs/tests/home.cjs +88 -0
  11. package/build/cjs/tests/home.cjs.map +1 -0
  12. package/build/cjs/tests/layout.cjs +71 -0
  13. package/build/cjs/tests/layout.cjs.map +1 -0
  14. package/build/cjs/tests/publish.cjs +129 -0
  15. package/build/cjs/tests/publish.cjs.map +1 -0
  16. package/build/cjs/tests/search.cjs +74 -0
  17. package/build/cjs/tests/search.cjs.map +1 -0
  18. package/build/cjs/tests/settings.cjs +66 -0
  19. package/build/cjs/tests/settings.cjs.map +1 -0
  20. package/build/cjs/tests/signin.cjs +38 -0
  21. package/build/cjs/tests/signin.cjs.map +1 -0
  22. package/build/commands/index.d.ts +29 -0
  23. package/build/esm/commands/index.js +33 -0
  24. package/build/esm/commands/index.js.map +1 -0
  25. package/build/esm/index.js +114 -0
  26. package/build/esm/index.js.map +1 -0
  27. package/build/esm/tasks/publish.js +243 -0
  28. package/build/esm/tasks/publish.js.map +1 -0
  29. package/build/esm/testIds.js +101 -0
  30. package/build/esm/testIds.js.map +1 -0
  31. package/build/esm/tests/home.js +88 -0
  32. package/build/esm/tests/home.js.map +1 -0
  33. package/build/esm/tests/layout.js +71 -0
  34. package/build/esm/tests/layout.js.map +1 -0
  35. package/build/esm/tests/publish.js +129 -0
  36. package/build/esm/tests/publish.js.map +1 -0
  37. package/build/esm/tests/search.js +74 -0
  38. package/build/esm/tests/search.js.map +1 -0
  39. package/build/esm/tests/settings.js +66 -0
  40. package/build/esm/tests/settings.js.map +1 -0
  41. package/build/esm/tests/signin.js +38 -0
  42. package/build/esm/tests/signin.js.map +1 -0
  43. package/build/index.d.ts +55 -0
  44. package/build/tasks/index.d.ts +2 -0
  45. package/build/tasks/publish.d.ts +94 -0
  46. package/build/testIds.d.ts +130 -0
  47. package/build/tests/home.d.ts +2 -0
  48. package/build/tests/index.d.ts +6 -0
  49. package/build/tests/layout.d.ts +12 -0
  50. package/build/tests/publish.d.ts +2 -0
  51. package/build/tests/search.d.ts +10 -0
  52. package/build/tests/settings.d.ts +19 -0
  53. package/build/tests/signin.d.ts +2 -0
  54. package/build/types.d.ts +102 -0
  55. package/package.json +1 -1
@@ -0,0 +1,94 @@
1
+ export interface PublishPackageInput {
2
+ pkgName: string;
3
+ version?: string;
4
+ registryUrl: string;
5
+ credentials: {
6
+ user: string;
7
+ password: string;
8
+ };
9
+ dependencies?: Record<string, string>;
10
+ devDependencies?: Record<string, string>;
11
+ /**
12
+ * When true, append a timestamp suffix to the version so reruns against
13
+ * a persistent registry don't collide on 403. The suffix is a valid
14
+ * semver prerelease, e.g. `1.0.0-t1712345678`. Defaults to false.
15
+ */
16
+ unique?: boolean;
17
+ }
18
+ /**
19
+ * Shape of the argument passed to `cy.task('publishPackage', ...)`.
20
+ *
21
+ * `registryUrl` and `credentials` are optional here (they fall back to
22
+ * whatever was configured in `setupVerdaccioTasks`), but `pkgName` is
23
+ * still required — every publish needs a name.
24
+ */
25
+ export type PublishPackageTaskInput = Partial<Omit<PublishPackageInput, 'pkgName'>> & {
26
+ pkgName: string;
27
+ };
28
+ export interface PublishPackageResult {
29
+ pkgName: string;
30
+ version: string;
31
+ tempFolder: string;
32
+ stdout: string;
33
+ stderr: string;
34
+ exitCode: number;
35
+ }
36
+ /**
37
+ * Publish a throwaway npm package to the target Verdaccio registry.
38
+ *
39
+ * Flow:
40
+ * 1. Create a throwaway user via `PUT /-/user/...` and capture its
41
+ * legacy auth token. See `obtainLegacyToken` for why.
42
+ * 2. Scaffold a temp project with `package.json`, `README.md`,
43
+ * `index.js`, and an `.npmrc` that includes the token.
44
+ * 3. Spawn `npm publish` from that temp dir.
45
+ *
46
+ * `input.credentials` is kept on the signature for forward-compat but
47
+ * is currently unused — each call mints its own throwaway user.
48
+ *
49
+ * Throws on non-zero npm exit. Returns the temp folder path on success
50
+ * so callers can inspect or clean up.
51
+ */
52
+ export declare function publishPackage(input: PublishPackageInput): Promise<PublishPackageResult>;
53
+ /**
54
+ * Remove a temp project folder previously created by publishPackage.
55
+ * Safe to call with a missing path or a path outside the OS tmp dir —
56
+ * in the latter case it refuses rather than rm-rf'ing arbitrary paths.
57
+ */
58
+ export declare function cleanupPublished(tempFolder: string): Promise<void>;
59
+ export interface UnpublishPackageInput {
60
+ registryUrl: string;
61
+ pkgName: string;
62
+ /**
63
+ * Temp folder returned by a previous `publishPackage` call. If
64
+ * provided, its existing `.npmrc` (which already carries a legacy
65
+ * auth token) is reused for the unpublish call — no extra throwaway
66
+ * user is minted. Otherwise this task creates its own.
67
+ */
68
+ tempFolder?: string;
69
+ }
70
+ export interface UnpublishPackageResult {
71
+ pkgName: string;
72
+ stdout: string;
73
+ stderr: string;
74
+ exitCode: number;
75
+ /**
76
+ * True if the package was already absent (HTTP 404 from the
77
+ * registry). Tests typically want to treat this as success.
78
+ */
79
+ alreadyGone: boolean;
80
+ }
81
+ /**
82
+ * Unpublish a package from the target registry so subsequent tests
83
+ * start from a clean slate.
84
+ *
85
+ * If `tempFolder` is provided (typically from a prior `publishPackage`
86
+ * result), its `.npmrc` is reused so no extra throwaway user is
87
+ * minted. Otherwise this function creates its own temp folder + token.
88
+ * Either way the temp folder used by THIS call is removed on exit
89
+ * (but callers still own the lifecycle of a tempFolder they passed in).
90
+ *
91
+ * Treats HTTP 404 / "tarball does not exist" as success so reruns and
92
+ * parallel teardowns don't flap.
93
+ */
94
+ export declare function unpublishPackage(input: UnpublishPackageInput): Promise<UnpublishPackageResult>;
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Configurable DOM selectors used by the e2e-ui test suites.
3
+ *
4
+ * The Verdaccio UI is a moving target — data-testids can and do change
5
+ * between majors — so every selector referenced by a test lives here
6
+ * and can be overridden by consumers of `@verdaccio/e2e-ui` via
7
+ * `createRegistryConfig({ testIds, selectors })`.
8
+ *
9
+ * The defaults below match Verdaccio 6.x as of the last time we audited
10
+ * the ui-components source. If a selector moves, override just the
11
+ * affected field instead of forking the suite.
12
+ */
13
+ /**
14
+ * Map of data-testid values used by the test suites, grouped by UI
15
+ * section. Each field holds the bare testid string (no `data-testid="…"`
16
+ * wrapping) — the test helpers pass it through `cy.getByTestId(...)`.
17
+ */
18
+ export interface TestIds {
19
+ home: {
20
+ /** Help card shown on the empty-registry landing page. */
21
+ helpCard: string;
22
+ /** 404 "not found" container. */
23
+ notFound: string;
24
+ };
25
+ header: {
26
+ /** Outermost `<NavBar>` element. */
27
+ container: string;
28
+ /** Inner wrapper inside the nav bar. */
29
+ innerNavBar: string;
30
+ /** Right-side action cluster wrapper. */
31
+ right: string;
32
+ /** Wrapper around the header search input. */
33
+ searchContainer: string;
34
+ /** Default SVG Verdaccio logo. */
35
+ defaultLogo: string;
36
+ /** Custom (user-provided) logo image. */
37
+ customLogo: string;
38
+ /** "Login" button shown when logged out. */
39
+ loginButton: string;
40
+ /** Gear icon that opens the settings dialog. */
41
+ settingsTooltip: string;
42
+ /** Info icon that opens the registry info dialog. */
43
+ infoTooltip: string;
44
+ /** Menu icon shown after login (opens the logged-in menu). */
45
+ logInDialogIcon: string;
46
+ /** "Log out" entry inside the logged-in menu. */
47
+ logOutDialogIcon: string;
48
+ /** "Hi <username>" label inside the logged-in menu. */
49
+ greetingsLabel: string;
50
+ };
51
+ footer: {
52
+ /** Outer footer wrapper. */
53
+ container: string;
54
+ /** "Powered by" version text on the right side of the footer. */
55
+ version: string;
56
+ };
57
+ package: {
58
+ /** Wrapper around the list of packages on the home page. */
59
+ itemList: string;
60
+ /** Package name link in the package list (home + search results). */
61
+ title: string;
62
+ /** Readme container on the package detail page. */
63
+ readme: string;
64
+ /** Sidebar container on the package detail page. */
65
+ sidebar: string;
66
+ /** Install commands section list. */
67
+ installList: string;
68
+ /** Individual install line for npm. */
69
+ installNpm: string;
70
+ /** Individual install line for yarn. */
71
+ installYarn: string;
72
+ /** Individual install line for pnpm. */
73
+ installPnpm: string;
74
+ /** Keyword list below the install section. */
75
+ keywordList: string;
76
+ /** Tab that reveals the dependencies view. */
77
+ dependenciesTab: string;
78
+ /** Dependencies list wrapper (one entry per dep). */
79
+ dependencies: string;
80
+ /** Tab that reveals the versions view. */
81
+ versionsTab: string;
82
+ /** "latest" tag row inside the versions view. */
83
+ tagLatest: string;
84
+ /** Tab that reveals the uplinks view. */
85
+ uplinksTab: string;
86
+ /** Empty-state message when the package has no uplinks. */
87
+ noUplinks: string;
88
+ };
89
+ }
90
+ /**
91
+ * CSS selectors (not data-testids) used by the test suites. These are
92
+ * things like form-field IDs and framework-specific class names that
93
+ * Verdaccio's UI exposes as plain selectors rather than testids.
94
+ */
95
+ export interface Selectors {
96
+ /** Class applied to the parsed README markdown body. */
97
+ markdownBody: string;
98
+ loginDialog: {
99
+ /** Username text input inside the login dialog. */
100
+ usernameInput: string;
101
+ /** Password text input inside the login dialog. */
102
+ passwordInput: string;
103
+ /** Submit button inside the login dialog. */
104
+ submitButton: string;
105
+ };
106
+ }
107
+ /**
108
+ * Defaults matching Verdaccio 6.x (bundled ui-theme@9.0.0-next-9.x).
109
+ * Overridable via `createRegistryConfig({ testIds: { ... } })`.
110
+ */
111
+ export declare const DEFAULT_TEST_IDS: TestIds;
112
+ /**
113
+ * Defaults for non-testid CSS selectors. Overridable via
114
+ * `createRegistryConfig({ selectors: { ... } })`.
115
+ */
116
+ export declare const DEFAULT_SELECTORS: Selectors;
117
+ /** Deep-partial helper — every field of a nested object becomes optional. */
118
+ export type DeepPartial<T> = {
119
+ [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
120
+ };
121
+ /**
122
+ * Merge user overrides into the default testIds map. Merging is
123
+ * per-section (one level deep): `overrides.header` replaces individual
124
+ * fields under `defaults.header` without touching `defaults.footer`.
125
+ * The shape is fixed and small, so we enumerate sections by hand
126
+ * rather than relying on a recursive generic merger.
127
+ */
128
+ export declare function mergeTestIds(defaults: TestIds, overrides?: DeepPartial<TestIds>): TestIds;
129
+ /** Same idea as `mergeTestIds`, for the CSS-selector block. */
130
+ export declare function mergeSelectors(defaults: Selectors, overrides?: DeepPartial<Selectors>): Selectors;
@@ -0,0 +1,2 @@
1
+ import { RegistryConfig } from '../types';
2
+ export declare function homeTests(config: RegistryConfig): void;
@@ -0,0 +1,6 @@
1
+ export { homeTests } from './home';
2
+ export { signinTests } from './signin';
3
+ export { publishTests } from './publish';
4
+ export { searchTests } from './search';
5
+ export { settingsTests } from './settings';
6
+ export { layoutTests } from './layout';
@@ -0,0 +1,12 @@
1
+ import { RegistryConfig } from '../types';
2
+ /**
3
+ * Tests for the persistent page chrome: the header (nav bar, logo,
4
+ * search container, action buttons) and the footer (version marker).
5
+ * Also asserts that the runtime UI configuration endpoint
6
+ * `/-/static/ui-options.js` loads successfully — this endpoint emits
7
+ * `window.__VERDACCIO_BASENAME_UI_OPTIONS`, which the ui-theme relies
8
+ * on for feature flags like showFooter / showSearch / showSettings. If
9
+ * it fails the whole SPA degrades to whatever defaults the provider
10
+ * ships with, so it's worth a direct network-level check.
11
+ */
12
+ export declare function layoutTests(config: RegistryConfig): void;
@@ -0,0 +1,2 @@
1
+ import { RegistryConfig } from '../types';
2
+ export declare function publishTests(config: RegistryConfig): void;
@@ -0,0 +1,10 @@
1
+ import { RegistryConfig } from '../types';
2
+ /**
3
+ * UI tests for the Verdaccio search box.
4
+ *
5
+ * These tests do NOT depend on any published package — they assert the
6
+ * search *flow* (input exists, typing triggers the search API, results
7
+ * region updates) rather than specific package metadata. Tests that need
8
+ * a real package in the registry should live in publishTests instead.
9
+ */
10
+ export declare function searchTests(config: RegistryConfig): void;
@@ -0,0 +1,19 @@
1
+ import { RegistryConfig } from '../types';
2
+ /**
3
+ * Tests for the header Settings dialog and the Translations (language)
4
+ * picker inside it.
5
+ *
6
+ * Requires `web.showSettings: true` in the registry config — the gear
7
+ * icon only renders when the flag is on (see HeaderRight in Verdaccio's
8
+ * ui-components package).
9
+ *
10
+ * Selector strategy: the language cards in LanguageSwitch do NOT have
11
+ * data-testids, so this suite leans on:
12
+ * - MUI's ARIA roles: `[role="dialog"]`, `[role="tab"]`
13
+ * - The stable English labels "Configuration", "Translations",
14
+ * "English", "German", and the language description text, which are
15
+ * bundled into the ui-theme via `@verdaccio/ui-i18n`
16
+ * - The settings trigger's testid from Verdaccio's HeaderToolTipIcon:
17
+ * `header--tooltip-settings`
18
+ */
19
+ export declare function settingsTests(config: RegistryConfig): void;
@@ -0,0 +1,2 @@
1
+ import { RegistryConfig } from '../types';
2
+ export declare function signinTests(config: RegistryConfig): void;
@@ -0,0 +1,102 @@
1
+ /// <reference types="cypress" />
2
+ /// <reference types="cypress" />
3
+ /// <reference types="cypress" />
4
+ import type { PublishPackageResult, PublishPackageTaskInput, UnpublishPackageInput, UnpublishPackageResult } from './tasks';
5
+ import type { DeepPartial, Selectors, TestIds } from './testIds';
6
+ export type RegistryConfig = {
7
+ registryUrl: string;
8
+ port: number;
9
+ credentials: {
10
+ user: string;
11
+ password: string;
12
+ };
13
+ title: string;
14
+ /** Fully-resolved data-testid map (defaults merged with overrides). */
15
+ testIds: TestIds;
16
+ /** Fully-resolved CSS selector map (defaults merged with overrides). */
17
+ selectors: Selectors;
18
+ };
19
+ export type VerdaccioUiOptions = {
20
+ registryUrl: string;
21
+ port?: number;
22
+ credentials?: {
23
+ user: string;
24
+ password: string;
25
+ };
26
+ title?: string;
27
+ /** Partial override of the default data-testid map. */
28
+ testIds?: DeepPartial<TestIds>;
29
+ /** Partial override of the default CSS selector map. */
30
+ selectors?: DeepPartial<Selectors>;
31
+ };
32
+ /**
33
+ * Return value of the `registry` Cypress task — exposed as a named
34
+ * type so `cy.task('registry')` can be strongly typed at the call site.
35
+ */
36
+ export interface RegistryTaskResult {
37
+ registryUrl: string;
38
+ port: number;
39
+ }
40
+ declare global {
41
+ namespace Cypress {
42
+ interface Chainable<Subject = any> {
43
+ /**
44
+ * Find an element by its `data-testid` attribute.
45
+ */
46
+ getByTestId(selector: string, ...args: any[]): Chainable<JQuery<HTMLElement>>;
47
+ /**
48
+ * Log in to the Verdaccio UI via the login dialog.
49
+ *
50
+ * `selectors` is optional — each field falls back to the
51
+ * Verdaccio 6.x default selector if omitted. Pass overrides when
52
+ * targeting a non-default Verdaccio build.
53
+ */
54
+ login(user: string, password: string, selectors?: {
55
+ loginButton?: string;
56
+ usernameInput?: string;
57
+ passwordInput?: string;
58
+ submitButton?: string;
59
+ }): Chainable<void>;
60
+ /**
61
+ * Publish a throwaway package to the configured registry.
62
+ *
63
+ * @example
64
+ * cy.task('publishPackage', {
65
+ * pkgName: '@verdaccio/pkg-scoped',
66
+ * version: '1.0.0',
67
+ * dependencies: { debug: '4.0.0' },
68
+ * unique: true,
69
+ * }).then((result) => {
70
+ * // result is a PublishPackageResult — fully typed.
71
+ * });
72
+ */
73
+ task(event: 'publishPackage', arg: PublishPackageTaskInput, options?: Partial<Loggable & Timeoutable>): Chainable<PublishPackageResult>;
74
+ /**
75
+ * Remove a temp project folder previously returned by
76
+ * `cy.task('publishPackage', …)`. Refuses to delete paths outside
77
+ * `os.tmpdir()`. Resolves with `null`.
78
+ */
79
+ task(event: 'cleanupPublished', arg: string, options?: Partial<Loggable & Timeoutable>): Chainable<null>;
80
+ /**
81
+ * Unpublish a package from the registry so the next test starts
82
+ * from a clean slate. Accepts either a bare package name (uses
83
+ * the configured registry URL and mints its own throwaway token)
84
+ * or a full input object (reuses an existing `tempFolder`'s
85
+ * .npmrc for efficiency).
86
+ *
87
+ * @example
88
+ * cy.task('unpublishPackage', '@verdaccio/pkg-scoped');
89
+ * cy.task('unpublishPackage', { pkgName, tempFolder });
90
+ */
91
+ task(event: 'unpublishPackage', arg: string | (Omit<UnpublishPackageInput, 'registryUrl'> & {
92
+ registryUrl?: string;
93
+ }), options?: Partial<Loggable & Timeoutable>): Chainable<UnpublishPackageResult>;
94
+ /**
95
+ * Read back the registry URL and port that were passed to
96
+ * `setupVerdaccioTasks`. Useful in specs that need to compute
97
+ * URLs without importing the cypress config.
98
+ */
99
+ task(event: 'registry', arg?: unknown, options?: Partial<Loggable & Timeoutable>): Chainable<RegistryTaskResult>;
100
+ }
101
+ }
102
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/e2e-ui",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Cypress plugin for Verdaccio UI e2e tests — run against any registry",