Skip to content

Commit

Permalink
[E2E] Reverting changes made to attr spec (#5079)
Browse files Browse the repository at this point in the history
* fixing attr  test

* fixing attr slug
  • Loading branch information
yellowee authored Jul 30, 2024
1 parent 1fdcb9e commit dba1594
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-waves-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can now run all e2e tests without attributes.spec interference
48 changes: 29 additions & 19 deletions playwright/tests/attributes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { ATTRIBUTES } from "@data/e2eTestData";
import { AttributesPage } from "@pages/attributesPage";
import { ConfigurationPage } from "@pages/configurationPage";
import { BrowserContext, expect, test } from "@playwright/test";
import { expect, test } from "@playwright/test";
import faker from "faker";

let context: BrowserContext;
test.use({ storageState: "./playwright/.auth/admin.json" });

let attributesPage: AttributesPage;
let configurationPage: ConfigurationPage;

test.beforeEach(async ({ browser }) => {
context = await browser.newContext({
storageState: "playwright/.auth/admin.json",
});

const page = await context.newPage();

test.beforeEach(({ page }) => {
attributesPage = new AttributesPage(page);
configurationPage = new ConfigurationPage(page);
});
Expand All @@ -24,9 +19,12 @@ const attributeClasses = ["PRODUCT_TYPE", "PAGE_TYPE"];

for (const attr of attributeClasses) {
for (const type of ATTRIBUTES.attributeTypesWithAbilityToAddValues.names) {
const uniqueSlug = `${attr}-${type.replace(" ", "-")}-${SALEOR_124_uuid}`;
const uniqueSlug = `${attr}-${type}-${SALEOR_124_uuid}`.replace(/\s+/g, "-");

test(`TC: SALEOR_124 User should be able to create ${attr} ${type} attribute with ability to add values, required, public @e2e @attributes`, async () => {
test(`TC: SALEOR_124 User should be able to create ${attr} ${type} attribute with ability to add values, required, public @e2e @attributes`, async ({
page,
}) => {
await page.context().storageState({ path: "./playwright/.auth/admin.json" });
await configurationPage.goToConfigurationView();
await configurationPage.openAttributes();
await attributesPage.clickCreateAttributeButton();
Expand Down Expand Up @@ -55,9 +53,12 @@ const SALEOR_125_uuid = faker.datatype.uuid();

for (const attr of attributeClasses) {
for (const type of ATTRIBUTES.attributeTypesWithoutAbilityToAddValues.names) {
const uniqueSlug = `${attr}-${type.replace(" ", "-")}-${SALEOR_125_uuid}`;
const uniqueSlug = `${attr}-${type}-${SALEOR_125_uuid}`.replace(/\s+/g, "-");

test(`TC: SALEOR_125 User should be able to create ${attr} ${type} attribute without ability to add values, NOT required, private @e2e @attributes`, async () => {
test(`TC: SALEOR_125 User should be able to create ${attr} ${type} attribute without ability to add values, NOT required, private @e2e @attributes`, async ({
page,
}) => {
await page.context().storageState({ path: "./playwright/.auth/admin.json" });
await configurationPage.goToConfigurationView();
await configurationPage.openAttributes();
await attributesPage.waitForDOMToFullyLoad();
Expand Down Expand Up @@ -87,17 +88,20 @@ const SALEOR_126_uuid = faker.datatype.uuid();

for (const attr of attributeClasses) {
for (const entity of ATTRIBUTES.attributeReferencesEntities.names) {
const uniqueSlug = `${attr}-${entity.replaceAll(" ", "-")}-${SALEOR_126_uuid}`;
const uniqueSlug = `${attr}-${entity}-${SALEOR_126_uuid}`.replace(/\s+/g, "-");

test(`TC: SALEOR_126 User should be able to create ${attr} References attribute for ${entity}, NOT required, public @e2e @attributes`, async () => {
test(`TC: SALEOR_126 User should be able to create ${attr} References attribute for ${entity}, NOT required, public @e2e @attributes`, async ({
page,
}) => {
await page.context().storageState({ path: "./playwright/.auth/admin.json" });
await configurationPage.goToConfigurationView();
await configurationPage.openAttributes();
await attributesPage.waitForDOMToFullyLoad();
await attributesPage.clickCreateAttributeButton();
await attributesPage.selectAttributeType(attr);
await attributesPage.typeAttributeDefaultLabel(`${attr} - REFERENCES for ${entity}`);
await attributesPage.fillAttributeSlug(uniqueSlug);
await attributesPage.selectAttributeInputType("Reference");
await attributesPage.selectAttributeInputType("REFERENCE");
await attributesPage.selectAttributeEntityType(entity);
await attributesPage.clickValueRequiredCheckbox();
await attributesPage.waitForNetworkIdleAfterAction(() => attributesPage.clickSaveButton());
Expand Down Expand Up @@ -129,7 +133,9 @@ const attributesWithValuesToBeUpdated = [productAttrWithValues, contentAttrWithV

for (const attribute of attributesWithValuesToBeUpdated) {
test(`TC: SALEOR_127 User should be able to update attribute values in existing ${attribute.name} attribute @e2e @attributes`, async () => {
await attributesPage.gotoExistingAttributePage(attribute.id, attribute.name);
await attributesPage.waitForNetworkIdleAfterAction(() =>
attributesPage.gotoExistingAttributePage(attribute.id, attribute.name),
);
await attributesPage.clickDeleteAttrValueButton(attribute.valueToBeDeleted);
await expect(attributesPage.dialog).toBeVisible();
await attributesPage.deleteAttributeValueDialog.deleteAttributeValue();
Expand All @@ -156,14 +162,18 @@ for (const attribute of attributesWithValuesToBeUpdated) {

for (const attr of ATTRIBUTES.attributesToBeUpdated) {
test(`TC: SALEOR_128 User should be able to edit existing ${attr.name} attribute @e2e @attributes`, async () => {
await attributesPage.gotoExistingAttributePage(attr.id, attr.name);
await attributesPage.waitForNetworkIdleAfterAction(() =>
attributesPage.gotoExistingAttributePage(attr.id, attr.name),
);
await attributesPage.attributeDefaultLabelInput.clear();
await attributesPage.typeAttributeDefaultLabel(`updated ${attr.name}`);
await attributesPage.expandMetadataSection();
await attributesPage.metadataAddFieldButton.click();
await attributesPage.fillMetadataFields("new key", "new value");
await attributesPage.clickSaveButton();
await attributesPage.waitForNetworkIdleAfterAction(() => attributesPage.clickSaveButton());
await attributesPage.expectSuccessBanner();
await attributesPage.expectElementIsHidden(attributesPage.successBanner);
await attributesPage.attributeSelect.waitFor({ state: "visible" });
await expect(attributesPage.attributeSelect).toHaveAttribute("aria-disabled", "true");
await expect(attributesPage.metadataKeyInput).toHaveValue("new key");
await expect(attributesPage.metadataValueInput).toHaveValue("new value");
Expand Down

0 comments on commit dba1594

Please sign in to comment.