Skip to content

Commit

Permalink
biome formatting stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
PintoGideon committed Feb 6, 2024
1 parent f70aa88 commit e250497
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/components/CreateFeed/HelperComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const LocalFileList = ({
<span className="file-icon">
{isFolder ? <FolderIcon /> : <FileIcon />}
</span>
{fileName}
<div className="file-name-text">{fileName}</div>
</FlexItem>
</Flex>

Expand Down
9 changes: 6 additions & 3 deletions tests/fixtures/loggedIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import fs from "fs";
import path from "path";
import { faker } from "@faker-js/faker";
import createAccountHelper from "../helpers/createAccount";
export * from '@playwright/test';
export * from "@playwright/test";

// create new user account for each worker
// https://playwright.dev/docs/auth#moderate-one-account-per-parallel-worker
export const test = baseTest.extend<{}, { workerStorageState: string }>({
export const test = baseTest.extend<
Record<string, unknown>,
{ workerStorageState: string }
>({
// Use the same storage state for all tests in this worker.
storageState: ({ workerStorageState }, use) => use(workerStorageState),

Expand All @@ -33,7 +36,7 @@ export const test = baseTest.extend<{}, { workerStorageState: string }>({
// create a new user account
const username = faker.internet.userName();
const email = faker.internet.email();
const password = `testuser1234`;
const password = "testuser1234";
const baseURL = test.info().project.use.baseURL as string;
await createAccountHelper(baseURL, page, username, email, password);

Expand Down
137 changes: 69 additions & 68 deletions tests/library.spec.ts
Original file line number Diff line number Diff line change
@@ -1,72 +1,73 @@
import { test, expect } from "./fixtures/loggedIn.ts";
import path from "path";

test("Test Library Page", async ({ page }) => {
//Avoids timeouts.
test.slow();
await page.goto("library");

const modalSelector = "[role='dialog']";

// Click on the button to trigger the modal
await page.getByRole("button", { name: /upload/i }).click();

// Wait for the modal to appear
await page.waitForSelector(modalSelector);

// Get a handle to the modal element
const modalElementHandle = await page.$(modalSelector);

// Now you can interact with the modal as needed
// Example: assert that modal content is visible

if (modalElementHandle) {
const isModalVisible = await modalElementHandle.isVisible();
expect(isModalVisible).toBeTruthy();

const fileChooserPromise = page.waitForEvent("filechooser");
await page.getByRole("button", { name: /upload files/i }).click();
const fileChooser = await fileChooserPromise;

const SOME_FILE = path.join(__dirname, "..", "package-lock.json");
await fileChooser.setFiles(SOME_FILE);

// Extract the file name from the file-name div
const fileName = await page.$eval(".file-name", (element) =>
element.textContent,
);

// Check if the file name is 'package-lock.json'
expect(fileName).toBe("package-lock.json");

// Correct the selector for the "Push to File Storage" button
await page
.getByRole("button", {
name: /push to file storage/i,
})
.click();

const username = await page.$eval(
".pf-v5-c-menu-toggle__text",
(element) => element.textContent,
);

const directoryNameValue = await page.$eval(
"input[name='horizontal-form-name']",
(element) => element.textContent,
);
const expectedURL = `/library/${username}/uploads/${directoryNameValue}`;

// Start waiting for the progress measure to be 100%
await page.waitForFunction(() => {
const progressMeasure = document.querySelector(
".pf-v5-c-progress__measure",
);
return progressMeasure && progressMeasure.textContent === "100%";
});

// Click the close button to close the modal
await page.click("[aria-label='Close']");
expect(page.url()).toContain(expectedURL);
}
test("Tests File Uploads", async ({ page }) => {
//Avoids timeouts.
test.slow();
await page.goto("library");

const modalSelector = "[role='dialog']";

// Click on the button to trigger the modal
await page.getByRole("button", { name: /upload/i }).click();

// Wait for the modal to appear
await page.waitForSelector(modalSelector);

// Get a handle to the modal element
const modalElementHandle = await page.$(modalSelector);

// Now you can interact with the modal as needed
// Example: assert that modal content is visible

if (modalElementHandle) {
const isModalVisible = await modalElementHandle.isVisible();
expect(isModalVisible).toBeTruthy();

const fileChooserPromise = page.waitForEvent("filechooser");
await page.getByRole("button", { name: /upload files/i }).click();
const fileChooser = await fileChooserPromise;

const SOME_FILE = path.join(__dirname, "..", "package-lock.json");
await fileChooser.setFiles(SOME_FILE);

// Extract the file name from the file-name div
const fileName = await page.$eval(
".file-name-text",
(element: HTMLDivElement) => element.innerText,
);

// Check if the file name is 'package-lock.json'
expect(fileName).toBe("package-lock.json");

// Correct the selector for the "Push to File Storage" button
await page
.getByRole("button", {
name: /push to file storage/i,
})
.click();

const username = await page.$eval(
".pf-v5-c-menu-toggle__text",
(element) => element.textContent,
);

const directoryNameValue = await page.$eval(
"input[name='horizontal-form-name']",
(element: HTMLInputElement) => element.value,
);
const expectedURL = `/library/${username}/uploads/${directoryNameValue}`;

// Start waiting for the progress measure to be 100%
await page.waitForFunction(() => {
const progressMeasure = document.querySelector(
".pf-v5-c-progress__measure",
);
return progressMeasure && progressMeasure.textContent === "100%";
});

// Click the close button to close the modal
await page.click("[aria-label='Close']");
expect(page.url()).toContain(expectedURL);
}
});

0 comments on commit e250497

Please sign in to comment.