@verdaccio/e2e-ui 2.1.1 → 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.
- package/README.md +134 -0
- package/build/cjs/commands/index.cjs +21 -5
- package/build/cjs/commands/index.cjs.map +1 -1
- package/build/cjs/index.cjs +65 -10
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/tasks/publish.cjs +245 -0
- package/build/cjs/tasks/publish.cjs.map +1 -0
- package/build/cjs/testIds.cjs +104 -0
- package/build/cjs/testIds.cjs.map +1 -0
- package/build/cjs/tests/home.cjs +61 -7
- package/build/cjs/tests/home.cjs.map +1 -1
- package/build/cjs/tests/layout.cjs +71 -0
- package/build/cjs/tests/layout.cjs.map +1 -0
- package/build/cjs/tests/publish.cjs +83 -33
- package/build/cjs/tests/publish.cjs.map +1 -1
- package/build/cjs/tests/search.cjs +74 -0
- package/build/cjs/tests/search.cjs.map +1 -0
- package/build/cjs/tests/settings.cjs +66 -0
- package/build/cjs/tests/settings.cjs.map +1 -0
- package/build/cjs/tests/signin.cjs +15 -7
- package/build/cjs/tests/signin.cjs.map +1 -1
- package/build/commands/index.d.ts +15 -3
- package/build/esm/commands/index.js +21 -5
- package/build/esm/commands/index.js.map +1 -1
- package/build/esm/index.js +55 -8
- package/build/esm/index.js.map +1 -1
- package/build/esm/tasks/publish.js +243 -0
- package/build/esm/tasks/publish.js.map +1 -0
- package/build/esm/testIds.js +101 -0
- package/build/esm/testIds.js.map +1 -0
- package/build/esm/tests/home.js +61 -7
- package/build/esm/tests/home.js.map +1 -1
- package/build/esm/tests/layout.js +71 -0
- package/build/esm/tests/layout.js.map +1 -0
- package/build/esm/tests/publish.js +83 -33
- package/build/esm/tests/publish.js.map +1 -1
- package/build/esm/tests/search.js +74 -0
- package/build/esm/tests/search.js.map +1 -0
- package/build/esm/tests/settings.js +66 -0
- package/build/esm/tests/settings.js.map +1 -0
- package/build/esm/tests/signin.js +15 -7
- package/build/esm/tests/signin.js.map +1 -1
- package/build/index.d.ts +17 -2
- package/build/tasks/index.d.ts +2 -0
- package/build/tasks/publish.d.ts +94 -0
- package/build/testIds.d.ts +130 -0
- package/build/tests/index.d.ts +3 -0
- package/build/tests/layout.d.ts +12 -0
- package/build/tests/search.d.ts +10 -0
- package/build/tests/settings.d.ts +19 -0
- package/build/types.d.ts +84 -0
- package/package.json +1 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//#region src/testIds.ts
|
|
2
|
+
/**
|
|
3
|
+
* Defaults matching Verdaccio 6.x (bundled ui-theme@9.0.0-next-9.x).
|
|
4
|
+
* Overridable via `createRegistryConfig({ testIds: { ... } })`.
|
|
5
|
+
*/
|
|
6
|
+
var DEFAULT_TEST_IDS = {
|
|
7
|
+
home: {
|
|
8
|
+
helpCard: "help-card",
|
|
9
|
+
notFound: "404"
|
|
10
|
+
},
|
|
11
|
+
header: {
|
|
12
|
+
container: "header",
|
|
13
|
+
innerNavBar: "inner-nav-bar",
|
|
14
|
+
right: "header-right",
|
|
15
|
+
searchContainer: "search-container",
|
|
16
|
+
defaultLogo: "default-logo",
|
|
17
|
+
customLogo: "custom-logo",
|
|
18
|
+
loginButton: "header--button-login",
|
|
19
|
+
settingsTooltip: "header--tooltip-settings",
|
|
20
|
+
infoTooltip: "header--tooltip-info",
|
|
21
|
+
logInDialogIcon: "logInDialogIcon",
|
|
22
|
+
logOutDialogIcon: "logOutDialogIcon",
|
|
23
|
+
greetingsLabel: "greetings-label"
|
|
24
|
+
},
|
|
25
|
+
footer: {
|
|
26
|
+
container: "footer",
|
|
27
|
+
version: "version-footer"
|
|
28
|
+
},
|
|
29
|
+
package: {
|
|
30
|
+
itemList: "package-item-list",
|
|
31
|
+
title: "package-title",
|
|
32
|
+
readme: "readme",
|
|
33
|
+
sidebar: "sidebar",
|
|
34
|
+
installList: "installList",
|
|
35
|
+
installNpm: "installListItem-npm",
|
|
36
|
+
installYarn: "installListItem-yarn",
|
|
37
|
+
installPnpm: "installListItem-pnpm",
|
|
38
|
+
keywordList: "keyword-list",
|
|
39
|
+
dependenciesTab: "dependencies-tab",
|
|
40
|
+
dependencies: "dependencies",
|
|
41
|
+
versionsTab: "versions-tab",
|
|
42
|
+
tagLatest: "tag-latest",
|
|
43
|
+
uplinksTab: "uplinks-tab",
|
|
44
|
+
noUplinks: "no-uplinks"
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Defaults for non-testid CSS selectors. Overridable via
|
|
49
|
+
* `createRegistryConfig({ selectors: { ... } })`.
|
|
50
|
+
*/
|
|
51
|
+
var DEFAULT_SELECTORS = {
|
|
52
|
+
markdownBody: ".markdown-body",
|
|
53
|
+
loginDialog: {
|
|
54
|
+
usernameInput: "#login--dialog-username",
|
|
55
|
+
passwordInput: "#login--dialog-password",
|
|
56
|
+
submitButton: "#login--dialog-button-submit"
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Merge user overrides into the default testIds map. Merging is
|
|
61
|
+
* per-section (one level deep): `overrides.header` replaces individual
|
|
62
|
+
* fields under `defaults.header` without touching `defaults.footer`.
|
|
63
|
+
* The shape is fixed and small, so we enumerate sections by hand
|
|
64
|
+
* rather than relying on a recursive generic merger.
|
|
65
|
+
*/
|
|
66
|
+
function mergeTestIds(defaults, overrides) {
|
|
67
|
+
if (!overrides) return defaults;
|
|
68
|
+
return {
|
|
69
|
+
home: {
|
|
70
|
+
...defaults.home,
|
|
71
|
+
...overrides.home
|
|
72
|
+
},
|
|
73
|
+
header: {
|
|
74
|
+
...defaults.header,
|
|
75
|
+
...overrides.header
|
|
76
|
+
},
|
|
77
|
+
footer: {
|
|
78
|
+
...defaults.footer,
|
|
79
|
+
...overrides.footer
|
|
80
|
+
},
|
|
81
|
+
package: {
|
|
82
|
+
...defaults.package,
|
|
83
|
+
...overrides.package
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Same idea as `mergeTestIds`, for the CSS-selector block. */
|
|
88
|
+
function mergeSelectors(defaults, overrides) {
|
|
89
|
+
if (!overrides) return defaults;
|
|
90
|
+
return {
|
|
91
|
+
markdownBody: overrides.markdownBody ?? defaults.markdownBody,
|
|
92
|
+
loginDialog: {
|
|
93
|
+
...defaults.loginDialog,
|
|
94
|
+
...overrides.loginDialog
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
exports.DEFAULT_SELECTORS = DEFAULT_SELECTORS;
|
|
100
|
+
exports.DEFAULT_TEST_IDS = DEFAULT_TEST_IDS;
|
|
101
|
+
exports.mergeSelectors = mergeSelectors;
|
|
102
|
+
exports.mergeTestIds = mergeTestIds;
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=testIds.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testIds.cjs","names":[],"sources":["../../src/testIds.ts"],"sourcesContent":["/**\n * Configurable DOM selectors used by the e2e-ui test suites.\n *\n * The Verdaccio UI is a moving target — data-testids can and do change\n * between majors — so every selector referenced by a test lives here\n * and can be overridden by consumers of `@verdaccio/e2e-ui` via\n * `createRegistryConfig({ testIds, selectors })`.\n *\n * The defaults below match Verdaccio 6.x as of the last time we audited\n * the ui-components source. If a selector moves, override just the\n * affected field instead of forking the suite.\n */\n\n/**\n * Map of data-testid values used by the test suites, grouped by UI\n * section. Each field holds the bare testid string (no `data-testid=\"…\"`\n * wrapping) — the test helpers pass it through `cy.getByTestId(...)`.\n */\nexport interface TestIds {\n home: {\n /** Help card shown on the empty-registry landing page. */\n helpCard: string;\n /** 404 \"not found\" container. */\n notFound: string;\n };\n header: {\n /** Outermost `<NavBar>` element. */\n container: string;\n /** Inner wrapper inside the nav bar. */\n innerNavBar: string;\n /** Right-side action cluster wrapper. */\n right: string;\n /** Wrapper around the header search input. */\n searchContainer: string;\n /** Default SVG Verdaccio logo. */\n defaultLogo: string;\n /** Custom (user-provided) logo image. */\n customLogo: string;\n /** \"Login\" button shown when logged out. */\n loginButton: string;\n /** Gear icon that opens the settings dialog. */\n settingsTooltip: string;\n /** Info icon that opens the registry info dialog. */\n infoTooltip: string;\n /** Menu icon shown after login (opens the logged-in menu). */\n logInDialogIcon: string;\n /** \"Log out\" entry inside the logged-in menu. */\n logOutDialogIcon: string;\n /** \"Hi <username>\" label inside the logged-in menu. */\n greetingsLabel: string;\n };\n footer: {\n /** Outer footer wrapper. */\n container: string;\n /** \"Powered by\" version text on the right side of the footer. */\n version: string;\n };\n package: {\n /** Wrapper around the list of packages on the home page. */\n itemList: string;\n /** Package name link in the package list (home + search results). */\n title: string;\n /** Readme container on the package detail page. */\n readme: string;\n /** Sidebar container on the package detail page. */\n sidebar: string;\n /** Install commands section list. */\n installList: string;\n /** Individual install line for npm. */\n installNpm: string;\n /** Individual install line for yarn. */\n installYarn: string;\n /** Individual install line for pnpm. */\n installPnpm: string;\n /** Keyword list below the install section. */\n keywordList: string;\n /** Tab that reveals the dependencies view. */\n dependenciesTab: string;\n /** Dependencies list wrapper (one entry per dep). */\n dependencies: string;\n /** Tab that reveals the versions view. */\n versionsTab: string;\n /** \"latest\" tag row inside the versions view. */\n tagLatest: string;\n /** Tab that reveals the uplinks view. */\n uplinksTab: string;\n /** Empty-state message when the package has no uplinks. */\n noUplinks: string;\n };\n}\n\n/**\n * CSS selectors (not data-testids) used by the test suites. These are\n * things like form-field IDs and framework-specific class names that\n * Verdaccio's UI exposes as plain selectors rather than testids.\n */\nexport interface Selectors {\n /** Class applied to the parsed README markdown body. */\n markdownBody: string;\n loginDialog: {\n /** Username text input inside the login dialog. */\n usernameInput: string;\n /** Password text input inside the login dialog. */\n passwordInput: string;\n /** Submit button inside the login dialog. */\n submitButton: string;\n };\n}\n\n/**\n * Defaults matching Verdaccio 6.x (bundled ui-theme@9.0.0-next-9.x).\n * Overridable via `createRegistryConfig({ testIds: { ... } })`.\n */\nexport const DEFAULT_TEST_IDS: TestIds = {\n home: {\n helpCard: 'help-card',\n notFound: '404',\n },\n header: {\n container: 'header',\n innerNavBar: 'inner-nav-bar',\n right: 'header-right',\n searchContainer: 'search-container',\n defaultLogo: 'default-logo',\n customLogo: 'custom-logo',\n loginButton: 'header--button-login',\n settingsTooltip: 'header--tooltip-settings',\n infoTooltip: 'header--tooltip-info',\n logInDialogIcon: 'logInDialogIcon',\n logOutDialogIcon: 'logOutDialogIcon',\n greetingsLabel: 'greetings-label',\n },\n footer: {\n container: 'footer',\n version: 'version-footer',\n },\n package: {\n itemList: 'package-item-list',\n title: 'package-title',\n readme: 'readme',\n sidebar: 'sidebar',\n installList: 'installList',\n installNpm: 'installListItem-npm',\n installYarn: 'installListItem-yarn',\n installPnpm: 'installListItem-pnpm',\n keywordList: 'keyword-list',\n dependenciesTab: 'dependencies-tab',\n dependencies: 'dependencies',\n versionsTab: 'versions-tab',\n tagLatest: 'tag-latest',\n uplinksTab: 'uplinks-tab',\n noUplinks: 'no-uplinks',\n },\n};\n\n/**\n * Defaults for non-testid CSS selectors. Overridable via\n * `createRegistryConfig({ selectors: { ... } })`.\n */\nexport const DEFAULT_SELECTORS: Selectors = {\n markdownBody: '.markdown-body',\n loginDialog: {\n usernameInput: '#login--dialog-username',\n passwordInput: '#login--dialog-password',\n submitButton: '#login--dialog-button-submit',\n },\n};\n\n/** Deep-partial helper — every field of a nested object becomes optional. */\nexport type DeepPartial<T> = {\n [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];\n};\n\n/**\n * Merge user overrides into the default testIds map. Merging is\n * per-section (one level deep): `overrides.header` replaces individual\n * fields under `defaults.header` without touching `defaults.footer`.\n * The shape is fixed and small, so we enumerate sections by hand\n * rather than relying on a recursive generic merger.\n */\nexport function mergeTestIds(\n defaults: TestIds,\n overrides?: DeepPartial<TestIds>\n): TestIds {\n if (!overrides) return defaults;\n return {\n home: { ...defaults.home, ...overrides.home },\n header: { ...defaults.header, ...overrides.header },\n footer: { ...defaults.footer, ...overrides.footer },\n package: { ...defaults.package, ...overrides.package },\n };\n}\n\n/** Same idea as `mergeTestIds`, for the CSS-selector block. */\nexport function mergeSelectors(\n defaults: Selectors,\n overrides?: DeepPartial<Selectors>\n): Selectors {\n if (!overrides) return defaults;\n return {\n markdownBody: overrides.markdownBody ?? defaults.markdownBody,\n loginDialog: { ...defaults.loginDialog, ...overrides.loginDialog },\n };\n}\n"],"mappings":";;;;;AAiHA,IAAa,mBAA4B;CACvC,MAAM;EACJ,UAAU;EACV,UAAU;EACX;CACD,QAAQ;EACN,WAAW;EACX,aAAa;EACb,OAAO;EACP,iBAAiB;EACjB,aAAa;EACb,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,iBAAiB;EACjB,kBAAkB;EAClB,gBAAgB;EACjB;CACD,QAAQ;EACN,WAAW;EACX,SAAS;EACV;CACD,SAAS;EACP,UAAU;EACV,OAAO;EACP,QAAQ;EACR,SAAS;EACT,aAAa;EACb,YAAY;EACZ,aAAa;EACb,aAAa;EACb,aAAa;EACb,iBAAiB;EACjB,cAAc;EACd,aAAa;EACb,WAAW;EACX,YAAY;EACZ,WAAW;EACZ;CACF;;;;;AAMD,IAAa,oBAA+B;CAC1C,cAAc;CACd,aAAa;EACX,eAAe;EACf,eAAe;EACf,cAAc;EACf;CACF;;;;;;;;AAcD,SAAgB,aACd,UACA,WACS;AACT,KAAI,CAAC,UAAW,QAAO;AACvB,QAAO;EACL,MAAM;GAAE,GAAG,SAAS;GAAM,GAAG,UAAU;GAAM;EAC7C,QAAQ;GAAE,GAAG,SAAS;GAAQ,GAAG,UAAU;GAAQ;EACnD,QAAQ;GAAE,GAAG,SAAS;GAAQ,GAAG,UAAU;GAAQ;EACnD,SAAS;GAAE,GAAG,SAAS;GAAS,GAAG,UAAU;GAAS;EACvD;;;AAIH,SAAgB,eACd,UACA,WACW;AACX,KAAI,CAAC,UAAW,QAAO;AACvB,QAAO;EACL,cAAc,UAAU,gBAAgB,SAAS;EACjD,aAAa;GAAE,GAAG,SAAS;GAAa,GAAG,UAAU;GAAa;EACnE"}
|
package/build/cjs/tests/home.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
//#region src/tests/home.ts
|
|
2
2
|
function homeTests(config) {
|
|
3
|
+
const { home, header, package: pkg } = config.testIds;
|
|
3
4
|
describe("home", () => {
|
|
4
5
|
beforeEach(() => {
|
|
6
|
+
cy.intercept("GET", "/-/verdaccio/data/packages").as("pkgs");
|
|
5
7
|
cy.visit(config.registryUrl);
|
|
6
8
|
cy.get("body").should("be.visible");
|
|
7
9
|
});
|
|
@@ -12,19 +14,71 @@ function homeTests(config) {
|
|
|
12
14
|
cy.location("pathname").should("include", "/");
|
|
13
15
|
cy.title().should("eq", config.title);
|
|
14
16
|
});
|
|
17
|
+
it("should fetch the package list from the API", () => {
|
|
18
|
+
cy.wait("@pkgs", { timeout: 1e4 }).then((interception) => {
|
|
19
|
+
const status = interception.response?.statusCode;
|
|
20
|
+
expect(status).to.be.oneOf([200, 304]);
|
|
21
|
+
if (status === 200) expect(interception.response?.body).to.be.an("array");
|
|
22
|
+
});
|
|
23
|
+
});
|
|
15
24
|
it("should match title with no packages published", () => {
|
|
16
|
-
cy.
|
|
17
|
-
cy.getByTestId(
|
|
25
|
+
cy.wait("@pkgs");
|
|
26
|
+
cy.getByTestId(home.helpCard, { timeout: 1e4 }).should("be.visible");
|
|
27
|
+
cy.getByTestId(home.helpCard).contains("No Package Published Yet.");
|
|
18
28
|
});
|
|
19
29
|
it("should display instructions on help card", () => {
|
|
20
|
-
cy.
|
|
21
|
-
cy.getByTestId(
|
|
22
|
-
cy.getByTestId(
|
|
30
|
+
cy.wait("@pkgs");
|
|
31
|
+
cy.getByTestId(home.helpCard, { timeout: 1e4 }).should("be.visible");
|
|
32
|
+
cy.getByTestId(home.helpCard).contains(`npm adduser --registry ${config.registryUrl}`);
|
|
33
|
+
cy.getByTestId(home.helpCard).contains(`npm publish --registry ${config.registryUrl}`);
|
|
34
|
+
});
|
|
35
|
+
it("should render the header logo and login button", () => {
|
|
36
|
+
cy.getByTestId(header.container).should("be.visible");
|
|
37
|
+
cy.get(`[data-testid="${header.defaultLogo}"], [data-testid="${header.customLogo}"]`).should("be.visible");
|
|
38
|
+
cy.getByTestId(header.loginButton).should("be.visible");
|
|
39
|
+
});
|
|
40
|
+
it("should navigate back to home when clicking the header logo", () => {
|
|
41
|
+
cy.visit(`${config.registryUrl}/-/web/detail/@verdaccio/not-found`);
|
|
42
|
+
cy.getByTestId(home.notFound, { timeout: 1e4 }).should("be.visible");
|
|
43
|
+
cy.get(`[data-testid="${header.defaultLogo}"], [data-testid="${header.customLogo}"]`).first().click();
|
|
44
|
+
cy.location("pathname").should("eq", "/");
|
|
45
|
+
cy.getByTestId(home.helpCard).should("be.visible");
|
|
23
46
|
});
|
|
24
47
|
it("should go to 404 page", () => {
|
|
25
48
|
cy.visit(`${config.registryUrl}/-/web/detail/@verdaccio/not-found`);
|
|
26
|
-
cy.getByTestId(
|
|
27
|
-
cy.getByTestId(
|
|
49
|
+
cy.getByTestId(home.notFound, { timeout: 1e4 }).should("be.visible");
|
|
50
|
+
cy.getByTestId(home.notFound).contains("Sorry, we couldn't find it.");
|
|
51
|
+
});
|
|
52
|
+
describe("with a published package", () => {
|
|
53
|
+
const pkgName = "@verdaccio/home-fixture";
|
|
54
|
+
let tempFolder = null;
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
cy.task("publishPackage", {
|
|
57
|
+
pkgName,
|
|
58
|
+
version: "1.0.0",
|
|
59
|
+
unique: true
|
|
60
|
+
}).then((result) => {
|
|
61
|
+
tempFolder = result?.tempFolder ?? null;
|
|
62
|
+
});
|
|
63
|
+
cy.visit(config.registryUrl);
|
|
64
|
+
});
|
|
65
|
+
afterEach(() => {
|
|
66
|
+
cy.task("unpublishPackage", {
|
|
67
|
+
pkgName,
|
|
68
|
+
tempFolder: tempFolder ?? void 0
|
|
69
|
+
});
|
|
70
|
+
if (tempFolder) cy.task("cleanupPublished", tempFolder);
|
|
71
|
+
tempFolder = null;
|
|
72
|
+
});
|
|
73
|
+
it("should render the package list when a package exists", () => {
|
|
74
|
+
cy.wait("@pkgs");
|
|
75
|
+
cy.getByTestId(pkg.itemList).should("be.visible");
|
|
76
|
+
cy.getByTestId(pkg.title).should("have.length.at.least", 1);
|
|
77
|
+
});
|
|
78
|
+
it("should show the published package name in the list", () => {
|
|
79
|
+
cy.wait("@pkgs");
|
|
80
|
+
cy.contains(`[data-testid="${pkg.title}"]`, pkgName).should("be.visible");
|
|
81
|
+
});
|
|
28
82
|
});
|
|
29
83
|
});
|
|
30
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"home.cjs","names":[],"sources":["../../../src/tests/home.ts"],"sourcesContent":["/// <reference types=\"cypress\" />\n\nimport { RegistryConfig } from '../types';\n\nexport function homeTests(config: RegistryConfig) {\n describe('home', () => {\n beforeEach(() => {\n cy.visit(config.registryUrl);\n // Wait for the app to render\n cy.get('body').should('be.visible');\n });\n\n afterEach(() => {\n cy.wait(2000);\n });\n\n it('title should be correct', () => {\n cy.location('pathname').should('include', '/');\n cy.title().should('eq', config.title);\n });\n\n it('should match title with no packages published', () => {\n cy.
|
|
1
|
+
{"version":3,"file":"home.cjs","names":[],"sources":["../../../src/tests/home.ts"],"sourcesContent":["/// <reference types=\"cypress\" />\n\nimport { RegistryConfig } from '../types';\n\nexport function homeTests(config: RegistryConfig) {\n const { home, header, package: pkg } = config.testIds;\n\n describe('home', () => {\n beforeEach(() => {\n cy.intercept('GET', '/-/verdaccio/data/packages').as('pkgs');\n cy.visit(config.registryUrl);\n // Wait for the app to render\n cy.get('body').should('be.visible');\n });\n\n afterEach(() => {\n cy.wait(2000);\n });\n\n it('title should be correct', () => {\n cy.location('pathname').should('include', '/');\n cy.title().should('eq', config.title);\n });\n\n it('should fetch the package list from the API', () => {\n // The home page always fires /-/verdaccio/data/packages on mount;\n // verifying the endpoint is healthy is the cheapest way to catch\n // registry-side regressions before any DOM assertions.\n //\n // Accept both 200 (fresh fetch) and 304 (cache hit from a prior\n // spec run in the same session) — both indicate a healthy endpoint.\n // 304 responses have no body, so only assert array-shape on 200.\n cy.wait('@pkgs', { timeout: 10000 }).then((interception) => {\n const status = interception.response?.statusCode;\n expect(status).to.be.oneOf([200, 304]);\n if (status === 200) {\n expect(interception.response?.body).to.be.an('array');\n }\n });\n });\n\n it('should match title with no packages published', () => {\n cy.wait('@pkgs');\n cy.getByTestId(home.helpCard, { timeout: 10000 }).should('be.visible');\n cy.getByTestId(home.helpCard).contains('No Package Published Yet.');\n });\n\n it('should display instructions on help card', () => {\n cy.wait('@pkgs');\n cy.getByTestId(home.helpCard, { timeout: 10000 }).should('be.visible');\n cy.getByTestId(home.helpCard).contains(\n `npm adduser --registry ${config.registryUrl}`\n );\n cy.getByTestId(home.helpCard).contains(\n `npm publish --registry ${config.registryUrl}`\n );\n });\n\n it('should render the header logo and login button', () => {\n cy.getByTestId(header.container).should('be.visible');\n cy.get(\n `[data-testid=\"${header.defaultLogo}\"], [data-testid=\"${header.customLogo}\"]`\n ).should('be.visible');\n cy.getByTestId(header.loginButton).should('be.visible');\n });\n\n it('should navigate back to home when clicking the header logo', () => {\n // Land on the 404 page, then click the logo — URL should reset.\n cy.visit(`${config.registryUrl}/-/web/detail/@verdaccio/not-found`);\n cy.getByTestId(home.notFound, { timeout: 10000 }).should('be.visible');\n cy.get(\n `[data-testid=\"${header.defaultLogo}\"], [data-testid=\"${header.customLogo}\"]`\n )\n .first()\n .click();\n cy.location('pathname').should('eq', '/');\n cy.getByTestId(home.helpCard).should('be.visible');\n });\n\n it('should go to 404 page', () => {\n cy.visit(`${config.registryUrl}/-/web/detail/@verdaccio/not-found`);\n cy.getByTestId(home.notFound, { timeout: 10000 }).should('be.visible');\n cy.getByTestId(home.notFound).contains(\"Sorry, we couldn't find it.\");\n });\n\n // ── Rendering assertions that require real package data ─────────\n // Publishes a throwaway package before each test in this block so\n // we can verify the home page actually renders the list (not just\n // the empty state) and cleans up after each test so the outer\n // \"empty registry\" assertions above keep working in isolation.\n describe('with a published package', () => {\n const pkgName = '@verdaccio/home-fixture';\n let tempFolder: string | null = null;\n\n beforeEach(() => {\n cy.task('publishPackage', {\n pkgName,\n version: '1.0.0',\n unique: true,\n }).then((result) => {\n tempFolder = result?.tempFolder ?? null;\n });\n // Re-visit so the page picks up the just-published package.\n cy.visit(config.registryUrl);\n });\n\n afterEach(() => {\n cy.task('unpublishPackage', {\n pkgName,\n tempFolder: tempFolder ?? undefined,\n });\n if (tempFolder) {\n cy.task('cleanupPublished', tempFolder);\n }\n tempFolder = null;\n });\n\n it('should render the package list when a package exists', () => {\n cy.wait('@pkgs');\n cy.getByTestId(pkg.itemList).should('be.visible');\n cy.getByTestId(pkg.title).should('have.length.at.least', 1);\n });\n\n it('should show the published package name in the list', () => {\n cy.wait('@pkgs');\n cy.contains(`[data-testid=\"${pkg.title}\"]`, pkgName).should(\n 'be.visible'\n );\n });\n });\n });\n}\n"],"mappings":";AAIA,SAAgB,UAAU,QAAwB;CAChD,MAAM,EAAE,MAAM,QAAQ,SAAS,QAAQ,OAAO;AAE9C,UAAS,cAAc;AACrB,mBAAiB;AACf,MAAG,UAAU,OAAO,6BAA6B,CAAC,GAAG,OAAO;AAC5D,MAAG,MAAM,OAAO,YAAY;AAE5B,MAAG,IAAI,OAAO,CAAC,OAAO,aAAa;IACnC;AAEF,kBAAgB;AACd,MAAG,KAAK,IAAK;IACb;AAEF,KAAG,iCAAiC;AAClC,MAAG,SAAS,WAAW,CAAC,OAAO,WAAW,IAAI;AAC9C,MAAG,OAAO,CAAC,OAAO,MAAM,OAAO,MAAM;IACrC;AAEF,KAAG,oDAAoD;AAQrD,MAAG,KAAK,SAAS,EAAE,SAAS,KAAO,CAAC,CAAC,MAAM,iBAAiB;IAC1D,MAAM,SAAS,aAAa,UAAU;AACtC,WAAO,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC;AACtC,QAAI,WAAW,IACb,QAAO,aAAa,UAAU,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AU;GAChB,IAAI,aAA4B;AAEhC,oBAAiB;AACf,OAAG,KAAK,kBAAkB;KACxB;KACA,SAAS;KACT,QAAQ;KACT,CAAC,CAAC,MAAM,WAAW;AAClB,kBAAa,QAAQ,cAAc;MACnC;AAEF,OAAG,MAAM,OAAO,YAAY;KAC5B;AAEF,mBAAgB;AACd,OAAG,KAAK,oBAAoB;KAC1B;KACA,YAAY,cAAc,KAAA;KAC3B,CAAC;AACF,QAAI,WACF,IAAG,KAAK,oBAAoB,WAAW;AAEzC,iBAAa;KACb;AAEF,MAAG,8DAA8D;AAC/D,OAAG,KAAK,QAAQ;AAChB,OAAG,YAAY,IAAI,SAAS,CAAC,OAAO,aAAa;AACjD,OAAG,YAAY,IAAI,MAAM,CAAC,OAAO,wBAAwB,EAAE;KAC3D;AAEF,MAAG,4DAA4D;AAC7D,OAAG,KAAK,QAAQ;AAChB,OAAG,SAAS,iBAAiB,IAAI,MAAM,KAAK,QAAQ,CAAC,OACnD,aACD;KACD;IACF;GACF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
//#region src/tests/layout.ts
|
|
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
|
+
function layoutTests(config) {
|
|
13
|
+
const { header, footer } = config.testIds;
|
|
14
|
+
describe("layout: header, footer, ui-options", () => {
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
cy.intercept("GET", "**/-/static/ui-options.js").as("uiOptions");
|
|
17
|
+
cy.visit(config.registryUrl);
|
|
18
|
+
cy.get("body").should("be.visible");
|
|
19
|
+
});
|
|
20
|
+
it("should load /-/static/ui-options.js with HTTP 200", () => {
|
|
21
|
+
cy.wait("@uiOptions", { timeout: 1e4 }).its("response.statusCode").should("eq", 200);
|
|
22
|
+
});
|
|
23
|
+
it("should serve ui-options.js with a JavaScript content-type", () => {
|
|
24
|
+
cy.wait("@uiOptions", { timeout: 1e4 }).then((interception) => {
|
|
25
|
+
const contentType = interception.response?.headers?.["content-type"] || "";
|
|
26
|
+
expect(contentType).to.match(/javascript/i);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
it("should expose window.__VERDACCIO_BASENAME_UI_OPTIONS at runtime", () => {
|
|
30
|
+
cy.wait("@uiOptions", { timeout: 1e4 });
|
|
31
|
+
cy.window().its("__VERDACCIO_BASENAME_UI_OPTIONS").should("be.an", "object");
|
|
32
|
+
});
|
|
33
|
+
describe("header", () => {
|
|
34
|
+
it("should render the header container", () => {
|
|
35
|
+
cy.getByTestId(header.container).should("be.visible");
|
|
36
|
+
cy.getByTestId(header.innerNavBar).should("be.visible");
|
|
37
|
+
});
|
|
38
|
+
it("should render the logo", () => {
|
|
39
|
+
cy.get(`[data-testid="${header.defaultLogo}"], [data-testid="${header.customLogo}"]`).should("be.visible");
|
|
40
|
+
});
|
|
41
|
+
it("should render the search container", () => {
|
|
42
|
+
cy.getByTestId(header.searchContainer).should("be.visible");
|
|
43
|
+
});
|
|
44
|
+
it("should render the header-right action cluster", () => {
|
|
45
|
+
cy.getByTestId(header.right).should("be.visible");
|
|
46
|
+
});
|
|
47
|
+
it("should render the login button when logged out", () => {
|
|
48
|
+
cy.getByTestId(header.loginButton).should("be.visible");
|
|
49
|
+
});
|
|
50
|
+
it("should render the settings and info buttons", () => {
|
|
51
|
+
cy.getByTestId(header.settingsTooltip).should("be.visible");
|
|
52
|
+
cy.getByTestId(header.infoTooltip).should("be.visible");
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe("footer", () => {
|
|
56
|
+
it("should render the footer container", () => {
|
|
57
|
+
cy.getByTestId(footer.container).scrollIntoView().should("be.visible");
|
|
58
|
+
});
|
|
59
|
+
it("should render the version marker with the powered-by label", () => {
|
|
60
|
+
cy.getByTestId(footer.version).scrollIntoView().should("be.visible").invoke("text").should("have.length.greaterThan", 0);
|
|
61
|
+
});
|
|
62
|
+
it("should render a logo next to the version marker", () => {
|
|
63
|
+
cy.getByTestId(footer.container).find(`[data-testid="${header.defaultLogo}"], [data-testid="${header.customLogo}"]`).should("exist");
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
exports.layoutTests = layoutTests;
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=layout.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.cjs","names":[],"sources":["../../../src/tests/layout.ts"],"sourcesContent":["/// <reference types=\"cypress\" />\n\nimport { RegistryConfig } from '../types';\n\n/**\n * Tests for the persistent page chrome: the header (nav bar, logo,\n * search container, action buttons) and the footer (version marker).\n * Also asserts that the runtime UI configuration endpoint\n * `/-/static/ui-options.js` loads successfully — this endpoint emits\n * `window.__VERDACCIO_BASENAME_UI_OPTIONS`, which the ui-theme relies\n * on for feature flags like showFooter / showSearch / showSettings. If\n * it fails the whole SPA degrades to whatever defaults the provider\n * ships with, so it's worth a direct network-level check.\n */\nexport function layoutTests(config: RegistryConfig) {\n const { header, footer } = config.testIds;\n\n describe('layout: header, footer, ui-options', () => {\n beforeEach(() => {\n cy.intercept('GET', '**/-/static/ui-options.js').as('uiOptions');\n cy.visit(config.registryUrl);\n cy.get('body').should('be.visible');\n });\n\n it('should load /-/static/ui-options.js with HTTP 200', () => {\n cy.wait('@uiOptions', { timeout: 10000 })\n .its('response.statusCode')\n .should('eq', 200);\n });\n\n it('should serve ui-options.js with a JavaScript content-type', () => {\n cy.wait('@uiOptions', { timeout: 10000 }).then((interception: any) => {\n const contentType =\n interception.response?.headers?.['content-type'] || '';\n // Verdaccio serves this as `application/javascript` (possibly\n // with a charset suffix). Match loosely so small header tweaks\n // don't break the test.\n expect(contentType).to.match(/javascript/i);\n });\n });\n\n it('should expose window.__VERDACCIO_BASENAME_UI_OPTIONS at runtime', () => {\n cy.wait('@uiOptions', { timeout: 10000 });\n // ui-options.js sets this global before the React app boots, so\n // by the time the body is visible it should already be populated.\n cy.window()\n .its('__VERDACCIO_BASENAME_UI_OPTIONS')\n .should('be.an', 'object');\n });\n\n describe('header', () => {\n it('should render the header container', () => {\n cy.getByTestId(header.container).should('be.visible');\n cy.getByTestId(header.innerNavBar).should('be.visible');\n });\n\n it('should render the logo', () => {\n // Either the default SVG logo or a user-provided custom one.\n cy.get(\n `[data-testid=\"${header.defaultLogo}\"], [data-testid=\"${header.customLogo}\"]`\n ).should('be.visible');\n });\n\n it('should render the search container', () => {\n cy.getByTestId(header.searchContainer).should('be.visible');\n });\n\n it('should render the header-right action cluster', () => {\n cy.getByTestId(header.right).should('be.visible');\n });\n\n it('should render the login button when logged out', () => {\n cy.getByTestId(header.loginButton).should('be.visible');\n });\n\n it('should render the settings and info buttons', () => {\n // Both depend on `showSettings` / `showInfo` being truthy in\n // the ui-options response. On the default config provider\n // they default to true so no explicit registry config is\n // required.\n cy.getByTestId(header.settingsTooltip).should('be.visible');\n cy.getByTestId(header.infoTooltip).should('be.visible');\n });\n });\n\n describe('footer', () => {\n it('should render the footer container', () => {\n cy.getByTestId(footer.container).scrollIntoView().should('be.visible');\n });\n\n it('should render the version marker with the powered-by label', () => {\n // <PoweredBy> only renders when `configOptions.version` is\n // truthy, which Verdaccio sets automatically from its\n // package.json at startup.\n cy.getByTestId(footer.version)\n .scrollIntoView()\n .should('be.visible')\n .invoke('text')\n .should('have.length.greaterThan', 0);\n });\n\n it('should render a logo next to the version marker', () => {\n // The footer uses the default SVG logo as the link to\n // verdaccio.org.\n cy.getByTestId(footer.container)\n .find(\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O,YAAY,CAAC,OAAO,aAAa;KACvD;AAEF,MAAG,qDAAqD;AAKtD,OAAG,YAAY,OAAO,gBAAgB,CAAC,OAAO,aAAa;AAC3D,OAAG,YAAY,OAAO,YAAY,CAAC,OAAO,aAAa;KACvD;IACF;AAEF,WAAS,gBAAgB;AACvB,MAAG,4CAA4C;AAC7C,OAAG,YAAY,OAAO,UAAU,CAAC,gBAAgB,CAAC,OAAO,aAAa;KACtE;AAEF,MAAG,oEAAoE;AAIrE,OAAG,YAAY,OAAO,QAAQ,CAC3B,gBAAgB,CAChB,OAAO,aAAa,CACpB,OAAO,OAAO,CACd,OAAO,2BAA2B,EAAE;KACvC;AAEF,MAAG,yDAAyD;AAG1D,OAAG,YAAY,OAAO,UAAU,CAC7B,KACC,iBAAiB,OAAO,YAAY,oBAAoB,OAAO,WAAW,IAC3E,CACA,OAAO,QAAQ;KAClB;IACF;GACF"}
|
|
@@ -1,75 +1,125 @@
|
|
|
1
1
|
//#region src/tests/publish.ts
|
|
2
2
|
function publishTests(config) {
|
|
3
|
+
const { header, package: pkg } = config.testIds;
|
|
4
|
+
const { markdownBody, loginDialog } = config.selectors;
|
|
3
5
|
describe("publish", () => {
|
|
4
6
|
const pkgName = "@verdaccio/pkg-scoped";
|
|
7
|
+
let tempFolder = null;
|
|
8
|
+
/**
|
|
9
|
+
* Log in once, reuse the session across every test in this suite.
|
|
10
|
+
* `cy.session` caches cookies + localStorage keyed on the first
|
|
11
|
+
* argument, so subsequent calls restore without hitting the network.
|
|
12
|
+
*/
|
|
13
|
+
const loginOnce = () => {
|
|
14
|
+
cy.session(["publish-suite", config.credentials.user], () => {
|
|
15
|
+
cy.visit(config.registryUrl);
|
|
16
|
+
cy.login(config.credentials.user, config.credentials.password, {
|
|
17
|
+
loginButton: header.loginButton,
|
|
18
|
+
...loginDialog
|
|
19
|
+
});
|
|
20
|
+
cy.wait("@sign");
|
|
21
|
+
}, {
|
|
22
|
+
validate() {
|
|
23
|
+
cy.request({
|
|
24
|
+
url: `${config.registryUrl}/-/verdaccio/data/packages`,
|
|
25
|
+
failOnStatusCode: false
|
|
26
|
+
}).its("status").should("be.oneOf", [200, 304]);
|
|
27
|
+
},
|
|
28
|
+
cacheAcrossSpecs: true
|
|
29
|
+
});
|
|
30
|
+
};
|
|
5
31
|
beforeEach(() => {
|
|
6
32
|
cy.intercept("POST", "/-/verdaccio/sec/login").as("sign");
|
|
7
33
|
cy.intercept("GET", "/-/verdaccio/data/packages").as("pkgs");
|
|
8
34
|
cy.intercept("GET", `/-/verdaccio/data/sidebar/${pkgName}`).as("sidebar");
|
|
9
35
|
cy.intercept("GET", `/-/verdaccio/data/package/readme/${pkgName}`).as("readme");
|
|
10
|
-
cy.task("
|
|
36
|
+
cy.task("publishPackage", {
|
|
37
|
+
pkgName,
|
|
38
|
+
version: "1.0.0",
|
|
39
|
+
dependencies: { debug: "4.0.0" },
|
|
40
|
+
unique: true
|
|
41
|
+
}).then((result) => {
|
|
42
|
+
tempFolder = result?.tempFolder ?? null;
|
|
43
|
+
});
|
|
44
|
+
loginOnce();
|
|
45
|
+
cy.visit(config.registryUrl);
|
|
46
|
+
});
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
cy.task("unpublishPackage", {
|
|
49
|
+
pkgName,
|
|
50
|
+
tempFolder: tempFolder ?? void 0
|
|
51
|
+
});
|
|
52
|
+
if (tempFolder) cy.task("cleanupPublished", tempFolder);
|
|
53
|
+
tempFolder = null;
|
|
11
54
|
});
|
|
12
55
|
it("should have one published package", () => {
|
|
13
|
-
cy.
|
|
14
|
-
cy.
|
|
15
|
-
cy.wait("@sign");
|
|
56
|
+
cy.wait("@pkgs");
|
|
57
|
+
cy.getByTestId(pkg.title).should("have.length.at.least", 1);
|
|
16
58
|
});
|
|
17
59
|
it("should navigate to page detail", () => {
|
|
18
|
-
cy.visit(config.registryUrl);
|
|
19
|
-
cy.login(config.credentials.user, config.credentials.password);
|
|
20
|
-
cy.wait("@sign");
|
|
21
60
|
cy.wait("@pkgs");
|
|
22
61
|
cy.wait(300);
|
|
23
|
-
cy.getByTestId(
|
|
62
|
+
cy.getByTestId(pkg.title).first().click();
|
|
24
63
|
});
|
|
25
64
|
it("should have readme content", () => {
|
|
26
|
-
cy.visit(config.registryUrl);
|
|
27
|
-
cy.login(config.credentials.user, config.credentials.password);
|
|
28
|
-
cy.wait("@sign");
|
|
29
65
|
cy.wait("@pkgs");
|
|
30
|
-
cy.getByTestId(
|
|
66
|
+
cy.getByTestId(pkg.title).first().click();
|
|
31
67
|
cy.wait("@readme");
|
|
32
68
|
cy.wait("@sidebar");
|
|
33
|
-
cy.
|
|
34
|
-
cy.
|
|
69
|
+
cy.getByTestId(pkg.readme).should("be.visible");
|
|
70
|
+
cy.get(markdownBody).should("have.length", 1);
|
|
71
|
+
cy.contains(markdownBody, /test/);
|
|
72
|
+
cy.contains(`${markdownBody} h1`, pkgName).should("be.visible");
|
|
73
|
+
});
|
|
74
|
+
it("should render the sidebar with install commands for npm, yarn, pnpm", () => {
|
|
75
|
+
cy.wait("@pkgs");
|
|
76
|
+
cy.getByTestId(pkg.title).first().click();
|
|
77
|
+
cy.wait("@sidebar");
|
|
78
|
+
cy.getByTestId(pkg.sidebar).should("be.visible");
|
|
79
|
+
cy.getByTestId(pkg.installList).within(() => {
|
|
80
|
+
cy.getByTestId(pkg.installNpm).should("be.visible");
|
|
81
|
+
cy.getByTestId(pkg.installYarn).should("be.visible");
|
|
82
|
+
cy.getByTestId(pkg.installPnpm).should("be.visible");
|
|
83
|
+
});
|
|
84
|
+
cy.getByTestId(pkg.installNpm).should("contain.text", pkgName);
|
|
85
|
+
});
|
|
86
|
+
it("should render the sidebar keywords from the published manifest", () => {
|
|
87
|
+
cy.wait("@pkgs");
|
|
88
|
+
cy.getByTestId(pkg.title).first().click();
|
|
89
|
+
cy.wait("@sidebar");
|
|
90
|
+
cy.getByTestId(pkg.keywordList).should("be.visible");
|
|
91
|
+
cy.getByTestId(pkg.keywordList).should("contain.text", "verdaccio");
|
|
92
|
+
cy.getByTestId(pkg.keywordList).should("contain.text", "e2e");
|
|
93
|
+
cy.getByTestId(pkg.keywordList).should("contain.text", "test");
|
|
35
94
|
});
|
|
36
95
|
it("should click on dependencies tab", () => {
|
|
37
|
-
cy.visit(config.registryUrl);
|
|
38
|
-
cy.login(config.credentials.user, config.credentials.password);
|
|
39
|
-
cy.wait("@sign");
|
|
40
96
|
cy.wait("@pkgs");
|
|
41
97
|
cy.wait(300);
|
|
42
|
-
cy.getByTestId(
|
|
98
|
+
cy.getByTestId(pkg.title).first().click();
|
|
43
99
|
cy.wait("@readme");
|
|
44
100
|
cy.wait("@sidebar");
|
|
45
|
-
cy.getByTestId(
|
|
101
|
+
cy.getByTestId(pkg.dependenciesTab).click();
|
|
46
102
|
cy.wait(100);
|
|
47
|
-
cy.getByTestId(
|
|
48
|
-
cy.getByTestId("
|
|
103
|
+
cy.getByTestId(pkg.dependencies).should("have.length", 1);
|
|
104
|
+
cy.getByTestId("debug").children().invoke("text").should("match", /debug/);
|
|
49
105
|
});
|
|
50
106
|
it("should click on versions tab", () => {
|
|
51
|
-
cy.visit(config.registryUrl);
|
|
52
|
-
cy.login(config.credentials.user, config.credentials.password);
|
|
53
|
-
cy.wait("@sign");
|
|
54
107
|
cy.wait("@pkgs");
|
|
55
108
|
cy.wait(300);
|
|
56
|
-
cy.getByTestId(
|
|
109
|
+
cy.getByTestId(pkg.title).first().click();
|
|
57
110
|
cy.wait("@readme");
|
|
58
111
|
cy.wait("@sidebar");
|
|
59
|
-
cy.getByTestId(
|
|
60
|
-
cy.getByTestId(
|
|
112
|
+
cy.getByTestId(pkg.versionsTab).click();
|
|
113
|
+
cy.getByTestId(pkg.tagLatest).children().invoke("text").should("match", /1\.0\.0/);
|
|
61
114
|
});
|
|
62
115
|
it("should click on uplinks tab", () => {
|
|
63
|
-
cy.visit(config.registryUrl);
|
|
64
|
-
cy.login(config.credentials.user, config.credentials.password);
|
|
65
|
-
cy.wait("@sign");
|
|
66
116
|
cy.wait("@pkgs");
|
|
67
117
|
cy.wait(300);
|
|
68
|
-
cy.getByTestId(
|
|
118
|
+
cy.getByTestId(pkg.title).first().click();
|
|
69
119
|
cy.wait("@readme");
|
|
70
120
|
cy.wait("@sidebar");
|
|
71
|
-
cy.getByTestId(
|
|
72
|
-
cy.getByTestId(
|
|
121
|
+
cy.getByTestId(pkg.uplinksTab).click();
|
|
122
|
+
cy.getByTestId(pkg.noUplinks).should("be.visible");
|
|
73
123
|
});
|
|
74
124
|
});
|
|
75
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.cjs","names":[],"sources":["../../../src/tests/publish.ts"],"sourcesContent":["/// <reference types=\"cypress\" />\n\nimport { RegistryConfig } from '../types';\n\nexport function publishTests(config: RegistryConfig) {\n describe('publish', () => {\n const pkgName = '@verdaccio/pkg-scoped';\n\n beforeEach(() => {\n cy.intercept('POST', '/-/verdaccio/sec/login').as('sign');\n cy.intercept('GET', '/-/verdaccio/data/packages').as('pkgs');\n cy.intercept('GET', `/-/verdaccio/data/sidebar/${pkgName}`).as('sidebar');\n cy.intercept('GET', `/-/verdaccio/data/package/readme/${pkgName}`).as('readme');\n cy.task('
|
|
1
|
+
{"version":3,"file":"publish.cjs","names":[],"sources":["../../../src/tests/publish.ts"],"sourcesContent":["/// <reference types=\"cypress\" />\n\nimport { RegistryConfig } from '../types';\n\nexport function publishTests(config: RegistryConfig) {\n const { header, package: pkg } = config.testIds;\n const { markdownBody, loginDialog } = config.selectors;\n\n describe('publish', () => {\n const pkgName = '@verdaccio/pkg-scoped';\n // Per-test state so afterEach can clean up the specific publish\n // that this test created (temp folder + registry entry).\n let tempFolder: string | null = null;\n\n /**\n * Log in once, reuse the session across every test in this suite.\n * `cy.session` caches cookies + localStorage keyed on the first\n * argument, so subsequent calls restore without hitting the network.\n */\n const loginOnce = () => {\n cy.session(\n ['publish-suite', config.credentials.user],\n () => {\n cy.visit(config.registryUrl);\n cy.login(config.credentials.user, config.credentials.password, {\n loginButton: header.loginButton,\n ...loginDialog,\n });\n cy.wait('@sign');\n },\n {\n validate() {\n cy.request({\n url: `${config.registryUrl}/-/verdaccio/data/packages`,\n failOnStatusCode: false,\n })\n .its('status')\n .should('be.oneOf', [200, 304]);\n },\n cacheAcrossSpecs: true,\n }\n );\n };\n\n beforeEach(() => {\n cy.intercept('POST', '/-/verdaccio/sec/login').as('sign');\n cy.intercept('GET', '/-/verdaccio/data/packages').as('pkgs');\n cy.intercept('GET', `/-/verdaccio/data/sidebar/${pkgName}`).as('sidebar');\n cy.intercept('GET', `/-/verdaccio/data/package/readme/${pkgName}`).as('readme');\n\n // Publish a fresh copy for this test. `unique: true` appends a\n // timestamp suffix so the version is distinct per test even when\n // the registry briefly has a stale copy from a prior afterEach.\n cy.task('publishPackage', {\n pkgName,\n version: '1.0.0',\n dependencies: { debug: '4.0.0' },\n unique: true,\n }).then((result) => {\n tempFolder = result?.tempFolder ?? null;\n });\n\n loginOnce();\n cy.visit(config.registryUrl);\n });\n\n afterEach(() => {\n // Remove the package from the registry AND the local temp folder.\n // Run both regardless of test outcome so the next test starts\n // clean. `unpublishPackage` treats 404 as success, so a re-run\n // after a half-published state is still safe.\n cy.task('unpublishPackage', { pkgName, tempFolder: tempFolder ?? undefined });\n if (tempFolder) {\n cy.task('cleanupPublished', tempFolder);\n }\n tempFolder = null;\n });\n\n it('should have one published package', () => {\n cy.wait('@pkgs');\n cy.getByTestId(pkg.title).should('have.length.at.least', 1);\n });\n\n it('should navigate to page detail', () => {\n cy.wait('@pkgs');\n cy.wait(300);\n cy.getByTestId(pkg.title).first().click();\n });\n\n it('should have readme content', () => {\n cy.wait('@pkgs');\n cy.getByTestId(pkg.title).first().click();\n cy.wait('@readme');\n cy.wait('@sidebar');\n cy.getByTestId(pkg.readme).should('be.visible');\n cy.get(markdownBody).should('have.length', 1);\n // publishPackage writes a README whose body contains \"e2e testing\".\n cy.contains(markdownBody, /test/);\n cy.contains(`${markdownBody} h1`, pkgName).should('be.visible');\n });\n\n it('should render the sidebar with install commands for npm, yarn, pnpm', () => {\n cy.wait('@pkgs');\n cy.getByTestId(pkg.title).first().click();\n cy.wait('@sidebar');\n cy.getByTestId(pkg.sidebar).should('be.visible');\n cy.getByTestId(pkg.installList).within(() => {\n cy.getByTestId(pkg.installNpm).should('be.visible');\n cy.getByTestId(pkg.installYarn).should('be.visible');\n cy.getByTestId(pkg.installPnpm).should('be.visible');\n });\n cy.getByTestId(pkg.installNpm).should('contain.text', pkgName);\n });\n\n it('should render the sidebar keywords from the published manifest', () => {\n cy.wait('@pkgs');\n cy.getByTestId(pkg.title).first().click();\n cy.wait('@sidebar');\n // publishPackage writes `keywords: ['verdaccio', 'e2e', 'test']`\n // into the generated package.json.\n cy.getByTestId(pkg.keywordList).should('be.visible');\n cy.getByTestId(pkg.keywordList).should('contain.text', 'verdaccio');\n cy.getByTestId(pkg.keywordList).should('contain.text', 'e2e');\n cy.getByTestId(pkg.keywordList).should('contain.text', 'test');\n });\n\n it('should click on dependencies tab', () => {\n cy.wait('@pkgs');\n cy.wait(300);\n cy.getByTestId(pkg.title).first().click();\n cy.wait('@readme');\n cy.wait('@sidebar');\n cy.getByTestId(pkg.dependenciesTab).click();\n cy.wait(100);\n cy.getByTestId(pkg.dependencies).should('have.length', 1);\n // The dep is rendered with its name as testid. This is a dynamic\n // Verdaccio convention (not configurable via testIds map).\n cy.getByTestId('debug').children().invoke('text').should('match', /debug/);\n });\n\n it('should click on versions tab', () => {\n cy.wait('@pkgs');\n cy.wait(300);\n cy.getByTestId(pkg.title).first().click();\n cy.wait('@readme');\n cy.wait('@sidebar');\n cy.getByTestId(pkg.versionsTab).click();\n // With `unique: true` the version becomes `1.0.0-t<timestamp>`,\n // but \"1.0.0\" still appears as a substring — match loosely.\n cy.getByTestId(pkg.tagLatest)\n .children()\n .invoke('text')\n .should('match', /1\\.0\\.0/);\n });\n\n it('should click on uplinks tab', () => {\n cy.wait('@pkgs');\n cy.wait(300);\n cy.getByTestId(pkg.title).first().click();\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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
|
+
function searchTests(config) {
|
|
11
|
+
describe("search", () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
cy.intercept("GET", "**/-/verdaccio/data/search/**").as("webSearch");
|
|
14
|
+
cy.intercept("GET", "**/-/v1/search**").as("v1Search");
|
|
15
|
+
cy.intercept("GET", "**/-/verdaccio/data/packages").as("pkgs");
|
|
16
|
+
cy.visit(config.registryUrl);
|
|
17
|
+
cy.get("body").should("be.visible");
|
|
18
|
+
});
|
|
19
|
+
it("should render the search input", () => {
|
|
20
|
+
getSearchInput().should("be.visible");
|
|
21
|
+
});
|
|
22
|
+
it("should fire a search request when typing a query", () => {
|
|
23
|
+
const query = "verdaccio";
|
|
24
|
+
getSearchInput().clear().type(query, { delay: 30 });
|
|
25
|
+
cy.wait(anySearchAlias(), { timeout: 1e4 }).then((interception) => {
|
|
26
|
+
expect(interception.request.url).to.contain(query);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
it("should show a \"no results\" state for an impossible query", () => {
|
|
30
|
+
const query = "xyzzy-no-such-package-" + Date.now();
|
|
31
|
+
getSearchInput().clear().type(query, { delay: 30 });
|
|
32
|
+
cy.wait(anySearchAlias(), { timeout: 1e4 });
|
|
33
|
+
cy.wait(300);
|
|
34
|
+
cy.contains(/no\s+(match|results|packages)/i, { timeout: 5e3 }).should("be.visible");
|
|
35
|
+
});
|
|
36
|
+
it("should clear the query and allow typing a new one", () => {
|
|
37
|
+
getSearchInput().clear().type("first-query", { delay: 20 });
|
|
38
|
+
cy.wait(anySearchAlias(), { timeout: 1e4 });
|
|
39
|
+
getSearchInput().clear();
|
|
40
|
+
getSearchInput().should("have.value", "");
|
|
41
|
+
getSearchInput().type("second-query", { delay: 20 });
|
|
42
|
+
cy.wait(anySearchAlias(), { timeout: 1e4 }).then((interception) => {
|
|
43
|
+
expect(interception.request.url).to.contain("second-query");
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolve the search input. Verdaccio 6 renders it with different
|
|
50
|
+
* data-testid values across versions, so we try a few in order before
|
|
51
|
+
* falling back to a generic role/type selector.
|
|
52
|
+
*/
|
|
53
|
+
function getSearchInput() {
|
|
54
|
+
return cy.get([
|
|
55
|
+
"[data-testid=\"search-input\"]",
|
|
56
|
+
"[data-testid=\"header--input-search\"]",
|
|
57
|
+
"[data-testid=\"autoCompleteSearch\"] input",
|
|
58
|
+
"input[aria-label*=\"earch\"]",
|
|
59
|
+
"input[placeholder*=\"earch\"]",
|
|
60
|
+
"input[type=\"search\"]"
|
|
61
|
+
].join(", "), { timeout: 1e4 });
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Cypress `cy.wait` only accepts one alias at a time, so pick whichever
|
|
65
|
+
* alias fires first. This helper lets us stay agnostic to which search
|
|
66
|
+
* endpoint the UI is wired to.
|
|
67
|
+
*/
|
|
68
|
+
function anySearchAlias() {
|
|
69
|
+
return "@webSearch";
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
exports.searchTests = searchTests;
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=search.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.cjs","names":[],"sources":["../../../src/tests/search.ts"],"sourcesContent":["/// <reference types=\"cypress\" />\n\nimport { RegistryConfig } from '../types';\n\n/**\n * UI tests for the Verdaccio search box.\n *\n * These tests do NOT depend on any published package — they assert the\n * search *flow* (input exists, typing triggers the search API, results\n * region updates) rather than specific package metadata. Tests that need\n * a real package in the registry should live in publishTests instead.\n */\nexport function searchTests(config: RegistryConfig) {\n describe('search', () => {\n beforeEach(() => {\n // Verdaccio's search endpoint — covers both the web API and the\n // npm v1 search API, depending on which one the UI calls.\n cy.intercept('GET', '**/-/verdaccio/data/search/**').as('webSearch');\n cy.intercept('GET', '**/-/v1/search**').as('v1Search');\n cy.intercept('GET', '**/-/verdaccio/data/packages').as('pkgs');\n\n cy.visit(config.registryUrl);\n cy.get('body').should('be.visible');\n });\n\n it('should render the search input', () => {\n getSearchInput().should('be.visible');\n });\n\n it('should fire a search request when typing a query', () => {\n const query = 'verdaccio';\n\n getSearchInput().clear().type(query, { delay: 30 });\n\n // Whichever endpoint the UI is wired to, at least one should hit.\n cy.wait(anySearchAlias(), { timeout: 10000 }).then((interception: any) => {\n expect(interception.request.url).to.contain(query);\n });\n });\n\n it('should show a \"no results\" state for an impossible query', () => {\n const query = 'xyzzy-no-such-package-' + Date.now();\n\n getSearchInput().clear().type(query, { delay: 30 });\n cy.wait(anySearchAlias(), { timeout: 10000 });\n\n // Give the UI a tick to render the empty state.\n cy.wait(300);\n\n // The UI may render \"No Match\", \"No results\", or similar — match\n // loosely rather than binding to one exact string.\n cy.contains(/no\\s+(match|results|packages)/i, { timeout: 5000 }).should(\n 'be.visible'\n );\n });\n\n it('should clear the query and allow typing a new one', () => {\n getSearchInput().clear().type('first-query', { delay: 20 });\n cy.wait(anySearchAlias(), { timeout: 10000 });\n\n // Clearing should empty the input value. We deliberately do NOT\n // assert on the autocomplete dropdown's empty-state text: on a\n // registry with no packages published it lingers regardless of\n // the input value, which previously caused a false positive.\n getSearchInput().clear();\n getSearchInput().should('have.value', '');\n\n // Typing a fresh query must fire another search request so the\n // search box is still functional after a clear.\n getSearchInput().type('second-query', { delay: 20 });\n cy.wait(anySearchAlias(), { timeout: 10000 }).then(\n (interception: any) => {\n expect(interception.request.url).to.contain('second-query');\n }\n );\n });\n });\n}\n\n/**\n * Resolve the search input. Verdaccio 6 renders it with different\n * data-testid values across versions, so we try a few in order before\n * falling back to a generic role/type selector.\n */\nfunction getSearchInput() {\n return cy.get(\n [\n '[data-testid=\"search-input\"]',\n '[data-testid=\"header--input-search\"]',\n '[data-testid=\"autoCompleteSearch\"] input',\n 'input[aria-label*=\"earch\"]',\n 'input[placeholder*=\"earch\"]',\n 'input[type=\"search\"]',\n ].join(', '),\n { timeout: 10000 }\n );\n}\n\n/**\n * Cypress `cy.wait` only accepts one alias at a time, so pick whichever\n * alias fires first. This helper lets us stay agnostic to which search\n * endpoint the UI is wired to.\n */\nfunction anySearchAlias(): string {\n // In practice most Verdaccio 6 builds call the web search endpoint;\n // prefer that one and let the test fail loud if neither fires.\n return '@webSearch';\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,YAAY,QAAwB;AAClD,UAAS,gBAAgB;AACvB,mBAAiB;AAGf,MAAG,UAAU,OAAO,gCAAgC,CAAC,GAAG,YAAY;AACpE,MAAG,UAAU,OAAO,mBAAmB,CAAC,GAAG,WAAW;AACtD,MAAG,UAAU,OAAO,+BAA+B,CAAC,GAAG,OAAO;AAE9D,MAAG,MAAM,OAAO,YAAY;AAC5B,MAAG,IAAI,OAAO,CAAC,OAAO,aAAa;IACnC;AAEF,KAAG,wCAAwC;AACzC,mBAAgB,CAAC,OAAO,aAAa;IACrC;AAEF,KAAG,0DAA0D;GAC3D,MAAM,QAAQ;AAEd,mBAAgB,CAAC,OAAO,CAAC,KAAK,OAAO,EAAE,OAAO,IAAI,CAAC;AAGnD,MAAG,KAAK,gBAAgB,EAAE,EAAE,SAAS,KAAO,CAAC,CAAC,MAAM,iBAAsB;AACxE,WAAO,aAAa,QAAQ,IAAI,CAAC,GAAG,QAAQ,MAAM;KAClD;IACF;AAEF,KAAG,oEAAkE;GACnE,MAAM,QAAQ,2BAA2B,KAAK,KAAK;AAEnD,mBAAgB,CAAC,OAAO,CAAC,KAAK,OAAO,EAAE,OAAO,IAAI,CAAC;AACnD,MAAG,KAAK,gBAAgB,EAAE,EAAE,SAAS,KAAO,CAAC;AAG7C,MAAG,KAAK,IAAI;AAIZ,MAAG,SAAS,kCAAk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