Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions e2e/remote/ansible-collection-versions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,9 @@ test('adding a collection version shows it in the tab and removing it empties th
).toBeVisible();
await expect.poll(latestVersion, { timeout: 60_000 }).toBe(1);

// the tab lists the content of the version the repository had when the page
// loaded, so the page is loaded again to see the new version
await page.goto(tabUrl());
// the tab follows the task and lists the new version without a page load
const added = page.getByRole('row').filter({ hasText: label() });
await expect(added).toBeVisible();
await expect(added).toBeVisible({ timeout: 60_000 });
await expect(page.getByText(EMPTY_STATE)).toHaveCount(0);

await added.locator('[data-cy=kebab-toggle] button').click();
Expand All @@ -152,8 +150,7 @@ test('adding a collection version shows it in the tab and removing it empties th
).toBeVisible();
await expect.poll(latestVersion, { timeout: 60_000 }).toBe(2);

await page.goto(tabUrl());
await expect(page.getByText(EMPTY_STATE)).toBeVisible();
await expect(page.getByText(EMPTY_STATE)).toBeVisible({ timeout: 60_000 });
await expect(page.getByRole('row').filter({ hasText: label() })).toHaveCount(
0,
);
Expand Down
8 changes: 6 additions & 2 deletions e2e/remote/list-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ export const listPages: ListPage[] = [
];

// The components the server reports in status/ versions, read once per
// worker.
// worker. A failed read is not kept, so the next test asks again instead of
// failing with the same error.
let installed: Promise<Set<string>> | undefined;

export function installedPlugins(): Promise<Set<string>> {
Expand All @@ -199,7 +200,10 @@ export function installedPlugins(): Promise<Set<string>> {
} finally {
await api.dispose();
}
})();
})().catch((error) => {
installed = undefined;
throw error;
});
return installed;
}

Expand Down
2 changes: 1 addition & 1 deletion locale/en.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions locale/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -7007,6 +7007,10 @@ msgstr "The base path \"{basePath}\" is already used by or overlaps the distribu
#~ msgid "The certificate for \"{namespace} {name} v{version}\" could not be saved."
#~ msgstr "The certificate for \"{namespace} {name} v{version}\" could not be saved."

#: src/actions/repository-content-task.ts
msgid "The change to repository \"{repositoryName}\" is still running."
msgstr "The change to repository \"{repositoryName}\" is still running."

#: src/components/repository-form.tsx
msgid "The client URL is shown on the repository page once the distribution exists."
msgstr "The client URL is shown on the repository page once the distribution exists."
Expand Down Expand Up @@ -7096,6 +7100,10 @@ msgstr "The following roles will be applied to user: <0>{0}</0>"
msgid "The outcome of removing the repository is unknown. Check the task:"
msgstr "The outcome of removing the repository is unknown. Check the task:"

#: src/actions/repository-content-task.ts
msgid "The outcome of the change to repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr "The outcome of the change to repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."

#: src/actions/repository-version-revert.tsx
msgid "The outcome of the revert of repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr "The outcome of the revert of repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
Expand Down
2 changes: 1 addition & 1 deletion locale/es.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions locale/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -7006,6 +7006,10 @@ msgstr ""
#~ msgid "The certificate for \"{namespace} {name} v{version}\" could not be saved."
#~ msgstr "No se ha podido guardar el certificado de \"{namespace} {name} v{version}\"."

#: src/actions/repository-content-task.ts
msgid "The change to repository \"{repositoryName}\" is still running."
msgstr ""

#: src/components/repository-form.tsx
msgid "The client URL is shown on the repository page once the distribution exists."
msgstr ""
Expand Down Expand Up @@ -7095,6 +7099,10 @@ msgstr ""
msgid "The outcome of removing the repository is unknown. Check the task:"
msgstr ""

#: src/actions/repository-content-task.ts
msgid "The outcome of the change to repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr ""

