-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* taxes tests * Create rude-clocks-attack.md * change locator for checkbox in exception country list * Trigger Build * locator fix * changed test name * Update rude-clocks-attack.md
- Loading branch information
1 parent
4d82f8f
commit 6f6e5ef
Showing
18 changed files
with
345 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"saleor-dashboard": minor | ||
--- | ||
|
||
Migrated taxes tests: | ||
- Change taxes in channel to use tax app | ||
- Change taxes in channel: enter prices without tax, do not show gross price, add country exception | ||
- Add new country and tax rates to it | ||
- Add new class with metadata and set tax rate for single country |
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,30 @@ | ||
import { Page } from "@playwright/test"; | ||
|
||
export class AddCountriesDialog { | ||
readonly page: Page; | ||
|
||
constructor( | ||
page: Page, | ||
readonly searchCountryInput = page | ||
.getByTestId("search-country-input") | ||
.locator("input"), | ||
readonly countryRow = page.getByTestId("country-row"), | ||
readonly addButton = page.getByTestId("add-button"), | ||
readonly rowRadioButton = page.locator("input[type='radio']"), | ||
) { | ||
this.page = page; | ||
} | ||
|
||
async typeSearchedCountry(countryName = "Canada") { | ||
await this.searchCountryInput.fill(countryName); | ||
} | ||
|
||
async checkAndSaveSingleCountry(countryName = "Canada") { | ||
await this.countryRow | ||
.filter({ hasText: countryName }) | ||
.locator(this.rowRadioButton) | ||
.click(); | ||
await this.addButton.click(); | ||
await this.countryRow.first().waitFor({ state: "hidden" }); | ||
} | ||
} |
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,160 @@ | ||
import { CHANNELS } from "@data/e2eTestData"; | ||
import { URL_LIST } from "@data/url"; | ||
import { AddCountriesDialog } from "@dialogs/addCountriesDialog"; | ||
import { MetadataSeoPage } from "@pageElements/metadataSeoPage"; | ||
import { BasePage } from "@pages/basePage"; | ||
import type { Page } from "@playwright/test"; | ||
|
||
export class TaxesPage extends BasePage { | ||
readonly page: Page; | ||
readonly addCountriesDialog: AddCountriesDialog; | ||
readonly metadataSeoPage: MetadataSeoPage; | ||
|
||
constructor( | ||
page: Page, | ||
readonly appOrFlatRateSelect = page | ||
.getByTestId("app-flat-select") | ||
.locator("[role='button']"), | ||
readonly chanelListRow = page.getByTestId("channels-list-rows"), | ||
readonly countriesListRow = page.getByTestId("countries-list-rows"), | ||
readonly classListRow = page.getByTestId("class-list-rows"), | ||
readonly countriesTab = page.getByTestId("countries-tab"), | ||
readonly taxClassTab = page.getByTestId("tax-classes-tab"), | ||
readonly enteredRenderedSection = page.getByTestId( | ||
"entered-rendered-prices-section", | ||
), | ||
readonly pricesEnteredWithTaxButton = page.locator( | ||
"[name='pricesEnteredWithTax'][ value='true']", | ||
), | ||
readonly pricesEnteredWithoutTaxButton = page.locator( | ||
"[name='pricesEnteredWithTax'][ value='false']", | ||
), | ||
readonly displayGrossPricesCheckbox = page.locator( | ||
"[name='displayGrossPrices']", | ||
), | ||
readonly addCountryButton = page.getByTestId("add-country-button"), | ||
readonly createClassButton = page.getByTestId("create-class-button"), | ||
readonly saveButton = page.getByTestId("button-bar-confirm"), | ||
readonly exceptionCountryRows = page.getByTestId("exception-country"), | ||
readonly exceptionCountryGrossPriceCheckbox = page.getByTestId( | ||
"display-gross-prices-checkbox", | ||
), | ||
readonly checkBoxCheckedState = page.locator("Mui-checked"), | ||
readonly exceptionCountriesCheckBoxCheckedState = page.locator( | ||
"[class*='Mui-checked']", | ||
), | ||
readonly searchTaxClassInput = page | ||
.getByTestId("search-tax-class-input") | ||
.locator("input"), | ||
readonly searchedCountryRows = page.getByTestId("country-rows"), | ||
|
||
readonly searchTaxCountryInput = page | ||
.getByTestId("search-tax-countries-input") | ||
.locator("input"), | ||
readonly taxClassNameInput = page | ||
.getByTestId("class-name-input") | ||
.locator("input"), | ||
readonly noTaxRateInput = page.getByTestId("No Taxes").locator("input"), | ||
readonly defaultRateInput = page | ||
.getByTestId("Country default rate") | ||
.locator("input"), | ||
readonly audioProductsRateInput = page | ||
.getByTestId("Audio Products (tapes, cds etc.)") | ||
.locator("input"), | ||
readonly dataServicesRateInput = page | ||
.getByTestId("Data services - storage and retrieval ") | ||
.locator("input"), | ||
readonly standardRateInput = page.getByTestId("standard").locator("input"), | ||
readonly temporaryUnmappedRateInput = page | ||
.getByTestId("Temporary Unmapped Other SKU - taxable default") | ||
.locator("input"), | ||
) { | ||
super(page); | ||
this.page = page; | ||
this.addCountriesDialog = new AddCountriesDialog(page); | ||
this.metadataSeoPage = new MetadataSeoPage(page); | ||
} | ||
|
||
async clickSelectMethodField() { | ||
await this.appOrFlatRateSelect.click(); | ||
} | ||
async typeAllTaxRatesForCountry( | ||
defaultRate: string, | ||
noTaxRate: string, | ||
audioRate: string, | ||
dataServiceRate: string, | ||
standardRate: string, | ||
temporaryRate: string, | ||
) { | ||
await this.defaultRateInput.fill(defaultRate); | ||
await this.audioProductsRateInput.fill(audioRate); | ||
await this.dataServicesRateInput.fill(dataServiceRate); | ||
await this.noTaxRateInput.fill(noTaxRate); | ||
await this.standardRateInput.fill(standardRate); | ||
await this.temporaryUnmappedRateInput.fill(temporaryRate); | ||
} | ||
async clickCountriesTab() { | ||
await this.countriesTab.click(); | ||
await this.countriesListRow.first().waitFor({ state: "visible" }); | ||
} | ||
async clickTaxClassTab() { | ||
await this.taxClassTab.click(); | ||
await this.classListRow.first().waitFor({ state: "visible" }); | ||
} | ||
async clickCountryFromList(countryCode: string) { | ||
await this.countriesListRow.filter({ hasText: countryCode }).click(); | ||
} | ||
async clickSaveButton() { | ||
await this.saveButton.click(); | ||
} | ||
async typeTaxClassName(taxClassName: string) { | ||
await this.taxClassNameInput.fill(taxClassName); | ||
} | ||
async typeSearchedTaxCountryName(taxCountryName: string) { | ||
await this.searchTaxCountryInput.fill(taxCountryName); | ||
} | ||
async typeTaxRateInSearchedCountryRow( | ||
taxCountryName: string, | ||
taxRateValue: string, | ||
) { | ||
await this.searchedCountryRows | ||
.filter({ hasText: taxCountryName }) | ||
.locator("input") | ||
.fill(taxRateValue); | ||
} | ||
async clickCreateClassButton() { | ||
await this.createClassButton.click(); | ||
} | ||
|
||
async selectTaxCalculationMethod(method: "FLAT_RATES" | "TAX_APP") { | ||
await this.clickSelectMethodField(); | ||
await this.page.getByTestId(`select-field-option-${method}`).click(); | ||
} | ||
|
||
async selectPricesWithoutTaxes() { | ||
await this.enteredRenderedSection | ||
.locator(this.pricesEnteredWithoutTaxButton) | ||
.click(); | ||
} | ||
async selectPricesWithTaxes() { | ||
await this.enteredRenderedSection | ||
.locator(this.pricesEnteredWithTaxButton) | ||
.click(); | ||
} | ||
async clickShowGrossPricesInStorefront() { | ||
await this.enteredRenderedSection | ||
.locator(this.displayGrossPricesCheckbox) | ||
.click(); | ||
} | ||
|
||
async clickAddCountryButton() { | ||
await this.addCountryButton.click(); | ||
} | ||
async selectChannel(channelName: string) { | ||
await this.chanelListRow.filter({ hasText: channelName }).click(); | ||
} | ||
|
||
async gotoChannelsTabUrl() { | ||
await this.page.goto(URL_LIST.taxChannel + CHANNELS.plnChannel.id); | ||
} | ||
} |
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,77 @@ | ||
import { CHANNELS, COUNTRIES } from "@data/e2eTestData"; | ||
import { ConfigurationPage } from "@pages/configurationPage"; | ||
import { TaxesPage } from "@pages/taxesPage"; | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test.use({ storageState: "playwright/.auth/admin.json" }); | ||
|
||
let configurationPage: ConfigurationPage; | ||
let taxesPage: TaxesPage; | ||
|
||
test.beforeEach(({ page }) => { | ||
configurationPage = new ConfigurationPage(page); | ||
taxesPage = new TaxesPage(page); | ||
}); | ||
|
||
test("TC: SALEOR_115 Change taxes in channel to use tax app @taxes @e2e", async () => { | ||
await configurationPage.gotoConfigurationView(); | ||
await configurationPage.openTaxes(); | ||
await taxesPage.selectChannel(CHANNELS.channelForTaxEdition.name); | ||
await taxesPage.selectTaxCalculationMethod("TAX_APP"); | ||
await taxesPage.clickSaveButton(); | ||
await taxesPage.expectSuccessBanner(); | ||
}); | ||
test("TC: SALEOR_116 Change taxes in channel: enter prices without tax, do not show gross price, add country exception @taxes @e2e", async () => { | ||
await taxesPage.gotoChannelsTabUrl(); | ||
await taxesPage.selectChannel(CHANNELS.channelForTaxEdition.name); | ||
|
||
await taxesPage.selectPricesWithoutTaxes(); | ||
await taxesPage.clickShowGrossPricesInStorefront(); | ||
await taxesPage.clickAddCountryButton(); | ||
await taxesPage.addCountriesDialog.typeSearchedCountry("Canada"); | ||
await taxesPage.addCountriesDialog.checkAndSaveSingleCountry("Canada"); | ||
await expect(taxesPage.exceptionCountryRows).toContainText("Canada"); | ||
expect( | ||
await taxesPage.exceptionCountryRows | ||
.locator(taxesPage.exceptionCountriesCheckBoxCheckedState) | ||
.count(), | ||
).toEqual(1); | ||
await taxesPage.clickSaveButton(); | ||
await taxesPage.expectSuccessBanner(); | ||
}); | ||
|
||
test("TC: SALEOR_117 Add new country and tax rates to it @taxes @e2e", async () => { | ||
await taxesPage.gotoChannelsTabUrl(); | ||
await taxesPage.clickCountriesTab(); | ||
await taxesPage.clickAddCountryButton(); | ||
await taxesPage.addCountriesDialog.typeSearchedCountry( | ||
COUNTRIES.countryToBeAddedInTaxes.name, | ||
); | ||
|
||
await taxesPage.addCountriesDialog.checkAndSaveSingleCountry( | ||
COUNTRIES.countryToBeAddedInTaxes.name, | ||
); | ||
expect(await taxesPage.countriesListRow.first()).toHaveText( | ||
COUNTRIES.countryToBeAddedInTaxes.name, | ||
); | ||
await taxesPage.typeAllTaxRatesForCountry("23", "0", "16", "7", "21", "19"); | ||
await taxesPage.clickSaveButton(); | ||
await taxesPage.expectSuccessBanner(); | ||
}); | ||
|
||
test("TC: SALEOR_118 Add new class with metadata and set tax rate for single country @taxes @e2e", async () => { | ||
await taxesPage.gotoChannelsTabUrl(); | ||
await taxesPage.clickTaxClassTab(); | ||
await taxesPage.clickCreateClassButton(); | ||
expect(await taxesPage.taxClassNameInput).toHaveValue("New tax class"); | ||
|
||
await taxesPage.typeTaxClassName("Automation test tax class"); | ||
await taxesPage.typeSearchedTaxCountryName("United States of America"); | ||
await taxesPage.typeTaxRateInSearchedCountryRow( | ||
"United States of America", | ||
"20", | ||
); | ||
await taxesPage.metadataSeoPage.expandAndAddAllMetadata(); | ||
await taxesPage.clickSaveButton(); | ||
await taxesPage.expectSuccessBanner(); | ||
}); |
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
Oops, something went wrong.