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
19 changes: 19 additions & 0 deletions src/components/DomainFormModal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,22 @@ describe("DomainFormModal routing-only hostnames", () => {
expect(saved.route_only_aliases).toEqual(["dashboard.example.com"]);
});
});

describe("DomainFormModal static caching", () => {
it("emits the static-cache toggle when enabled on the domain", async () => {
const wrapper = mountModal({
id: "d1",
service: "web",
container_port: 80,
domain: "api.example.com",
ssl: { enabled: false, auto_cert: false },
static_cache: true,
});

document.querySelector<HTMLButtonElement>(".btn-primary")?.click();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using document.querySelector is slightly brittle and bypasses the Vue Test Utils wrapper. It's more idiomatic to use wrapper.find to target the button.

Suggested change
document.querySelector<HTMLButtonElement>(".btn-primary")?.click();
await wrapper.find(".btn-primary").trigger("click");

await wrapper.vm.$nextTick();

const saved = wrapper.emitted("save")?.[0]?.[0] as DomainConfig;
expect(saved.static_cache).toBe(true);
});
});
16 changes: 16 additions & 0 deletions src/components/DomainFormModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@
</div>
</div>

<div class="form-group checkbox-group">
<label class="checkbox-label">
<input v-model="form.static_cache" type="checkbox" />
<span>Cache static assets in the browser</span>
</label>
<span class="hint">
Sets a long cache on static files (styles, scripts, images, fonts). Dynamic responses keep the app's own
cache headers.
</span>
</div>

<div class="form-group">
<label>Domain Aliases</label>
<div class="aliases-input">
Expand Down Expand Up @@ -155,6 +166,7 @@ const form = ref<{
ssl: { enabled: boolean; auto_cert: boolean };
aliases: string[];
route_only_aliases: string[];
static_cache: boolean;
}>({
domain: "",
service: "",
Expand All @@ -164,6 +176,7 @@ const form = ref<{
ssl: { enabled: false, auto_cert: false },
aliases: [],
route_only_aliases: [],
static_cache: false,
});

watch(
Expand All @@ -183,6 +196,7 @@ watch(
},
aliases: [...(props.domain.aliases || [])],
route_only_aliases: [...(props.domain.route_only_aliases || [])],
static_cache: props.domain.static_cache || false,
};
} else {
form.value = {
Expand All @@ -194,6 +208,7 @@ watch(
ssl: { enabled: false, auto_cert: false },
aliases: [],
route_only_aliases: [],
static_cache: false,
};
}
}
Expand Down Expand Up @@ -234,6 +249,7 @@ function handleSubmit() {
ssl: form.value.ssl,
aliases: form.value.aliases.filter((a) => a.trim() !== ""),
route_only_aliases: form.value.route_only_aliases.filter((a) => a.trim() !== ""),
static_cache: form.value.static_cache || undefined,
};

emit("save", domainData);
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface DomainConfig {
ssl: SSLConfig;
aliases?: string[];
route_only_aliases?: string[];
static_cache?: boolean;
}

export interface QuickAction {
Expand Down
Loading