#: src/actions/repository-version-revert.tsx
msgid "The outcome of the revert of repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locale/fr.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions locale/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -7006,6 +7006,10 @@ msgstr ""
#~ msgid "The certificate for \"{namespace} {name} v{version}\" could not be saved."
#~ msgstr "Le certificat pour \"{namespace} {name} v{version}\" n'a pas pu être enregistré."

#: src/actions/repository-content-task.ts
msgid "The change to repository \"{repositoryName}\" is still running."
msgstr ""

#: src/components/repository-form.tsx
msgid "The client URL is shown on the repository page once the distribution exists."
msgstr ""
Expand Down Expand Up @@ -7095,6 +7099,10 @@ msgstr ""
msgid "The outcome of removing the repository is unknown. Check the task:"
msgstr ""

#: src/actions/repository-content-task.ts
msgid "The outcome of the change to repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr ""

#: src/actions/repository-version-revert.tsx
msgid "The outcome of the revert of repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locale/ja.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions locale/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -7006,6 +7006,10 @@ msgstr ""
#~ msgid "The certificate for \"{namespace} {name} v{version}\" could not be saved."
#~ msgstr "\"{namespace} {name} v{version}\" の証明書を保存できませんでした。"

#: src/actions/repository-content-task.ts
msgid "The change to repository \"{repositoryName}\" is still running."
msgstr ""

#: src/components/repository-form.tsx
msgid "The client URL is shown on the repository page once the distribution exists."
msgstr ""
Expand Down Expand Up @@ -7095,6 +7099,10 @@ msgstr ""
msgid "The outcome of removing the repository is unknown. Check the task:"
msgstr ""

#: src/actions/repository-content-task.ts
msgid "The outcome of the change to repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr ""

#: src/actions/repository-version-revert.tsx
msgid "The outcome of the revert of repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locale/ko.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions locale/ko.po
Original file line number Diff line number Diff line change
Expand Up @@ -7006,6 +7006,10 @@ msgstr ""
#~ msgid "The certificate for \"{namespace} {name} v{version}\" could not be saved."
#~ msgstr "\"{namespace} {name} v{version}\"의 인증서를 저장할 수 없습니다."

#: src/actions/repository-content-task.ts
msgid "The change to repository \"{repositoryName}\" is still running."
msgstr ""

#: src/components/repository-form.tsx
msgid "The client URL is shown on the repository page once the distribution exists."
msgstr ""
Expand Down Expand Up @@ -7095,6 +7099,10 @@ msgstr ""
msgid "The outcome of removing the repository is unknown. Check the task:"
msgstr ""

#: src/actions/repository-content-task.ts
msgid "The outcome of the change to repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr ""

#: src/actions/repository-version-revert.tsx
msgid "The outcome of the revert of repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locale/nl.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions locale/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -7006,6 +7006,10 @@ msgstr ""
#~ msgid "The certificate for \"{namespace} {name} v{version}\" could not be saved."
#~ msgstr "Het certificaat van '{namespace} {name} v{version}' kan niet worden opgeslagen."

#: src/actions/repository-content-task.ts
msgid "The change to repository \"{repositoryName}\" is still running."
msgstr ""

#: src/components/repository-form.tsx
msgid "The client URL is shown on the repository page once the distribution exists."
msgstr ""
Expand Down Expand Up @@ -7095,6 +7099,10 @@ msgstr ""
msgid "The outcome of removing the repository is unknown. Check the task:"
msgstr ""

#: src/actions/repository-content-task.ts
msgid "The outcome of the change to repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr ""

#: src/actions/repository-version-revert.tsx
msgid "The outcome of the revert of repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locale/zh.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions locale/zh.po
Original file line number Diff line number Diff line change
Expand Up @@ -7006,6 +7006,10 @@ msgstr ""
#~ msgid "The certificate for \"{namespace} {name} v{version}\" could not be saved."
#~ msgstr "\"{namespace} {name} v{version}\" 的证书不能被保存。"

#: src/actions/repository-content-task.ts
msgid "The change to repository \"{repositoryName}\" is still running."
msgstr ""

