Skip to content
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

[Gitlab-91] Updated flaky tests to always run #42

Merged
merged 7 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions tests/base/account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ test.describe('Account information actions', {annotation: {type: 'Account Dashbo
});
});


test.describe('Account address book actions', { annotation: {type: 'Account Dashboard', description: 'Tests for the Address Book'},}, () => {
test.describe.serial('Account address book actions', { annotation: {type: 'Account Dashboard', description: 'Tests for the Address Book'},}, () => {
test.beforeEach(async ({page}) => {
// go to the Adress Book page
await page.goto(slugs.account.addressBookSlug);
await page.waitForLoadState();
});
Expand All @@ -109,20 +107,22 @@ test.describe('Account address book actions', { annotation: {type: 'Account Dash
*/

test('I can add my first address',{ tag: '@address-actions', }, async ({page}, testInfo) => {
// If account has no address, Address Book redirects to the 'Add New Address' page.
// We expect this to be true before continuing.
let addNewAddressTitle = page.getByRole('heading', {level: 1, name: selectors.newAddress.addNewAddressTitle});
testInfo.skip(await addNewAddressTitle.isHidden(), `Heading "Add New Addres" is not found, please check if an address has already been added.`);
const accountPage = new AccountPage(page);

let addNewAddressTitle = page.getByRole('heading', {level: 1, name: selectors.newAddress.addNewAddressTitle});
if(await addNewAddressTitle.isHidden()) {
await accountPage.deleteAllAddresses();
testInfo.annotations.push({ type: 'Notification: deleted addresses', description: `All addresses are deleted to recreate the first address flow.` });
await page.goto(slugs.account.addressNewSlug);
dheesen marked this conversation as resolved.
Show resolved Hide resolved
}

let phoneNumberValue = inputvalues.firstAddress.firstPhoneNumberValue;
let addressValue = inputvalues.firstAddress.firstStreetAddressValue;
let zipCodeValue = inputvalues.firstAddress.firstZipCodeValue;
let cityNameValue = inputvalues.firstAddress.firstCityValue;
let stateValue = inputvalues.firstAddress.firstProvinceValue;

await accountPage.addNewAddress(phoneNumberValue, addressValue, zipCodeValue, cityNameValue, stateValue);

});

/**
Expand All @@ -146,7 +146,6 @@ test.describe('Account address book actions', { annotation: {type: 'Account Dash
let stateValue = inputvalues.secondAddress.secondProvinceValue;

await accountPage.addNewAddress(phoneNumberValue, addressValue, zipCodeValue, cityNameValue, stateValue);

});

/**
Expand All @@ -171,11 +170,12 @@ test.describe('Account address book actions', { annotation: {type: 'Account Dash
let newState = inputvalues.editedAddress.editStateValue;

let editAddressButton = page.getByRole('link', {name: selectors.accountDashboard.editAddressIconButton}).first();
testInfo.skip(await editAddressButton.isHidden(), `Button to edit Address is not found, please check if an address has been added.`);
if(await editAddressButton.isHidden()) {
await page.goto(slugs.account.addressNewSlug);
await accountPage.addNewAddress(inputvalues.firstAddress.firstPhoneNumberValue, inputvalues.firstAddress.firstStreetAddressValue, inputvalues.firstAddress.firstZipCodeValue, inputvalues.firstAddress.firstCityValue, inputvalues.firstAddress.firstProvinceValue);
}

await page.goto(slugs.account.addressBookSlug);
await accountPage.editExistingAddress(newFirstName, newLastName, newStreet, newZipCode, newCity, newState);

});

/**
Expand All @@ -193,15 +193,17 @@ test.describe('Account address book actions', { annotation: {type: 'Account Dash
const accountPage = new AccountPage(page);

let deleteAddressButton = page.getByRole('link', {name: selectors.accountDashboard.addressDeleteIconButton}).first();
testInfo.skip(await deleteAddressButton.isHidden(), `Button to delete Address is not found, please check if an address has been added.`);

if(await deleteAddressButton.isHidden()) {
await page.goto(slugs.account.addressNewSlug);
await accountPage.addNewAddress(inputvalues.firstAddress.firstPhoneNumberValue, inputvalues.firstAddress.firstStreetAddressValue, inputvalues.firstAddress.firstZipCodeValue, inputvalues.firstAddress.firstCityValue, inputvalues.firstAddress.firstProvinceValue);
}
await accountPage.deleteFirstAddressFromAddressBook();
});
});

test.describe('Newsletter actions', { annotation: {type: 'Account Dashboard', description: 'Newsletter tests'},}, () => {
test.beforeEach(async ({page}) => {
// go to the Dashboard page
await page.goto(slugs.account.accountOverviewSlug);
});

Expand Down Expand Up @@ -235,6 +237,4 @@ test.describe('Newsletter actions', { annotation: {type: 'Account Dashboard', de
await expect(newsletterCheckElement).not.toBeChecked();
}
});

});

17 changes: 17 additions & 0 deletions tests/base/fixtures/account.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,21 @@ export class AccountPage {
await this.accountCreationPasswordRepeatField.fill(password);
await this.accountCreationConfirmButton.click();
}

async deleteAllAddresses() {
let addressDeletedNotification = verify.address.addressDeletedNotification;

this.page.on('dialog', async (dialog) => {
if (dialog.type() === 'confirm') {
await dialog.accept();
}
});

while (await this.deleteAddressButton.isVisible()) {
await this.deleteAddressButton.click();
await this.page.waitForLoadState();

await expect(this.page.getByText(addressDeletedNotification)).toBeVisible();
}
}
}
Loading