-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
88 changed files
with
9,432 additions
and
486 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,74 @@ | ||
import { Locator, Page, expect } from '@playwright/test'; | ||
import { adjectives, animals, colors, uniqueNamesGenerator } from 'unique-names-generator'; | ||
|
||
export class Parcels { | ||
closeButton: Locator; | ||
confirmModal: Locator; | ||
confirmModalDeleteButton: Locator; | ||
createButton: Locator; | ||
nameField: Locator; | ||
newButton: Locator; | ||
parcelName: string; | ||
tableRow: Locator; | ||
tableRowDeleteButton: Locator; | ||
|
||
constructor(public page: Page) { | ||
this.parcelName = uniqueNamesGenerator({ dictionaries: [adjectives, colors, animals] }); | ||
|
||
this.updatePage(page); | ||
} | ||
|
||
async createParcel(dictionaryName: string) { | ||
await this.newButton.click(); | ||
await this.page.getByText(dictionaryName).click(); | ||
await this.updatePage(this.page); | ||
await expect(this.tableRow).not.toBeVisible(); | ||
await this.nameField.fill(this.parcelName); | ||
await this.createButton.click(); | ||
await this.closeButton.click(); | ||
await this.tableRow.waitFor({ state: 'attached' }); | ||
await this.tableRow.waitFor({ state: 'visible' }); | ||
await expect(this.tableRow).toBeVisible(); | ||
} | ||
|
||
async deleteParcel() { | ||
await expect(this.tableRow).toBeVisible(); | ||
await expect(this.tableRowDeleteButton).not.toBeVisible(); | ||
|
||
await this.tableRow.hover(); | ||
await this.tableRowDeleteButton.waitFor({ state: 'attached' }); | ||
await this.tableRowDeleteButton.waitFor({ state: 'visible' }); | ||
await expect(this.tableRowDeleteButton).toBeVisible(); | ||
|
||
await expect(this.confirmModal).not.toBeVisible(); | ||
await this.tableRowDeleteButton.click(); | ||
await this.confirmModal.waitFor({ state: 'attached' }); | ||
await this.confirmModal.waitFor({ state: 'visible' }); | ||
await expect(this.confirmModal).toBeVisible(); | ||
|
||
await expect(this.confirmModalDeleteButton).toBeVisible(); | ||
await this.confirmModalDeleteButton.click(); | ||
await this.tableRow.waitFor({ state: 'detached' }); | ||
await this.tableRow.waitFor({ state: 'hidden' }); | ||
await expect(this.tableRow).not.toBeVisible(); | ||
} | ||
|
||
async goto() { | ||
await this.page.goto('/parcels', { waitUntil: 'networkidle' }); | ||
await this.page.waitForTimeout(250); | ||
} | ||
|
||
updatePage(page: Page): void { | ||
this.closeButton = page.locator(`button:has-text("Close")`); | ||
this.confirmModal = page.locator(`.modal:has-text("Delete Parcel")`); | ||
this.confirmModalDeleteButton = page.locator(`.modal:has-text("Delete Parcel") >> button:has-text("Delete")`); | ||
this.createButton = page.locator(`button:has-text("Save")`); | ||
this.nameField = page.locator(`input[name="parcelName"]`); | ||
this.newButton = page.locator(`button:has-text("New")`); | ||
this.page = page; | ||
this.tableRow = page.locator(`.ag-row:has-text("${this.parcelName}")`); | ||
this.tableRowDeleteButton = page.locator( | ||
`.ag-row:has-text("${this.parcelName}") >> button[aria-label="Delete Parcel"]`, | ||
); | ||
} | ||
} |
This file contains 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 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,34 @@ | ||
import test, { type BrowserContext, type Page } from '@playwright/test'; | ||
import { Dictionaries } from '../fixtures/Dictionaries.js'; | ||
import { Parcels } from '../fixtures/Parcels.js'; | ||
let context: BrowserContext; | ||
let dictionaries: Dictionaries; | ||
let dictionaryName: string; | ||
let parcels: Parcels; | ||
let page: Page; | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
context = await browser.newContext(); | ||
page = await context.newPage(); | ||
dictionaries = new Dictionaries(page); | ||
parcels = new Parcels(page); | ||
|
||
await dictionaries.goto(); | ||
dictionaryName = await dictionaries.createDictionary(); | ||
await parcels.goto(); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await page.close(); | ||
await context.close(); | ||
}); | ||
|
||
test.describe.serial('Parcels', () => { | ||
test('Create parcel', async () => { | ||
await parcels.createParcel(dictionaryName); | ||
}); | ||
|
||
test('Delete parcel', async () => { | ||
await parcels.deleteParcel(); | ||
}); | ||
}); |
Oops, something went wrong.