#: src/components/repository-form.tsx
msgid "The client URL is shown on the repository page once the distribution exists."
msgstr ""
Expand Down Expand Up @@ -7095,6 +7099,10 @@ msgstr ""
msgid "The outcome of removing the repository is unknown. Check the task:"
msgstr ""

#: src/actions/repository-content-task.ts
msgid "The outcome of the change to repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr ""

#: src/actions/repository-version-revert.tsx
msgid "The outcome of the revert of repository \"{repositoryName}\" is unknown, because the task status could not be read. Check the task."
msgstr ""
Expand Down
20 changes: 14 additions & 6 deletions scripts/bundle-size.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
// The budget file is JSON: { "initialGzipBytes": <integer> }.
//
// Exit status: 0 within the budget, 1 over it, 2 when index.html, an asset it
// names or the budget file is missing or invalid, or an asset path would leave
// the dist folder. When GITHUB_STEP_SUMMARY names a file, the report is
// names or the budget file is missing or invalid, an asset path would leave
// the dist folder, or index.html names a script or stylesheet outside a js or
// css folder. When GITHUB_STEP_SUMMARY names a file, the report is
// appended to it as Markdown.
import { appendFileSync, readFileSync, readdirSync } from 'node:fs';
import { join, resolve, sep } from 'node:path';
Expand All @@ -31,9 +32,11 @@ class InputError extends Error {}

/**
* The initial assets named by a page: the path of every script src and link
* href that ends in .js or .css and sits under a js or css folder, as a path
* relative to the dist folder ("js/App.<hash>.js"), in page order, once each.
* Handles quoted and unquoted attribute values.
* href that ends in .js or .css, as a path relative to the dist folder
* ("js/App.<hash>.js"), in page order, once each. Handles quoted and unquoted
* attribute values. Throws InputError for a script or stylesheet outside a js
* or css folder: leaving it out would make the total smaller than what a first
* visit downloads while the check stays green.
*/
export function parseAssets(html) {
const found = [];
Expand All @@ -44,7 +47,12 @@ export function parseAssets(html) {
continue;
}
const tail = /(?:^|\/)((?:js|css)\/.*)$/.exec(value);
if (tail && !found.includes(tail[1])) {
if (!tail) {
throw new InputError(
`index.html names ${value}, which is not under a js or css folder`,
);
}
if (!found.includes(tail[1])) {
found.push(tail[1]);
}
}
Expand Down
25 changes: 21 additions & 4 deletions scripts/bundle-size.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ describe('parseAssets', () => {
expect(parseAssets(html)).toEqual(['js/App.abc.js', 'css/App.def.css']);
});

it('ignores scripts and links that are not under a js or css folder', () => {
const html =
'<script src=/static/pulp_ui/other/x.js></script><link href=/static/pulp_ui/x.css rel=stylesheet>';
expect(parseAssets(html)).toEqual([]);
it('rejects a script that is not under a js or css folder', () => {
const html = '<script src=/static/pulp_ui/other/x.js></script>';
expect(() => parseAssets(html)).toThrow(/other\/x\.js.*not under/);
});

it('rejects a stylesheet that is not under a js or css folder', () => {
const html = '<link href=/static/pulp_ui/x.css rel=stylesheet>';
expect(() => parseAssets(html)).toThrow(/x\.css.*not under/);
});
});

Expand Down Expand Up @@ -208,6 +212,19 @@ describe('command line', () => {
expect(res.status).toBe(2);
});

it('exits 2 when index.html names a script outside a js or css folder', () => {
write(
'index.html',
INDEX_UNQUOTED.replace(
'</head>',
'<script src=/static/pulp_ui/runtime.js></script></head>',
),
);
const res = run(['--budget', writeBudget(100000), '--dist', dist]);
expect(res.status).toBe(2);
expect(res.stderr).toMatch(/runtime\.js/);
});

it('exits 2 for a missing budget file, a non-numeric limit and a missing argument', () => {
expect(
run(['--budget', join(dist, 'nope.json'), '--dist', dist]).status,
Expand Down
Loading
Loading