-
Notifications
You must be signed in to change notification settings - Fork 4
added custom color palette e2e tests #2124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
noahonyejese
wants to merge
18
commits into
main
Choose a base branch
from
test/custom-color-palette-e2e
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f4cee42
chore: adjusted test scripts
noahonyejese 444b980
refactor: Added test ids
noahonyejese 8d5a72b
chore: fixed missing translations
noahonyejese 18e938d
feat: implemented custom color palette e2e tests
noahonyejese f8047bd
refactor: data-testId => data-testid
noahonyejese cca66c3
chore: added CHANGELOG
noahonyejese d9d7548
Merge branch 'main' into test/custom-color-palette-e2e
noahonyejese 1418c70
fix: Fixed merge conflict
noahonyejese 74f4916
fix: delete correct name
noahonyejese c224fd8
fix: tried alternative approach
noahonyejese 02ebcfe
fix: use Trans id select edit & delete button
noahonyejese dc33386
fix: clear palettes before starting test
noahonyejese 78802fb
Merge branch 'main' into test/custom-color-palette-e2e
noahonyejese 7311c4d
fix: resolved conflict
noahonyejese 85b8bc8
fix: added timout to tab
noahonyejese eb3ab47
fix: await titles visibility
noahonyejese 65b3dbc
fix: Added more explicit locator & awaiting
noahonyejese 042b177
fix: await after saving
noahonyejese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
}); | ||
noahonyejese marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.