Skip to content

Commit

Permalink
Playwright for firefox and webkit (#160)
Browse files Browse the repository at this point in the history
* i try fix

* Fix popover compat issue

* Remove global config

* Fix lint

* remove unused

* Fixed typos

* Skipping popover dependent tests in firefox and webkit

* Attempt to fix flaky fill

* Attempt to fix other flaky tests

Co-Authored-By: Nyby <[email protected]>

* Disabling concurrent tests

Co-Authored-By: Nyby <[email protected]>

* Removed comment

Co-Authored-By: Nyby <[email protected]>

---------

Co-authored-by: Anton <[email protected]>
Co-authored-by: BaBrixx <[email protected]>
Co-authored-by: Bastian Brix <[email protected]>
Co-authored-by: Nyby <[email protected]>
Co-authored-by: Nyby <[email protected]>
  • Loading branch information
6 people authored Dec 14, 2023
1 parent decb3e0 commit 7a2e059
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 71 deletions.
16 changes: 16 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
import type { PlaywrightTestConfig } from "@playwright/test";
import { devices } from "@playwright/test";

const config: PlaywrightTestConfig = {
workers: 1,
webServer: {
command: "yarn build && yarn preview",
port: 4173,
timeout: 10 * 60 * 1000,
},
testDir: "tests",
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},
{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},
],
};

