Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ You can also check the
- Improved filter section styling
- Maintenance
- Added authentication method to e2e tests
- Added e2e tests for custom color palettes
- Added authentication to Vercel previews for easier testing

# [5.2.4] - 2025-02-06
Expand Down
4 changes: 2 additions & 2 deletions app/charts/shared/legend-color.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ export const LegendColor = memo(function LegendColor({
{showTitle && segmentComponent && (
<OpenMetadataPanelWrapper component={segmentComponent}>
<Typography
data-testId="legendTitle"
data-testid="legendTitle"
component="div"
variant="caption"
color="primary.main"
>
{segmentComponent.label}
{segmentComponent?.label}
</Typography>
</OpenMetadataPanelWrapper>
)}
Expand Down
8 changes: 4 additions & 4 deletions app/configurator/components/color-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const CustomColorPicker = ({
}}
>
<Saturation
data-testId="color-picker-saturation"
data-testid="color-picker-saturation"
hsva={hsva}
onChange={(color) => {
const newHsva = { ...hsva, ...color, a: hsva.a };
Expand All @@ -115,10 +115,10 @@ const CustomColorPicker = ({
backgroundColor: hsvaToHex(hsva),
borderRadius: "50%",
}}
data-testId="color-square"
data-testid="color-square"
/>
<Hue
data-testId="color-picker-hue"
data-testid="color-picker-hue"
hue={hsva.h}
onChange={(newHue) => {
const newHsva = { ...hsva, ...newHue };
Expand Down Expand Up @@ -151,7 +151,7 @@ const CustomColorPicker = ({
onChange={updateColorInput}
/>
<ChromePicker
data-testId="color-picker-chrome"
data-testid="color-picker-chrome"
showAlpha={false}
showHue={false}
showColorPreview={false}
Expand Down
4 changes: 2 additions & 2 deletions app/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -1676,15 +1676,15 @@ msgstr "My palette"

#: app/login/components/color-palettes/profile-color-palette-content.tsx
msgid "login.profile.my-color-palettes.delete"
msgstr "login.profile.my-color-palettes.delete"
msgstr "Delete Color Palette"

#: app/login/components/color-palettes/profile-color-palette-content.tsx
msgid "login.profile.my-color-palettes.description"
msgstr "Save your first custom color palette to easily choose your colors while creating a visualization."

#: app/login/components/color-palettes/profile-color-palette-content.tsx
msgid "login.profile.my-color-palettes.edit"
msgstr "login.profile.my-color-palettes.edit"
msgstr "Edit Color Palette"

#: app/login/components/profile-content-tabs.tsx
#: app/login/components/profile-content-tabs.tsx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ const CategoricalColorPaletteCreator = (props: ColorPaletteCreatorProps) => {
<Button
variant="text"
fullWidth
data-testid="profile-add-new-color"
className={classes.addColorButton}
disabled={disabled}
startIcon={<Icon name="add" />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const ProfileColorPaletteContent = ({ title }: ProfileContentProps) => {
startIcon={<Icon name="add" />}
sx={{ width: "fit-content" }}
onClick={showAddForm}
data-testid="add-profile-color-palette"
>
<Trans id="login.profile.my-color-palettes.add" />
</Button>
Expand Down Expand Up @@ -153,6 +154,7 @@ const ColorPaletteRow = ({

return (
<ColorRowFlex
data-testid="profile-color-palette-row"
sx={{
paddingY: 3,
paddingRight: 4,
Expand Down Expand Up @@ -184,16 +186,16 @@ const ColorPaletteRow = ({
</Box>
<ColorRowFlex gap={3}>
<EditButton onClick={() => onEdit(paletteId)}>
<VisuallyHidden>
<Trans id="login.profile.my-color-palettes.edit">
Edit Color Palette
</Trans>
</VisuallyHidden>
<Typography
aria-hidden
color="primary"
sx={{ backgroundColor: "transparent" }}
>
<VisuallyHidden>
<Trans id="login.profile.my-color-palettes.edit">
Edit Color Palette
</Trans>
</VisuallyHidden>
<Icon name="edit" size={24} />
</Typography>
</EditButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ const ProfileColorPaletteForm = ({
<Box className={classes.saveButtonContainer}>
<Button
onClick={saveColorPalette}
data-testid="profile-save-color-palette"
disabled={
colorValues.length === 0 || titleInput === "" || noChanges
}
Expand Down Expand Up @@ -277,12 +278,14 @@ const ColorPaletteTypeSelector = ({
flexDirection={"column"}
gap={2}
>
<Radio
label={capitalize(type)}
value={type}
checked={type === selectedType}
onChange={handleChange}
/>
<Box data-testid={`profile-color-palette-${type}`}>
<Radio
label={capitalize(type)}
value={type}
checked={type === selectedType}
onChange={handleChange}
/>
</Box>
<ColorPaletteExample type={type} />
</Flex>
);
Expand Down
2 changes: 1 addition & 1 deletion app/login/components/login-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const LoginMenu = () => {
</>
) : (
<Button
data-testId="test-sign-in"
data-testid="test-sign-in"
variant="text"
color="primary"
size="small"
Expand Down
2 changes: 1 addition & 1 deletion app/login/components/profile-content-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const ProfileContentTabs = (props: ProfileContentTabsProps) => {
value="published"
/>
<Tab
data-testId="color-palettes-tab"
data-testid="color-palettes-tab"
className={classes.tab}
label={t({
id: "login.profile.my-color-palettes",
Expand Down
2 changes: 1 addition & 1 deletion e2e/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const setup = (contextOptions?: PlaywrightTestOptions["contextOptions"]) => {
}>({
auth: async ({ page }, use) => {
const auth = async () => {
const signInBtn = page.locator('[data-testId="test-sign-in"]');
const signInBtn = page.locator('[data-testid="test-sign-in"]');
await signInBtn.waitFor({ state: "visible", timeout: 5000 });
await signInBtn.click();
};
Expand Down
183 changes: 183 additions & 0 deletions e2e/custom-color-palette.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
import { Page } from "@playwright/test";

import { setup, sleep } from "./common";

const { test, expect, describe } = setup();

const addNewColor = async (page: Page, i: number) => {
await page.locator('[data-testid="profile-add-new-color"]').click();

await page.getByRole("button", { name: "Open Color Picker" }).last().click();
await sleep(1_000);

const saturation = page.locator('[data-testid="color-picker-saturation"]');
await saturation.waitFor({ state: "visible", timeout: 5000 });

const box = await saturation.boundingBox();
if (!box) {
throw new Error("Could not get saturation element bounding box");
}

const randomX = box.x + Math.random() * box.width;
const randomY = box.y + Math.random() * box.height;

await page.mouse.click(randomX, randomY);
await sleep(1_000);
await page.keyboard.press("Escape");
};

test("Custom color palettes on profile page should allow CREATE, UPDATE and DELETING palettes ", async ({
page,
auth,
}) => {
test.slow();

await page.goto("/en");
await auth();
await page.waitForLoadState("networkidle");
await page.goto("/en/profile");
const url = page.url();
expect(url.endsWith("/en/profile")).toBe(true);
await page.locator('[data-testid="color-palettes-tab"]').click();

//Create Categorical Palette
await page.locator('[data-testid="add-profile-color-palette"]').click();
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
await sleep(1_000);

const categoricalTitleInput = page.locator(
'input[name="custom-color-palette-title"]'
);
await categoricalTitleInput.waitFor({ state: "visible", timeout: 5000 });
await categoricalTitleInput.click();
await categoricalTitleInput.fill("Categorical Palette");
await page.keyboard.press("Enter");
await page.waitForTimeout(500);

for (let i = 0; i < 3; i++) {
await addNewColor(page, i);
}
await page.locator('[data-testid="profile-save-color-palette"]').click();
await sleep(1_000);

const categoricalTitleExists = await page
.getByText("Categorical Palette")
.isVisible();
expect(categoricalTitleExists).toBe(true);

//Create Sequential Palette
await page.locator('[data-testid="add-profile-color-palette"]').click();
await page
.locator('[data-testid="profile-color-palette-sequential"]')
.click();
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
await sleep(1_000);

const sequentialTitleInput = page.locator(
'input[name="custom-color-palette-title"]'
);
await sequentialTitleInput.waitFor({ state: "visible", timeout: 5000 });
await sequentialTitleInput.click();
await sequentialTitleInput.fill("Sequential Palette");
await page.keyboard.press("Enter");
await page.waitForTimeout(500);

await page.locator('[data-testid="profile-save-color-palette"]').click();
await sleep(1_000);

const sequentialTitleExists = await page
.getByText("Sequential Palette")
.isVisible();
expect(sequentialTitleExists).toBe(true);

//Create Diverging Palette (2 colors)
await page.locator('[data-testid="add-profile-color-palette"]').click();
await page.locator('[data-testid="profile-color-palette-diverging"]').click();
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
await sleep(1_000);

const divergingTwoTitleInput = page.locator(
'input[name="custom-color-palette-title"]'
);
await divergingTwoTitleInput.waitFor({ state: "visible", timeout: 5000 });
await divergingTwoTitleInput.click();
await divergingTwoTitleInput.fill("Diverging Palette (2)");
await page.keyboard.press("Enter");
await page.waitForTimeout(500);

await page.getByRole("button", { name: "Remove Color" }).first().click();
await sleep(1_000);

await page.locator('[data-testid="profile-save-color-palette"]').click();
await sleep(1_000);

const divergingTwoTitleExists = await page
.getByText("Diverging Palette (2)")
.isVisible();
expect(divergingTwoTitleExists).toBe(true);

//Create Diverging Palette (3 colors)
await page.locator('[data-testid="add-profile-color-palette"]').click();
await page.locator('[data-testid="profile-color-palette-diverging"]').click();
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
await sleep(1_000);

const divergingThreeTitleInput = page.locator(
'input[name="custom-color-palette-title"]'
);
await divergingThreeTitleInput.waitFor({ state: "visible", timeout: 5000 });
await divergingThreeTitleInput.click();
await divergingThreeTitleInput.fill("Diverging Palette (3)");
await page.keyboard.press("Enter");
await page.waitForTimeout(500);

await page.locator('[data-testid="profile-save-color-palette"]').click();
await sleep(1_000);

const divergingThreeTitleExists = await page
.getByText("Diverging Palette (3)")
.isVisible();
expect(divergingThreeTitleExists).toBe(true);

//Update Color palettes
//Edit Categorical Palette add more colors
await page
.getByRole("button", { name: "Edit Color Palette" })
.first()
.click();

await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
await sleep(1_000);

for (let i = 0; i < 3; i++) {
await addNewColor(page, i);
}
await page.locator('[data-testid="profile-save-color-palette"]').click();
await sleep(1_000);

//Edit Sequential Palette change type
await page
.getByRole("button", { name: "Edit Color Palette" })
.first()
.click();
await page
.locator('[data-testid="profile-color-palette-categorical"]')
.click();

await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
await sleep(1_000);

for (let i = 0; i < 3; i++) {
await addNewColor(page, i);
}
await page.locator('[data-testid="profile-save-color-palette"]').click();
await sleep(1_000);

//Delete Color palettes
for (let i = 0; i < 4; i++) {
await page
.getByRole("button", { name: "Delete Color Palette" })
.first()
.click();
}
});
6 changes: 3 additions & 3 deletions e2e/custom-color-picker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test("Custom Color Picker", async ({ page, selectors }) => {
(el) => window.getComputedStyle(el).backgroundColor
);

const saturation = page.locator('[data-testId="color-picker-saturation"]');
const saturation = page.locator('[data-testid="color-picker-saturation"]');
await saturation.waitFor({ state: "visible", timeout: 5000 });

await saturation.click();
Expand All @@ -47,7 +47,7 @@ test("Custom Color Picker", async ({ page, selectors }) => {

expect(finalColor).toBe("rgb(255, 0, 0)");

const hue = page.locator('[data-testId="color-picker-hue"]');
const hue = page.locator('[data-testid="color-picker-hue"]');
await hue.waitFor({ state: "visible", timeout: 5000 });

await hue.click();
Expand All @@ -60,7 +60,7 @@ test("Custom Color Picker", async ({ page, selectors }) => {
expect(selectedHueColor).toBe("rgb(0, 255, 248)");

//FIXME: figure out a way to test the color picker pen tool in this env
// const picker = page.locator('[data-testId="color-picker-chrome"]');
// const picker = page.locator('[data-testid="color-picker-chrome"]');
// await picker.waitFor({ state: "visible", timeout: 5000 });

// await picker.click();
Expand Down
2 changes: 1 addition & 1 deletion e2e/filters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe("Filters", () => {

await actions.mui.selectOption("Kanton");

const legend = page.locator('[data-testId="legendTitle"]');
const legend = page.locator('[data-testid="legendTitle"]');

await legend.waitFor({ state: "hidden", timeout: 5000 });
await expect(legend).toHaveCount(0);
Expand Down
Loading
Loading