diff --git a/scripts/check-svelte-company.sh b/scripts/check-svelte-company.sh index bc5ab6f0..f3625af5 100644 --- a/scripts/check-svelte-company.sh +++ b/scripts/check-svelte-company.sh @@ -4,15 +4,15 @@ set -euo pipefail cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." scratch="$(mktemp -d)" trap 'rm -rf "$scratch"' EXIT -unset FEATURE_COMPANY_IDENTITY FEATURE_OFFER_COPY FEATURE_PORTAL_PRIVACY PUBLIC_CONTENT_PROFILE COMPANY_POSTAL_ADDRESS +unset FEATURE_COMPANY_IDENTITY FEATURE_OFFER_COPY FEATURE_PORTAL_PRIVACY FEATURE_ADDONS PUBLIC_CONTENT_PROFILE COMPANY_POSTAL_ADDRESS bash scripts/build-journal-reference.sh > "$scratch/content.log" 2>&1 || { tail -80 "$scratch/content.log" >&2; exit 1; } for mode in false published preview independent template unset; do - unset FEATURE_COMPANY_IDENTITY FEATURE_OFFER_COPY FEATURE_PORTAL_PRIVACY PUBLIC_CONTENT_PROFILE COMPANY_POSTAL_ADDRESS + unset FEATURE_COMPANY_IDENTITY FEATURE_OFFER_COPY FEATURE_PORTAL_PRIVACY FEATURE_ADDONS PUBLIC_CONTENT_PROFILE COMPANY_POSTAL_ADDRESS case "$mode" in - false) export FEATURE_COMPANY_IDENTITY=false FEATURE_OFFER_COPY=false ;; - published) export FEATURE_COMPANY_IDENTITY=true FEATURE_OFFER_COPY=false ;; - preview|template) export FEATURE_COMPANY_IDENTITY=true FEATURE_OFFER_COPY=true FEATURE_PORTAL_PRIVACY=true ;; - independent) export FEATURE_COMPANY_IDENTITY=false FEATURE_OFFER_COPY=true ;; + false) export FEATURE_COMPANY_IDENTITY=false FEATURE_OFFER_COPY=false FEATURE_ADDONS=false ;; + published) export FEATURE_COMPANY_IDENTITY=true FEATURE_OFFER_COPY=false FEATURE_ADDONS=false ;; + preview|template) export FEATURE_COMPANY_IDENTITY=true FEATURE_OFFER_COPY=true FEATURE_PORTAL_PRIVACY=true FEATURE_ADDONS=true ;; + independent) export FEATURE_COMPANY_IDENTITY=false FEATURE_OFFER_COPY=true FEATURE_ADDONS=true ;; esac export COMPANY_POSTAL_ADDRESS=$'Example & company-address-fixture-187 1\n1234 Exampletown' if [[ "$mode" == template ]]; then @@ -30,8 +30,8 @@ for mode in false published preview independent template unset; do done # Native framework validation must reject ambiguous switches before output. -unset COMPANY_POSTAL_ADDRESS PUBLIC_CONTENT_PROFILE FEATURE_COMPANY_IDENTITY FEATURE_OFFER_COPY FEATURE_PORTAL_PRIVACY -for flag in FEATURE_COMPANY_IDENTITY FEATURE_OFFER_COPY FEATURE_PORTAL_PRIVACY; do +unset COMPANY_POSTAL_ADDRESS PUBLIC_CONTENT_PROFILE FEATURE_COMPANY_IDENTITY FEATURE_OFFER_COPY FEATURE_PORTAL_PRIVACY FEATURE_ADDONS +for flag in FEATURE_COMPANY_IDENTITY FEATURE_OFFER_COPY FEATURE_PORTAL_PRIVACY FEATURE_ADDONS; do if env "$flag=ambiguous" npm --prefix web run build > "$scratch/rejected.log" 2>&1; then printf 'Invalid business setting was accepted: %s\n' "$flag" >&2; exit 1 fi @@ -52,7 +52,7 @@ if PUBLIC_CONTENT_PROFILE=invalid npm --prefix web run build > "$scratch/rejecte fi grep -q 'PUBLIC_CONTENT_PROFILE must be' "$scratch/rejected.log" # With identity off the public application needs no private disclosure input. -unset FEATURE_COMPANY_IDENTITY FEATURE_OFFER_COPY FEATURE_PORTAL_PRIVACY COMPANY_POSTAL_ADDRESS PUBLIC_CONTENT_PROFILE +unset FEATURE_COMPANY_IDENTITY FEATURE_OFFER_COPY FEATURE_PORTAL_PRIVACY FEATURE_ADDONS COMPANY_POSTAL_ADDRESS PUBLIC_CONTENT_PROFILE npm --prefix web run build > "$scratch/default.log" 2>&1 node web/tests/check-output.mjs enabled node web/tests/check-discovery-output.mjs enabled diff --git a/src/components/business/legal-copy.ts b/src/components/business/legal-copy.ts index bf0124a3..cec7ece8 100644 --- a/src/components/business/legal-copy.ts +++ b/src/components/business/legal-copy.ts @@ -142,7 +142,7 @@ const privacy = (portal: boolean) => ({ }, }) satisfies Record; -const terms = { +const terms = (addons: boolean) => ({ en: { title: 'Terms for projects and hosting', description: 'How agreements with Devantler Tech work: proposals, prices, payment, your right of withdrawal and ending hosting.', @@ -197,6 +197,12 @@ const terms = { 'As a private customer you can in any case end hosting with one month’s notice to the end of a month once five months have passed since the agreement. If you have paid for a period after the end date, I refund that amount immediately.', 'When hosting ends, I hand over your content and code as described in your proposal.', ] }, + ...(addons ? [{ title: 'Feature requests and add-ons', blocks: [ + 'You can send feature requests at any time while your project is hosted. Hosting and ending it says which are included and which get a fixed-price quote. There are no hourly rates.', + 'Two monthly add-ons speed this up. With Priority, the target is to pick up your requests about once a week. With Express, the target is to start work on a request within 1 business day and to reply within 1 business day. Business days are Monday to Friday, except Danish public holidays. These are targets, not guarantees: during holidays or illness they can take longer, and I tell you as early as I can.', + 'Fair use applies to every level: one request is in progress per customer at a time. The next request is picked up when the current one is finished.', + 'Other add-ons, such as an extra language or visitor statistics, are part of your order at the prices it states. A monthly add-on is billed with your hosting. You can end it in the portal or by email from the next month, and it ends with your hosting.', + ] }] : []), { title: 'Faults and complaints', blocks: [ `If something delivered does not match what we agreed, write to ${company.email} within a reasonable time after you notice it. Then we will find a solution. If you are a private customer, the rules on defects in the Danish Sale of Goods Act (købeloven) may apply.`, 'If we cannot agree, a private customer can complain to Nævnenes Hus, Toldboden 2, 8800 Viborg. If you live in another EU country, the European Consumer Centre in Denmark (Forbruger Europa) can help.', @@ -262,6 +268,12 @@ const terms = { 'Som privatkunde kan du under alle omstændigheder opsige hostingen med en måneds varsel til udgangen af en måned, når der er gået fem måneder efter aftalens indgåelse. Har du betalt for en periode efter ophøret, tilbagebetaler jeg straks beløbet for den periode.', 'Når hostingen ophører, overdrager jeg dit indhold og din kode som beskrevet i dit tilbud.', ] }, + ...(addons ? [{ title: 'Ønsker og tilvalg', blocks: [ + 'Du kan til enhver tid sende ønsker til nye funktioner, mens dit projekt er hostet. Afsnittet om hosting og opsigelse beskriver, hvilke der er inkluderet, og hvilke der får et fastpristilbud. Der er ingen timepriser.', + 'To månedlige tilvalg gør det hurtigere. Med Prioritet er målet at tage dine ønsker op cirka en gang om ugen. Med Ekspres er målet at begynde arbejdet på et ønske inden for 1 arbejdsdag og at svare inden for 1 arbejdsdag. Arbejdsdage er mandag til fredag undtagen danske helligdage. Det er mål, ikke garantier: Under ferie eller sygdom kan det tage længere tid, og jeg giver besked så tidligt, jeg kan.', + 'Rimelig brug gælder på alle niveauer: én opgave er under arbejde pr. kunde ad gangen. Det næste ønske tages op, når det aktuelle er færdigt.', + 'Andre tilvalg, fx et ekstra sprog eller besøgsstatistik, indgår i din ordre til de priser, den angiver. Et månedligt tilvalg betales sammen med hostingen. Du kan opsige det i portalen eller på e-mail fra næste måned, og det ophører sammen med hostingen.', + ] }] : []), { title: 'Fejl og klager', blocks: [ `Hvis det leverede ikke svarer til det aftalte, så skriv til ${company.email} inden rimelig tid efter, at du har opdaget det. Så finder vi en løsning. Er du privatkunde, kan købelovens mangelsregler finde anvendelse.`, 'Kan vi ikke blive enige, kan en privatkunde klage til Nævnenes Hus, Toldboden 2, 8800 Viborg. Bor du i et andet EU-land, kan Forbruger Europa hjælpe.', @@ -273,11 +285,11 @@ const terms = { ] }, ], }, -} as const satisfies Record; +}) as const satisfies Record; export type LegalKind = 'privacy' | 'terms'; -/** One legal page; portal-only privacy text appears only when `portal` is true. */ -export function legalPage(kind: LegalKind, locale: Locale, portal: boolean): LegalPage { - return kind === 'privacy' ? privacy(portal)[locale] : terms[locale]; +/** Portal privacy and add-on terms have independent, default-off releases. */ +export function legalPage(kind: LegalKind, locale: Locale, portal: boolean, addons = false): LegalPage { + return kind === 'privacy' ? privacy(portal)[locale] : terms(addons)[locale]; } diff --git a/web/README.md b/web/README.md index 2e861363..cb7bb4d0 100644 --- a/web/README.md +++ b/web/README.md @@ -57,6 +57,12 @@ HTML documents; shared data, scripts and unrelated routes must never carry it. L fictional addresses. `PUBLIC_CONTENT_PROFILE=production-template` retains the existing Go runtime's escaped address placeholders. Invalid profiles fail. Revised-offer copy remains separately gated. +`FEATURE_ADDONS` is the server-only, default-off build setting shared by the add-on +listing and its English/Danish terms. Ordinary and production-template runtime packages pin it off, +including when the invoking environment enables it. Preview builds may set it to `true`. +Coordinated add-on activation and live bilingual verification precede its retirement in +[#632](https://github.com/devantler-tech/business-site/issues/632). + The approved VAT-inclusive guide prices, public/private customer invitation, six-tool catalogue and bilingual content are permanent. The old frontend variable has no effect. Unsupported old preview/client/featured presentation combinations fail rather than silently changing the result. diff --git a/web/src/lib/legal.server.ts b/web/src/lib/legal.server.ts index 3619f7c5..d3e3f7f4 100644 --- a/web/src/lib/legal.server.ts +++ b/web/src/lib/legal.server.ts @@ -1,5 +1,5 @@ import { error } from "@sveltejs/kit"; -import { FEATURE_COMPANY_IDENTITY, FEATURE_PORTAL_PRIVACY } from "$app/env/private"; +import { FEATURE_ADDONS, FEATURE_COMPANY_IDENTITY, FEATURE_PORTAL_PRIVACY } from "$app/env/private"; import { legalPage, type LegalKind } from "../../../src/components/business/legal-copy"; // The privacy notice and customer terms name the registered business, so they @@ -8,5 +8,5 @@ import { legalPage, type LegalKind } from "../../../src/components/business/lega export function legalPageLoad(kind: LegalKind, locale: string | undefined) { if (!FEATURE_COMPANY_IDENTITY || (locale !== undefined && locale !== "da")) error(404); const selected: "en" | "da" = locale === "da" ? "da" : "en"; - return { locale: selected, kind, copy: legalPage(kind, selected, FEATURE_PORTAL_PRIVACY) }; + return { locale: selected, kind, copy: legalPage(kind, selected, FEATURE_PORTAL_PRIVACY, FEATURE_ADDONS) }; } diff --git a/web/tests/company-output.mjs b/web/tests/company-output.mjs index 7695940c..2991289b 100644 --- a/web/tests/company-output.mjs +++ b/web/tests/company-output.mjs @@ -20,6 +20,7 @@ const links = node => walk(node).filter(item => item.tagName === "a").map(item = const files = dir => readdirSync(dir, {withFileTypes:true}).flatMap(entry => entry.isDirectory() ? files(join(dir,entry.name)) : [join(dir,entry.name)]); /** The portal's privacy section is released separately from the rest of the notice. */ const portalPrivacy = process.env.FEATURE_PORTAL_PRIVACY === "true"; +const addonTerms = process.env.FEATURE_ADDONS === "true"; /** The published phone number, or "" until the business adds one to company.json. */ const companyPhone = JSON.parse(readFileSync(new URL("../../src/data/company.json", import.meta.url), "utf8")).phone?.trim() ?? ""; @@ -105,6 +106,11 @@ export function assertCompanyOutput(candidate, {identity, scope, template, addre if (kind === "privacy") for (const phrase of ["accounts.devantler.tech", locale === "da" ? "30 dage" : "30 days", "GitHub"]) { assert.equal(text(main).includes(phrase), portalPrivacy, `portal privacy text follows FEATURE_PORTAL_PRIVACY: ${phrase}`); } + if (kind === "terms") { + for (const phrase of locale === "da" ? ["Ønsker og tilvalg", "mål, ikke garantier"] : ["Feature requests and add-ons", "targets, not guarantees"]) { + assert.equal(text(main).includes(phrase), addonTerms, `add-on terms follow FEATURE_ADDONS: ${phrase}`); + } + } } const path = join(candidate,`${prefix}company/index.html`); if (!identity) { assert.equal(existsSync(path),false,"disabled company route must be absent, not merely empty"); continue; } diff --git a/web/tests/legal-copy.test.ts b/web/tests/legal-copy.test.ts index 3fd79cc4..f9ac6e4c 100644 --- a/web/tests/legal-copy.test.ts +++ b/web/tests/legal-copy.test.ts @@ -20,3 +20,20 @@ test("the portal's privacy text appears only when FEATURE_PORTAL_PRIVACY is on", test("the terms do not depend on the portal flag", () => { for (const locale of ["en", "da"] as const) assert.deepEqual(legalPage("terms", locale, true), legalPage("terms", locale, false)); }); + +test("add-on terms follow the coordinated add-on release", () => { + for (const locale of ["en", "da"] as const) { + const heading = locale === "da" ? "Ønsker og tilvalg" : "Feature requests and add-ons"; + const published = legalPage("terms", locale, false); + const off = legalPage("terms", locale, true, false); + const on = legalPage("terms", locale, false, true); + assert.deepEqual(off, published, "portal privacy cannot activate add-on terms"); + assert.ok(!flat(published).includes(heading), `${locale} draft add-on terms leaked`); + assert.ok(flat(on).includes(heading), `${locale} enabled add-on terms missing`); + assert.match(flat(on), locale === "da" ? /mål, ikke garantier/ : /targets, not guarantees/); + assert.deepEqual(on.sections.filter(section => section.title !== heading), published.sections, + "activation changes only the add-on section, retaining the published hosting terms"); + assert.deepEqual(legalPage("privacy", locale, true, true), legalPage("privacy", locale, true), + "add-on terms cannot change portal privacy"); + } +});