export default config;
2 changes: 1 addition & 1 deletion src/lib/classes/automaton/IdMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export abstract class IdMap<
const storedMember = this.get(id);
if (storedMember && storedMember.id !== id) {
throw new TypeError(
`This map uses a different Id (${storedMember.id.rawId}) that is uniqely comparable to ${id.rawId}. You cannot use both in the same map.`,
`This map uses a different Id (${storedMember.id.rawId}) that is uniquely comparable to ${id.rawId}. You cannot use both in the same map.`,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/buttons/SvgButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
<div>
<button
style="justify-content: {justifyContent}"
{id}
bind:this={button}
on:click={click}
{popovertarget}
>
<svelte:component
this={icon}
{id}
{size}
{color}
ariaLabel=""
Expand Down
11 changes: 9 additions & 2 deletions src/lib/components/overlayMenu/OverlayMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@
open = Boolean(event.newState === "open");
}
// TODO: this check is unnecessary when support is universal: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/popover#browser_compatibility
const popoverIsSupported =
browser && Object.hasOwnProperty.call(HTMLElement.prototype, "popover");
/**
* Opens the context menu (Right-click menu)
*/
function openContextMenu() {
if (!overlayMenuPopover) return;
// Show the menu
if (!overlayMenuPopover.matches(":popover-open"))
if (popoverIsSupported && !overlayMenuPopover.matches(":popover-open"))
overlayMenuPopover.showPopover();
// Set up event listeners for closing the menu
Expand Down Expand Up @@ -103,7 +107,10 @@
* Closes the context menu (Right-click menu)
*/
function closeContextMenu() {
if (overlayMenuPopover?.matches(":popover-open")) {
if (
popoverIsSupported &&
overlayMenuPopover?.matches(":popover-open")
) {
overlayMenuPopover.hidePopover();
}
closeListenersController?.abort();
Expand Down
98 changes: 50 additions & 48 deletions src/lib/components/project/ProjectItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@
export let setAsActive: () => void;
export let rename: () => void;
const UniqeId = id.rawId.split(" ").join("-").toLowerCase();
const UniqueId = id.rawId.split(" ").join("-").toLowerCase();
</script>

<button on:click={setAsActive}>
<div class="project-item {itemType}" id={UniqeId}>
<div
class="left"
on:dblclick={rename}
on:keypress={(event) => {
if (event.key === "Enter") {
rename();
}
}}
role="button"
tabindex="0"
>
<div class="project-item {itemType}" id={UniqueId}>
<div
class="left"
on:click={setAsActive}
on:dblclick={rename}
on:keypress={(event) => {
if (event.key === "Enter") {
rename();
}
}}
role="button"
tabindex="0"
>
<div style="display: flex;">
<div class="circle" style="background-color: {color}">
<div class="icon">
{#if itemType === "component"}
Expand All @@ -43,47 +44,49 @@
</div>
<p>{id.rawId}</p>
</div>
<div>
{#if itemType === "component"}
<ProjectItemDropDownMenu
bind:description
bind:color
bind:includeInPeriodicCheck
{id}
{itemType}
/>
{:else}
<ProjectItemDropDownMenu
bind:description
bind:color
{id}
{itemType}
/>
{/if}
</div>
</div>
</button>
<div class="right">
{#if itemType === "component"}
<ProjectItemDropDownMenu
bind:description
bind:color
bind:includeInPeriodicCheck
{id}
{itemType}
/>
{:else}
<ProjectItemDropDownMenu
bind:description
bind:color
{id}
{itemType}
/>
{/if}
</div>
</div>

<style>
button {
display: block;
color: inherit;
font: inherit;
border: none;
border-bottom: 1px solid black;
padding: 0;
.left {
padding: 10px;
width: 100%;
overflow: hidden;
border-right: 1px solid rgba(28, 28, 28, 0.55);
border-image: linear-gradient(
rgba(0, 0, 0, 0) 20%,
rgba(0, 0, 0, 1) 20%,
rgba(0, 0, 0, 1) 80%,
rgba(0, 0, 0, 0) 80%
);
border-image-slice: 1;
}
button:focus-visible {
outline: 1px solid white;
outline-offset: -1px;
.right {
margin: 0 5px;
}
.left {
display: flex;
align-items: center;
width: 100%;
p {
overflow: hidden;
text-overflow: ellipsis;
}
.project-item {
Expand All @@ -95,7 +98,6 @@
display: flex;
justify-content: flex-start;
align-items: center;
padding: 10px;
border-bottom: 1px solid black;
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/project/ProjectItemDropDownMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
export let id: SystemId | ComponentId;
export let itemType: "system" | "component";
const UniqeId = id.rawId.split(" ").join("-").toLowerCase();
const UniqueId = id.rawId.split(" ").join("-").toLowerCase();
const colorOptions = [
"#8B0000", // Dark Red
Expand All @@ -40,7 +40,7 @@
"#900C3F", // Deep Red
];
const menuId = `${UniqeId}-menu`;
const menuId = `${UniqueId}-menu`;
let button: HTMLElement;
/**
Expand All @@ -57,7 +57,7 @@
bind:button
icon={More_vert}
popovertarget={menuId}
id={`${UniqeId}-button`}
id={`${UniqueId}-button`}
color="var(--sidebar-text-color)"
/>
<OverlayMenu anchor={button} id={menuId}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
color: inherit;
font: inherit;
border: none;
border-bottom: 1px solid black;
padding: 0;
width: 100%;
}
Expand All @@ -32,6 +31,11 @@
outline-offset: -1px;
}
p {
overflow: hidden;
text-overflow: ellipsis;
}
#global-dec {
background-color: var(--sidebar-element-color);
transition: var(--sidebar-element-transition);
Expand Down
13 changes: 13 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
<script lang="ts">
import { browser } from "$app/environment";
import ContextMenu from "$lib/components/contextMenu/ContextMenu.svelte";
if (browser) {
/**
* This is a temporary fix to not show the popover elements in Firefox, which has not enabled support for popover elements yet
* TOOO: remove this when the popover element is enabled by default: https://developer.mozilla.org/en-US/docs/Web/API/Popover_API#browser_compatibility
*/
if (!Object.hasOwnProperty.call(HTMLElement.prototype, "popover")) {
const style = document.createElement("style");
document.head.appendChild(style);
style.sheet?.insertRule("div[popover] { display: none; }");
}
}
</script>

<svelte:head>
Expand Down
Loading

0 comments on commit 7a2e059

Please sign in to comment.