mirror of
https://github.com/keycloak/keycloak.git
synced 2026-05-25 11:30:27 -05:00
Make fileChooser platform independent. (#41500)
* Make fileChooser platform independent. Fixes #41474 Signed-off-by: Stan Silvert <ssilvert@redhat.com> * Added node: prefix to imports. Signed-off-by: Stan Silvert <ssilvert@redhat.com> --------- Signed-off-by: Stan Silvert <ssilvert@redhat.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import path from "path";
|
||||
import { v4 as uuid } from "uuid";
|
||||
import adminClient from "../utils/AdminClient";
|
||||
import { assertRequiredFieldError } from "../utils/form";
|
||||
import { chooseFile } from "../utils/file-chooser";
|
||||
import { login } from "../utils/login";
|
||||
import { assertNotificationMessage } from "../utils/masthead";
|
||||
import { assertModalTitle, confirmModal } from "../utils/modal";
|
||||
@@ -132,19 +132,7 @@ test.describe("Clients test", () => {
|
||||
|
||||
test("Import client", async ({ page }) => {
|
||||
await page.getByTestId("importClient").click();
|
||||
|
||||
const fileChooserPromise = page.waitForEvent("filechooser");
|
||||
await page.getByText("Browse...").click();
|
||||
const fileChooser = await fileChooserPromise;
|
||||
await fileChooser.setFiles(
|
||||
new URL(
|
||||
path.join(
|
||||
path.dirname(import.meta.url),
|
||||
"../utils/files/import-identical-client.json",
|
||||
),
|
||||
).pathname,
|
||||
);
|
||||
|
||||
await chooseFile(page, "../utils/files/import-identical-client.json");
|
||||
await save(page);
|
||||
await assertNotificationMessage(
|
||||
page,
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { Page } from "@playwright/test";
|
||||
import path from "path";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export async function chooseFile(page: Page, file: string) {
|
||||
const fileChooserPromise = page.waitForEvent("filechooser");
|
||||
await page.getByText("Browse...").click();
|
||||
const fileChooser = await fileChooserPromise;
|
||||
await fileChooser.setFiles(
|
||||
new URL(path.join(path.dirname(import.meta.url), file)).pathname,
|
||||
);
|
||||
|
||||
const fileName = fileURLToPath(import.meta.url);
|
||||
const dirName = path.dirname(fileName);
|
||||
const pathName = path.resolve(dirName, file);
|
||||
|
||||
await fileChooser.setFiles(pathName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user