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
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<p class="nol-site-eyebrow">{{ eyebrowText }}</p>
}
<div class="nol-site-hero-grid">
<h1 class="nol-site-hero-title" [id]="titleId()">{{ title() }}@if (accent(); as accentText) {<span class="nol-site-hero-accent">{{ accentText }}</span>}</h1>
<p class="nol-site-hero-copy"><ng-content />@if (closing(); as closingText) {<strong class="nol-site-hero-closing">{{ closingText }}</strong>}</p>
<h1 class="nol-site-hero-title" [id]="titleId()">{{ title() }}@if (accent(); as accentText) {{{ ' ' }}<span class="nol-site-hero-accent">{{ accentText }}</span>}</h1>
<p class="nol-site-hero-copy"><ng-content />@if (closing(); as closingText) {{{ ' ' }}<strong class="nol-site-hero-closing">{{ closingText }}</strong>}</p>
</div>
@if (actions().length > 0) {
<div class="nol-site-hero-actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/

import { Component, signal } from "@angular/core";
import { Component, PLATFORM_ID, signal } from "@angular/core";
import { type ComponentFixture, TestBed } from "@angular/core/testing";
import { page } from "vitest/browser";

Expand Down Expand Up @@ -85,6 +85,7 @@ describe("SiteHeroComponent", () => {
AppearanceFixture.reset();
document.documentElement.removeAttribute("data-nol-theme-mode");
await EmulatedMediaFixture.resetAsync();
vi.unstubAllGlobals();
await page.viewport(windowWidth, windowHeight);
});

Expand All @@ -95,9 +96,9 @@ describe("SiteHeroComponent", () => {
const images = DomFixture.allOf(hero(), "img", HTMLImageElement);

expect([part("section").getAttribute("aria-labelledby"), title.id, title.textContent, part(".nol-site-hero-accent").textContent]).toEqual([
"nol-site-hero-title", "nol-site-hero-title", "Your AI agents,working as one team.", "working as one team."]);
"nol-site-hero-title", "nol-site-hero-title", "Your AI agents, working as one team.", "working as one team."]);
expect([part(".nol-site-eyebrow").textContent?.trim(), part(".nol-site-hero-copy").textContent, part(".nol-site-hero-closing").innerText]).toEqual([
"Your agents. One team.", "Put your agents in the same chat.Less copying between agents.\nMore work done.", "Less copying between agents.\nMore work done."]);
"Your agents. One team.", "Put your agents in the same chat. Less copying between agents.\nMore work done.", "Less copying between agents.\nMore work done."]);
expect(links.map(t => [t.textContent, t.getAttribute("href"), t.classList.contains("nol-button-secondary")])).toEqual([
["Download TeamRundownload", "/download/", false], ["Get startedkeyboard_arrow_right", "/docs/", true]]);
expect(DomFixture.all(hero(), ".nol-site-hero-action-icon").map(t => t.getAttribute("aria-hidden"))).toEqual(["true", "true"]);
Expand Down Expand Up @@ -129,6 +130,23 @@ describe("SiteHeroComponent", () => {
expect(part("h1").textContent).toBe("Your AI agents,");
});

it("reads the headline and the side text as words apart where their accent line and closing words start in the prerendered page, and with nothing after them when they have none", async () => {
TestBed.configureTestingModule({ providers: [{ provide: PLATFORM_ID, useValue: "server" }] });
vi.stubGlobal("ngServerMode", true);
const prerendered = (selector: string): string | null => new DOMParser().parseFromString(part(selector).outerHTML, "text/html").body.textContent;
await renderAsync();
const title = prerendered("h1");
const copy = prerendered(".nol-site-hero-copy");
fixture.destroy();
await renderAsync(t => {
t.accent.set(null);
t.closing.set(null);
});

expect([title, copy, prerendered("h1"), prerendered(".nol-site-hero-copy")]).toEqual([
"Your AI agents, working as one team.", "Put your agents in the same chat. Less copying between agents.\nMore work done.", "Your AI agents,", "Put your agents in the same chat."]);
});

for (const scheme of ["light", "dark"]) {
it(`shows the ${scheme} theme's shot when the page sets no mode and the system's scheme is ${scheme}`, async () => {
await EmulatedMediaFixture.emulateAsync("prefers-color-scheme", scheme);
Expand Down Expand Up @@ -166,6 +184,15 @@ describe("SiteHeroComponent", () => {
const outer = hero().getBoundingClientRect();
const intro = box("section");
const title = box("h1");
const texts = Array.from(part("h1").childNodes).filter(t => t.nodeType === Node.TEXT_NODE);
const words = document.createRange();
words.selectNode(DomFixture.at(texts, 0));
const join = document.createRange();
join.selectNode(DomFixture.at(texts, 1));
const closingJoin = document.createRange();
closingJoin.selectNode(DomFixture.present(part(".nol-site-hero-closing").previousSibling));
const accent = box(".nol-site-hero-accent");
const lineHeight = Number.parseFloat(getComputedStyle(part("h1")).lineHeight);
const copy = box(".nol-site-hero-copy");
const actions = DomFixture.all(hero(), "a[nol-button]").map(t => t.getBoundingClientRect());
const shot = box(mode === ThemeMode.Dark ? ".nol-site-hero-shot-dark" : ".nol-site-hero-shot-light");
Expand All @@ -176,6 +203,10 @@ describe("SiteHeroComponent", () => {
AppearanceFixture.expectPixels(intro.left - outer.left, outer.right - intro.right);
AppearanceFixture.expectPixels(box(".nol-site-eyebrow").top - intro.top, rem(size.paddingTop));
AppearanceFixture.expectPixels(title.left, intro.left);
expect([join.getClientRects().length, closingJoin.toString(), closingJoin.getClientRects().length]).toEqual([0, " ", 0]);
AppearanceFixture.expectPixels(accent.left, title.left);
AppearanceFixture.expectPixels(accent.top - title.top, words.getClientRects().length * lineHeight);
AppearanceFixture.expectPixels(accent.bottom, title.bottom);
AppearanceFixture.expectPixels(first.left, intro.left);
AppearanceFixture.expectPixels(first.height, rem(2.5));
AppearanceFixture.expectPixels(first.top - box(".nol-site-hero-grid").bottom, rem(size.actionsTop));
Expand Down
Loading