synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
85 lines (84 loc) • 2.43 kB
JavaScript
import { screen as r, waitFor as a, within as i } from "@testing-library/react";
import { REMOVE_BUTTON_LABEL as m } from "./ResourceAccessItem.js";
import { PUBLIC_GROUP_DISPLAY_TEXT as B, AUTHENTICATED_GROUP_DISPLAY_TEXT as T } from "../TeamBadge.js";
import { ADD_PUBLIC_PRINCIPALS_BUTTON_TEXT as x, ADD_PRINCIPAL_TO_ACL_COMBOBOX_LABEL as y } from "./AclEditor.js";
function u(e, n) {
return e.find((t) => i(t).queryByText(n, { exact: !1 }));
}
async function R(e, n, t) {
let o;
try {
await a(() => {
o = u(e, n), expect(o).toBeInTheDocument();
});
} catch (l) {
throw r.debug(), new Error(`Principal ${n} not found in ACL`, { cause: l });
}
const c = i(o).queryByRole("combobox");
return c ? expect(c).toHaveTextContent(t) : i(o).getByText(t), o;
}
function b(e, n, t) {
expect(i(e).queryByRole("link") ?? e).toHaveTextContent(
n
);
const o = i(e).queryByRole("combobox");
o ? expect(o).toHaveTextContent(t) : i(e).getByText(t);
}
async function d(e, n, t = !0) {
const o = i(e).getByRole("button", {
name: m
});
await n.click(o), t && await a(() => {
expect(o).not.toBeInTheDocument(), expect(e).not.toBeInTheDocument();
});
}
async function h(e, n, t) {
const o = i(e).getByRole("combobox");
await n.click(o);
const c = r.getByRole("option", {
name: t
});
await n.click(c), await a(() => {
expect(c).not.toBeInTheDocument();
});
}
function w() {
return r.queryByRole("combobox", {
name: y
});
}
async function A(e, n) {
const t = w();
expect(t).toBeInTheDocument(), await e.clear(t), await e.type(t, n);
const o = await r.findByText(new RegExp(`\\(@${n}\\)`));
await e.click(o), await a(() => expect(o).not.toBeInTheDocument());
const c = r.getAllByRole("row");
return c[c.length - 1];
}
async function _(e) {
const n = r.getByRole("button", {
name: x
});
await e.click(n);
let t = [], o, c;
return await a(() => {
t = r.getAllByRole("row"), o = u(t, B), c = u(
t,
T
), expect(o).toBeInTheDocument(), expect(c).toBeInTheDocument();
}), {
publicRow: t[t.length - 2],
authenticatedUsersRow: t[t.length - 1]
};
}
export {
_ as addPublicToAcl,
A as addUserToAcl,
b as confirmItem,
R as confirmItemViaQuery,
w as queryForAddUserCombobox,
u as queryForRowWithPrincipalName,
d as removeItem,
h as updatePermissionLevel
};
//# sourceMappingURL=AclEditor.test-utils.js.map