Skip to content

Commit

Permalink
Remove the data-test attribute in items, used in Playwright tests
Browse files Browse the repository at this point in the history
Easy to avoid storing this extra info in the DOM
  • Loading branch information
raimohanska committed Feb 18, 2024
1 parent 7aa9bc2 commit 983d39d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
12 changes: 0 additions & 12 deletions frontend/src/board/ItemView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ export const ItemView = ({
dispatch,
)

const dataTest = L.combineTemplate({
text: L.view(item, (i) => (i.type === "note" || i.type === "text" ? i.text : "")),
type: L.view(item, "type"),
selected,
}).pipe(
L.map(({ text, selected, type }: { text: string; selected: boolean; type: ItemType }) => {
const textSuffix = text ? "-" + text : ""
return selected ? `${type}-selected${textSuffix}` : `${type}${textSuffix}`
}),
)

function itemPadding(i: Item) {
if (i.type != "note") return undefined

Expand All @@ -109,7 +98,6 @@ export const ItemView = ({
<span
title={L.view(isLocked, (l) => (l ? "Item is selected by another user" : ""))}
ref={ref}
data-test={dataTest}
data-itemid={id}
draggable={L.view(itemFocus, (f) => f !== "editing")}
onClick={onClick}
Expand Down
8 changes: 3 additions & 5 deletions playwright/src/pages/BoardPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,13 @@ export function BoardPage(page: Page) {
},
async createNoteWithText(x: number, y: number, text: string) {
await createNew(this.newNoteOnPalette, x, y)
await expect(this.getNote("HELLO")).toBeVisible()
await page.keyboard.type(`${text}`)
await page.keyboard.press("Escape")
await expect(this.getNote(text)).toBeVisible()
return this.getNote(text)
},
async createText(x: number, y: number, text: string) {
await createNew(this.newTextOnPalette, x, y)
await expect(this.getText("HELLO")).toBeVisible()
await page.keyboard.type(`${text}`)
await expect(this.getText(text)).toBeVisible()
return this.getText(text)
Expand All @@ -132,13 +130,13 @@ export function BoardPage(page: Page) {
await dragElementOnBoard(bottomCorner, x, y)
},
getNote(name: string) {
return page.locator(`[data-test^="note"][data-test*="${name}"]`)
return page.locator(`.board > .note`).filter({ hasText: name })
},
getText(name: string) {
return page.locator(`[data-test^="text"][data-test*="${name}"]`)
return page.locator(`.board > .text`).filter({ hasText: name })
},
getArea(name: string) {
return page.locator(`[data-test^="container"]`).filter({ hasText: name })
return page.locator(`.board > .container`).filter({ hasText: name })
},
async assertItemPosition(item: Locator, x: number, y: number) {
const pos = await getElementPosition(item)
Expand Down

0 comments on commit 983d39d

Please sign in to comment.