mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-12-03 01:23:31 +01:00
fix(ui): name the expiry date in its option and reveal the input on Change date
The dated option now reads "Expire on Apr 29, 2027" with a muted line
below ("In 5 months · Maximum on your plan", or the conference, Extended
expiration or saved-date reason). "Change date" sits beside the option
and reveals the bounded date input inline; an invalid date reveals and
focuses it, also on submit (forms.js dispatches a "reveal" event to a
hidden invalid field). The date and "After expiry" rows share one label
column, and "Never expire" keeps the same text edge. Without a plan
limit the option reads "Expire on a date" with the input shown.
A saved date on the same day as an Extended expiration limit keeps the
add-on as the reason.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
94947ad0ec
commit
0e3055fa9c
8 files changed
+175
-109
No files matched your search
+42
-18
@@ -1106,8 +1106,8 @@ describe("Vue 3 UI", function () {
|
||||
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('.hosting-date .expiry-summary').textContent).to.include("the maximum on your plan");
|
||||
expect(doc.querySelector('#expirationDate').closest('details.expiry-advanced')).to.not.equal(null);
|
||||
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");
|
||||
@@ -3093,29 +3093,53 @@ describe("Vue 3 UI", function () {
|
||||
expect(ui.errors).to.deep.equal([]);
|
||||
});
|
||||
|
||||
it("words a plan-limited expiry and keeps the exact date behind a disclosure", async () => {
|
||||
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 summary = doc.querySelector(".hosting-date .expiry-summary");
|
||||
expect(summary.textContent).to.match(/· in 5 months, the maximum on your plan$/);
|
||||
expect(doc.querySelector(".hosting-date").textContent).not.to.match(/Expires\s+[A-Z][a-z]{2} \d/);
|
||||
const details = doc.querySelector("details.expiry-advanced");
|
||||
expect(details.open).to.equal(false);
|
||||
expect(details.querySelector("summary").textContent).to.equal("Advanced: pick an exact date");
|
||||
const input = details.querySelector("#expirationDate");
|
||||
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 stated, without the "maximum" note.
|
||||
// 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(summary.textContent).not.to.include("maximum");
|
||||
// A never-expiring choice has no date at all.
|
||||
expect(meta()).to.equal("In 2 months");
|
||||
state.options.expirationMode = "never"; await delay(20);
|
||||
expect(doc.querySelector(".hosting-date")).to.equal(null);
|
||||
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([]);
|
||||
});
|
||||
|
||||
@@ -3125,9 +3149,9 @@ describe("Vue 3 UI", function () {
|
||||
const state = doc.querySelector("#sourceUrl")._field.binding.state;
|
||||
state.sourceUrl = "https://github.com/owner/repo";
|
||||
await state.urlSelected(); await delay(60);
|
||||
expect(doc.querySelector(".hosting-date .expiry-summary")).to.equal(null);
|
||||
expect(doc.querySelector("details.expiry-advanced").classList.contains("is-plain")).to.equal(true);
|
||||
expect(doc.querySelector("details.expiry-advanced").open).to.equal(true);
|
||||
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?$/);
|
||||
@@ -3144,7 +3168,7 @@ describe("Vue 3 UI", function () {
|
||||
state.sourceUrl = "https://github.com/owner/repo";
|
||||
await state.urlSelected(); await delay(60);
|
||||
state.conference = "ICSE"; await delay(60);
|
||||
expect(doc.querySelector(".hosting-date .expiry-summary").textContent).to.match(/, when ICSE 2027 ends$/);
|
||||
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