added test for resources (#23706)
* added test for resources fixes: #21251 * pr comments * Rename `data-testId` to `data-testid` --------- Co-authored-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
parent
e803cd8b84
commit
7f9ea3afbb
6 changed files with 58 additions and 17 deletions
|
@ -8,7 +8,7 @@ export default defineConfig({
|
|||
fullyParallel: true,
|
||||
forbidOnly: !!process.env.CI,
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
workers: 1,
|
||||
reporter: "html",
|
||||
use: {
|
||||
baseURL: process.env.CI
|
||||
|
@ -38,15 +38,6 @@ export default defineConfig({
|
|||
dependencies: ["setup", "import realms"],
|
||||
testIgnore: ["**/personal-info.spec.ts"],
|
||||
},
|
||||
{
|
||||
name: "firefox",
|
||||
use: {
|
||||
...devices["Desktop Firefox"],
|
||||
storageState: ".auth/user.json",
|
||||
},
|
||||
dependencies: ["setup", "import realms"],
|
||||
testIgnore: ["**/personal-info.spec.ts"],
|
||||
},
|
||||
{
|
||||
name: "personal-info",
|
||||
use: {
|
||||
|
|
|
@ -18,12 +18,14 @@ const Resources = () => {
|
|||
unmountOnExit
|
||||
>
|
||||
<Tab
|
||||
data-testid="myResources"
|
||||
eventKey={0}
|
||||
title={<TabTitleText>{t("myResources")}</TabTitleText>}
|
||||
>
|
||||
<ResourcesTab />
|
||||
</Tab>
|
||||
<Tab
|
||||
data-testid="sharedWithMe"
|
||||
eventKey={1}
|
||||
title={<TabTitleText>{t("sharedWithMe")}</TabTitleText>}
|
||||
>
|
||||
|
|
|
@ -166,6 +166,7 @@ export const ResourcesTab = ({ isShared = false }: ResourcesTabProps) => {
|
|||
>
|
||||
<Tr>
|
||||
<Td
|
||||
data-testid={`expand-${resource.name}`}
|
||||
expand={
|
||||
!isShared
|
||||
? {
|
||||
|
|
|
@ -121,7 +121,7 @@ export const ShareTheResource = ({
|
|||
<Button
|
||||
key="confirm"
|
||||
variant="primary"
|
||||
id="done"
|
||||
data-testid="done"
|
||||
isDisabled={!isValid}
|
||||
type="submit"
|
||||
form="share-form"
|
||||
|
@ -147,6 +147,7 @@ export const ShareTheResource = ({
|
|||
<InputGroup>
|
||||
<KeycloakTextInput
|
||||
id="users"
|
||||
data-testid="users"
|
||||
placeholder={t("usernamePlaceholder")}
|
||||
validated={
|
||||
errors.usernames
|
||||
|
@ -160,7 +161,7 @@ export const ShareTheResource = ({
|
|||
<Button
|
||||
key="add-user"
|
||||
variant="primary"
|
||||
id="add"
|
||||
data-testid="add"
|
||||
onClick={() => append({ value: "" })}
|
||||
isDisabled={isDisabled}
|
||||
>
|
||||
|
|
|
@ -6,8 +6,10 @@ type SharedWithProps = {
|
|||
permissions?: Permission[];
|
||||
};
|
||||
|
||||
export const SharedWith = ({ permissions: p = [] }: SharedWithProps) => {
|
||||
return (
|
||||
export const SharedWith = ({ permissions: p = [] }: SharedWithProps) => (
|
||||
<div
|
||||
data-testid={`shared-with-${p.length ? p.map((e) => e.username) : "none"}`}
|
||||
>
|
||||
<Trans i18nKey="resourceSharedWith" count={p.length}>
|
||||
<strong>
|
||||
{{
|
||||
|
@ -20,5 +22,5 @@ export const SharedWith = ({ permissions: p = [] }: SharedWithProps) => {
|
|||
}}
|
||||
</strong>
|
||||
</Trans>
|
||||
);
|
||||
};
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -5,7 +5,51 @@ test.describe("My resources page", () => {
|
|||
test("List my resources", async ({ page }) => {
|
||||
await login(page, "jdoe", "jdoe", "photoz");
|
||||
await page.getByTestId("resources").click();
|
||||
//await expect(page.getByTestId("row[0].name")).toHaveText("one");
|
||||
|
||||
await expect(page.getByRole("gridcell", { name: "one" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("Nothing is shared with alice", async ({ page }) => {
|
||||
await login(page, "alice", "alice", "photoz");
|
||||
await page.getByTestId("resources").click();
|
||||
|
||||
await page.getByTestId("sharedWithMe").click();
|
||||
const tableData = await page.locator("table > tr").count();
|
||||
expect(tableData).toBe(0);
|
||||
});
|
||||
|
||||
test("Share one with alice", async ({ page }) => {
|
||||
await login(page, "jdoe", "jdoe", "photoz");
|
||||
await page.getByTestId("resources").click();
|
||||
|
||||
await page.getByTestId("expand-one").click();
|
||||
await expect(page.getByText("This resource is not shared.")).toBeVisible();
|
||||
|
||||
await page.getByTestId("share-one").click();
|
||||
await page.getByTestId("users").click();
|
||||
await page.getByTestId("users").fill("alice");
|
||||
await page.getByTestId("add").click();
|
||||
|
||||
await expect(page.getByRole("group", { name: "Share with" })).toHaveText(
|
||||
"Share with alice",
|
||||
);
|
||||
|
||||
await page.getByRole("button", { name: "Options menu" }).click();
|
||||
await page.getByRole("option", { name: "album:view" }).click();
|
||||
await page.getByRole("button", { name: "Options menu" }).click();
|
||||
|
||||
await page.getByTestId("done").click();
|
||||
|
||||
await page.getByTestId("expand-one").click();
|
||||
expect(page.getByTestId("shared-with-alice")).toBeDefined();
|
||||
});
|
||||
|
||||
test("One is shared with alice", async ({ page }) => {
|
||||
await login(page, "alice", "alice", "photoz");
|
||||
await page.getByTestId("resources").click();
|
||||
|
||||
await page.getByTestId("sharedWithMe").click();
|
||||
const rowData = await page.getByTestId("row[0].name").allTextContents();
|
||||
expect(rowData).toEqual(["one"]);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue