59 lines
2.4 KiB
TypeScript
59 lines
2.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { readFileSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
|
|
const readSource = () => readFileSync(resolve(__dirname, "./StartupMeetingAuth.vue"), "utf8");
|
|
|
|
describe("StartupMeetingAuth permissions", () => {
|
|
it("does not load project members unless the role can read project members", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).toContain('can("project.members.list")');
|
|
expect(source).toContain("if (canReadMembers.value)");
|
|
});
|
|
|
|
it("does not lazily create kickoff records from row click or edit action", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).not.toContain("createKickoff");
|
|
expect(source).toContain("if (!row.meeting_id) return");
|
|
});
|
|
|
|
it("renders rows from kickoff records instead of center placeholders", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).toContain("const siteMap = computed");
|
|
expect(source).toContain("return kickoffItems.value");
|
|
expect(source).not.toContain("return sites.value");
|
|
});
|
|
|
|
it("renders kickoff operation column with edit action only", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).toContain(":label=\"TEXT.common.labels.actions\"");
|
|
expect(source).toContain('can("startup.auth.update")');
|
|
expect(source).toContain("canUpdateAuth");
|
|
expect(source).not.toContain("canDeleteAuth");
|
|
expect(source).toContain("v-if=\"canUpdateAuth && scope.row.meeting_id\"");
|
|
expect(source).toContain("@click.stop=\"openKickoffEditor(scope.row)\"");
|
|
expect(source).not.toContain("removeKickoff");
|
|
expect(source).toContain("<KickoffEditorDrawer");
|
|
});
|
|
|
|
it("uses backend contact display names before falling back to member lookup", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).toContain("row.contact_display");
|
|
expect(source.indexOf("row.contact_display")).toBeLessThan(source.indexOf("memberNameMap.value[c] || c"));
|
|
});
|
|
|
|
it("loads site contact display names independently from project member permissions", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).toContain("fetchSites(studyId, { limit: 500 })");
|
|
expect(source).toContain("if (canReadMembers.value)");
|
|
expect(source.indexOf("fetchSites(studyId, { limit: 500 })")).toBeLessThan(source.indexOf("if (canReadMembers.value)"));
|
|
expect(source.indexOf("contact_display: site.contact_display")).toBeLessThan(source.indexOf("const membersResp = canReadMembers.value"));
|
|
});
|
|
});
|