Skip to content
Myr

Pin each answer-page commit link's text, not only its href

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- commitLinksOf now returns [href, text] for each link to a commit page, so the tests pin the base link's text as its short SHA (the issue's Want) and the landing link's text as "The landing commit". - Drops expect(markup).toContain("The landing commit"): the old label "The landing commit, in a clone of <project>" already held that string, so it passed against the code before the change. Seen red by planting the old label back as the link's text.

authored by oscabriel · committed by oscabriel · parent e9e8325 · Browse files · 1 file+12 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−7 removed

  • tests:+12 added−7 removed

1 file+12 added−7 removed

modified:apps/web/test/answer.test.tsx+12 added-7 removed
71 unmodified lines
7273 return lane === undefined || result === undefined ? [] : [[lane, result]];74 });7576/** Each link to a commit page, in page order. */76/** Each link to a commit page, in page order, as `[href, text]`. */77const commitLinksOf = (markup: string) =>78 [...markup.matchAll(/href="(?<href>[^"]*\/commit\/[^"]*)"/gu)].flatMap(79 ({ groups }) => (groups?.href === undefined ? [] : [groups.href])78 [79 ...markup.matchAll(80 /<a\b[^>]*href="(?<href>[^"]*\/commit\/[^"]*)"[^>]*>(?<inner>.*?)<\/a>/gu81 ),82 ].flatMap(({ groups }) =>83 groups?.href === undefined || groups.inner === undefined84 ? []85 : [[groups.href, plainText(groups.inner).trim()]]86 );8788describe(AnswerView, () => {89 const page = <AnswerView now={now} verdict={refused} />;
83 unmodified lines
173 <AnswerView landing={landing} now={now} verdict={landed} />174 );175176 expect(commitLinksOf(markup)).toStrictEqual([171 `/${project}/commit/${landed.base}`,172 `/${project}/commit/${landedSha}`,177 [`/${project}/commit/${landed.base}`, landed.base.slice(0, 7)],178 [`/${project}/commit/${landedSha}`, "The landing commit"],179 ]);180 expect(markup).toContain(`git show ${landedSha}`);175 expect(markup).toContain("The landing commit");181 });182183 it("links neither the head nor the merged tree: they live in the claim's fork", () => {184 const landed = verdictOf(Outcome.cases.Landed.make({ sha: landedSha }));
7 unmodified lines
192 });193194 it("links the base and no landing when the answer has not landed", () => {195 expect(commitLinksOf(markupOf(page))).toStrictEqual([191 `/${project}/commit/${refused.base}`,196 [`/${project}/commit/${refused.base}`, refused.base.slice(0, 7)],197 ]);198 });199});200
178 unmodified lines