mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-12-03 01:23:31 +01:00
Merge origin/main into feat/log-repo-user-context; rebuild bundles
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
c281841f91
16 files changed
+570
-110
No files matched your search
+201
-6
@@ -449,13 +449,16 @@ describe("Vue 3 UI", function () {
|
||||
},
|
||||
});
|
||||
const picker = () => ui.window.document.querySelector(".repo-picker");
|
||||
const button = text => [...picker().querySelectorAll("button")].find(b => b.textContent.trim() === text);
|
||||
const button = label => picker().querySelector(`button[aria-label="${label}"]`);
|
||||
expect(picker().textContent).to.include("repo-0");
|
||||
expect(button("Previous").disabled).to.equal(true);
|
||||
button("Next").click();
|
||||
// Page 1 has no Previous button; the pager is the footer's compact icon pair.
|
||||
expect(button("Previous page")).to.equal(null);
|
||||
expect(picker().querySelector(".repo-picker-foot .repo-picker-pagination")).to.not.equal(null);
|
||||
button("Next page").click();
|
||||
await delay(30);
|
||||
expect(picker().textContent).to.include("repo-20");
|
||||
button("Previous").click();
|
||||
expect(button("Previous page").disabled).to.equal(false);
|
||||
button("Previous page").click();
|
||||
await delay(30);
|
||||
expect(picker().textContent).to.include("repo-0");
|
||||
await ui.input(".repo-picker-filter", "needle");
|
||||
@@ -1099,9 +1102,12 @@ describe("Vue 3 UI", function () {
|
||||
state.sourceUrl = "https://github.com/owner/repo";
|
||||
await state.urlSelected(); await delay(60);
|
||||
expect(doc.querySelector('.repository-task')).to.equal(null);
|
||||
for (const selector of ['#sourceUrl', '#terms', '#image', '#conference', '#expirationDate']) {
|
||||
for (const selector of ['#sourceUrl', '#terms', '#image', '#conference']) {
|
||||
expect(doc.querySelector(selector).closest('details')).to.equal(null);
|
||||
}
|
||||
// Under the free plan's limit the expiry reads as text; the exact date is one click away.
|
||||
expect(doc.querySelector('.expiry-meta').textContent).to.include("Maximum on your plan");
|
||||
expect(doc.querySelector('#expirationDate').closest('.hosting-date').style.display).to.equal("none");
|
||||
state.terms = "Private Author";
|
||||
await delay(450);
|
||||
expect(doc.querySelector('.reviewer-preview .file-content, .anonymize-preview-body').textContent).to.include("MASKED");
|
||||
@@ -1109,7 +1115,7 @@ describe("Vue 3 UI", function () {
|
||||
state.options.expirationMode = "never"; await delay(20);
|
||||
expect(doc.querySelector('.hosting-options').textContent).to.include("20 repositories");
|
||||
expect(doc.querySelector('.anonymize-submit-bar').textContent).to.include("Continue to checkout");
|
||||
// The caption also has a "Files" toggle (.rp-open) for the preview's tree; target Expand preview.
|
||||
// Expand preview is the caption's only window control.
|
||||
doc.querySelector('.reviewer-preview .rp-open.is-toggle').click(); await delay(10);
|
||||
expect(doc.querySelector('.anonymize-page').classList.contains('preview-expanded')).to.equal(true);
|
||||
doc.querySelector('.reviewer-preview .rp-open.is-toggle').click(); await delay(10);
|
||||
@@ -2977,4 +2983,193 @@ describe("Vue 3 UI", function () {
|
||||
}
|
||||
expect(ui.app.router.currentRoute.value.path).to.equal("/");
|
||||
});
|
||||
|
||||
describe("workspace polish (r19)", () => {
|
||||
it("keeps the dashboard tabs and counts rendered while a tab reloads", async () => {
|
||||
const item = (repoId, status) => ({ _type: "repo", repoId, status, source: { fullName: "owner/" + repoId }, options: {} });
|
||||
let release;
|
||||
ui = await browser("/dashboard", {
|
||||
"/api/user": { username: "tester" },
|
||||
"/api/user/dashboard": request => {
|
||||
const removed = request.url.searchParams.get("statuses") === "removed";
|
||||
const body = { items: removed ? [item("gone", "removed")] : [item("alpha", "ready"), item("broken", "error")],
|
||||
total: 3, filtered: removed ? 1 : 2, attention: 1, cursor: null };
|
||||
return removed ? new Promise(resolve => { release = () => resolve(body); }) : body;
|
||||
},
|
||||
});
|
||||
const doc = ui.window.document;
|
||||
await delay(50);
|
||||
const tabs = () => [...doc.querySelectorAll(".dashboard-meta .dashboard-view-tabs button")].map(b => b.textContent.replace(/\s+/g, " ").trim());
|
||||
expect(tabs()).to.deep.equal(["Current", "Needs attention 1", "Removed 1"]);
|
||||
[...doc.querySelectorAll(".dashboard-view-tabs button")].find(b => /Removed/.test(b.textContent)).click();
|
||||
await delay(250);
|
||||
// The answer is pending: same tabs, the table busy, placeholders instead of a false empty state.
|
||||
expect(tabs()).to.deep.equal(["Current", "Needs attention 1", "Removed 1"]);
|
||||
const table = doc.querySelector(".paper-table-dashboard");
|
||||
expect(table.getAttribute("aria-busy")).to.equal("true");
|
||||
expect(table.classList.contains("is-refreshing")).to.equal(true);
|
||||
expect(doc.querySelector(".paper-table-empty")).to.equal(null);
|
||||
expect(doc.querySelectorAll(".paper-table-skeleton").length).to.be.greaterThan(0);
|
||||
release(); await delay(30);
|
||||
expect(table.classList.contains("is-refreshing")).to.equal(false);
|
||||
expect(doc.querySelectorAll(".paper-table-skeleton")).to.have.length(0);
|
||||
expect(doc.querySelector(".paper-table-row:not(.paper-table-skeleton):not(.paper-table-head)").textContent).to.include("gone");
|
||||
expect(ui.errors).to.deep.equal([]);
|
||||
});
|
||||
|
||||
it("holds the dashboard tab row with placeholders on the first load", async () => {
|
||||
let release;
|
||||
ui = await browser("/dashboard", {
|
||||
"/api/user": { username: "tester" },
|
||||
"/api/user/dashboard": () => new Promise(resolve => { release = () => resolve({ items: [], total: 0, filtered: 0, attention: 0, cursor: null }); }),
|
||||
});
|
||||
const doc = ui.window.document;
|
||||
expect(doc.querySelector(".dashboard-meta.is-loading .dashboard-tab-skeleton")).to.not.equal(null);
|
||||
expect(doc.querySelector(".paper-table-empty")).to.equal(null);
|
||||
release(); await delay(30);
|
||||
expect(doc.querySelector(".dashboard-meta.is-loading")).to.equal(null);
|
||||
expect(doc.querySelector(".dashboard-meta .dashboard-count")).to.not.equal(null);
|
||||
expect(ui.errors).to.deep.equal([]);
|
||||
});
|
||||
|
||||
it("shows admin placeholder rows instead of an empty state until the list arrives", async () => {
|
||||
let release;
|
||||
ui = await browser("/admin/repositories", {
|
||||
"/api/user": { username: "admin", isAdmin: true },
|
||||
"/api/admin/repos": request => request.url.searchParams.get("limit") === "1"
|
||||
? { total: 1, results: [], statusCounts: [] }
|
||||
: new Promise(resolve => { release = () => resolve({ total: 1, results: [{ repoId: "r1", status: "ready", source: { repositoryName: "owner/r1" }, options: {} }] }); }),
|
||||
});
|
||||
const doc = ui.window.document;
|
||||
await delay(30);
|
||||
expect(doc.querySelectorAll(".paper-table-repos .paper-table-skeleton").length).to.be.greaterThan(0);
|
||||
expect(doc.querySelector(".paper-table-repos .paper-table-empty")).to.equal(null);
|
||||
expect(doc.querySelector(".seg-filter")).to.not.equal(null);
|
||||
release(); await delay(30);
|
||||
expect(doc.querySelectorAll(".paper-table-repos .paper-table-skeleton")).to.have.length(0);
|
||||
expect(doc.querySelector(".paper-table-repos").getAttribute("aria-busy")).to.equal("false");
|
||||
expect(ui.errors).to.deep.equal([]);
|
||||
});
|
||||
|
||||
it("gives a picker row a tooltip only when its name is cut short", async () => {
|
||||
ui = await browser("/anonymize", {
|
||||
"/api/user/repository_picker": { items: [{ id: 1, fullName: "org/short" }], nextCursor: null },
|
||||
});
|
||||
const name = ui.window.document.querySelector(".repo-picker-name");
|
||||
expect(name.hasAttribute("title")).to.equal(false);
|
||||
name.dispatchEvent(new ui.window.MouseEvent("mouseenter"));
|
||||
expect(name.hasAttribute("title")).to.equal(false);
|
||||
Object.defineProperty(name, "scrollWidth", { configurable: true, value: 400 });
|
||||
Object.defineProperty(name, "clientWidth", { configurable: true, value: 200 });
|
||||
name.dispatchEvent(new ui.window.MouseEvent("mouseenter"));
|
||||
expect(name.getAttribute("title")).to.equal("org/short");
|
||||
expect(ui.errors).to.deep.equal([]);
|
||||
});
|
||||
|
||||
it("states the redaction status beside the preview title and leads to the Terms field", async () => {
|
||||
ui = await browser("/anonymize", { ...repositorySource, "/api/user/default": { terms: [], options: {} },
|
||||
"/api/anonymize-preview": request => {
|
||||
const mask = text => (request.payload.options?.terms || []).includes("Private Author") ? text.replaceAll("Private Author", "XXXX-1") : text;
|
||||
return request.payload.contents ? { contents: request.payload.contents.map(mask) } : { content: mask(String(request.payload.content)) };
|
||||
} });
|
||||
const doc = ui.window.document;
|
||||
const state = doc.querySelector("#sourceUrl")._field.binding.state;
|
||||
state.sourceUrl = "https://github.com/owner/repo";
|
||||
await state.urlSelected(); await delay(450);
|
||||
const caption = doc.querySelector(".reviewer-preview .rp-caption");
|
||||
expect(caption.querySelector(".rp-title").textContent).to.equal("What reviewers will see");
|
||||
expect([...caption.querySelectorAll("button")].some(b => b.textContent.trim() === "Files")).to.equal(false);
|
||||
const chip = caption.querySelector(".rp-status-empty");
|
||||
expect(chip.textContent.replace(/\s+/g, " ").trim()).to.equal("Nothing redacted yet: add terms");
|
||||
state.mobilePane = "preview";
|
||||
chip.click(); await delay(20);
|
||||
expect(state.mobilePane).to.equal("settings");
|
||||
expect(doc.activeElement.id).to.equal("terms");
|
||||
state.terms = "Private Author"; await delay(450);
|
||||
expect(caption.querySelector(".rp-status-empty")).to.equal(null);
|
||||
expect(caption.querySelector(".rp-count").textContent.replace(/\s+/g, " ").trim()).to.equal("1 redacted");
|
||||
state.terms = "Nobody"; await delay(450);
|
||||
expect(caption.querySelector(".rp-count").textContent).to.equal("No terms found in this file");
|
||||
expect(ui.errors).to.deep.equal([]);
|
||||
});
|
||||
|
||||
it("names the plan-limited date in the option and reveals the bounded input on Change date", async () => {
|
||||
ui = await browser("/anonymize", { ...repositorySource, "/api/billing/": { ...taskBilling, freeExpirationMonths: 5 },
|
||||
"/api/user/quota": { repository: { used: 1, total: 5 } } });
|
||||
const doc = ui.window.document;
|
||||
const state = doc.querySelector("#sourceUrl")._field.binding.state;
|
||||
state.sourceUrl = "https://github.com/owner/repo";
|
||||
await state.urlSelected(); await delay(60);
|
||||
const option = doc.querySelector(".expiration-choice span");
|
||||
expect(option.textContent).to.match(/^Expire on [A-Z][a-z]{2} \d{1,2}, \d{4}$/);
|
||||
const meta = () => doc.querySelector(".expiry-meta").textContent.replace(/\s+/g, " ").trim();
|
||||
expect(meta()).to.equal("In 5 months · Maximum on your plan");
|
||||
expect(doc.querySelector(".expiration-choice-row .expiry-change").textContent).to.equal("Change date");
|
||||
expect(doc.querySelector(".dated-options").textContent).not.to.match(/Expires|Then|Advanced/);
|
||||
expect(doc.querySelector(".hosting-property label").textContent).to.equal("After expiry");
|
||||
const row = doc.querySelector("#expirationDate").closest(".hosting-date");
|
||||
expect(row.style.display).to.equal("none");
|
||||
doc.querySelector(".expiry-change").click(); await delay(20);
|
||||
expect(row.style.display).to.equal("");
|
||||
expect(doc.activeElement.id).to.equal("expirationDate");
|
||||
expect(doc.querySelector(".expiry-change")).to.equal(null);
|
||||
const input = doc.querySelector("#expirationDate");
|
||||
expect(input.getAttribute("max")).to.equal(state.maxExpirationDate);
|
||||
expect(input.getAttribute("min")).to.equal(state.minExpirationDate);
|
||||
// An earlier pick is still named, without the "maximum" reason.
|
||||
const earlier = new Date(); earlier.setMonth(earlier.getMonth() + 2);
|
||||
state.options.expirationDate = new ui.window.Date(earlier.getTime()); await delay(20);
|
||||
expect(meta()).to.equal("In 2 months");
|
||||
state.options.expirationMode = "never"; await delay(20);
|
||||
expect(doc.querySelector(".dated-options")).to.equal(null);
|
||||
expect(option.textContent).to.equal("Expire on a date");
|
||||
expect(ui.errors).to.deep.equal([]);
|
||||
});
|
||||
|
||||
it("reveals and focuses a hidden invalid date on submit", async () => {
|
||||
ui = await browser("/anonymize", { ...repositorySource, "/api/billing/": { ...taskBilling, freeExpirationMonths: 5 },
|
||||
"/api/user/quota": { repository: { used: 1, total: 5 } } });
|
||||
const doc = ui.window.document;
|
||||
const state = doc.querySelector("#sourceUrl")._field.binding.state;
|
||||
state.sourceUrl = "https://github.com/owner/repo";
|
||||
await state.urlSelected(); await delay(60);
|
||||
const input = doc.querySelector("#expirationDate");
|
||||
expect(input.closest(".hosting-date").style.display).to.equal("none");
|
||||
input.setCustomValidity("out of range");
|
||||
input.dispatchEvent(new ui.window.Event("reveal", { bubbles: true }));
|
||||
await delay(20);
|
||||
expect(state.expiryPickerOpen).to.equal(true);
|
||||
expect(input.closest(".hosting-date").style.display).to.equal("");
|
||||
expect(ui.errors).to.deep.equal([]);
|
||||
});
|
||||
|
||||
it("keeps the plain date picker when no plan limit applies", async () => {
|
||||
ui = await browser("/anonymize", repositorySource);
|
||||
const doc = ui.window.document;
|
||||
const state = doc.querySelector("#sourceUrl")._field.binding.state;
|
||||
state.sourceUrl = "https://github.com/owner/repo";
|
||||
await state.urlSelected(); await delay(60);
|
||||
expect(doc.querySelector(".expiry-meta")).to.equal(null);
|
||||
expect(doc.querySelector(".expiration-choice span").textContent).to.equal("Expire on a date");
|
||||
expect(doc.querySelector("#expirationDate").closest(".hosting-date").style.display).to.equal("");
|
||||
const echo = doc.querySelector(".hosting-date .date-echo").textContent;
|
||||
expect(echo).not.to.match(/^Expires/);
|
||||
expect(echo).to.match(/· in \d+ months?$/);
|
||||
expect(ui.errors).to.deep.equal([]);
|
||||
});
|
||||
|
||||
it("names the conference when its end date sets the expiry", async () => {
|
||||
const end = new Date(); end.setMonth(end.getMonth() + 9);
|
||||
ui = await browser("/anonymize", { ...repositorySource, "/api/billing/": { ...taskBilling, freeExpirationMonths: 5 },
|
||||
"/api/user/quota": { repository: { used: 1, total: 5 } },
|
||||
"/api/conferences/ICSE": { conferenceID: "ICSE", name: "ICSE 2027", startDate: new Date().toISOString(), endDate: end.toISOString(), options: {} } });
|
||||
const doc = ui.window.document;
|
||||
const state = doc.querySelector("#sourceUrl")._field.binding.state;
|
||||
state.sourceUrl = "https://github.com/owner/repo";
|
||||
await state.urlSelected(); await delay(60);
|
||||
state.conference = "ICSE"; await delay(60);
|
||||
expect(doc.querySelector(".expiry-meta").textContent).to.include("When ICSE 2027 ends");
|
||||
expect(ui.errors).to.deep.equal([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user