Skip to content

Commit

Permalink
test(e2e): wait for enabled button in quoting test
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi authored and SGrueber committed Apr 21, 2022
1 parent 811b540 commit 4c8b891
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
12 changes: 8 additions & 4 deletions e2e/cypress/integration/pages/checkout/cart.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ export class CartPage {
readonly addToWishlist = new AddToWishlistModule();
readonly addToOrderTemplate = new AddToOrderTemplateModule();

private saveQuoteRequestButton = () => cy.get('[id="createQuote"]');
private saveQuoteRequestButton = () => cy.get('[data-testing-id="create-quote-from-basket"]');

beginCheckout() {
cy.wait(1000);
cy.get(this.tag).find('button').contains('Checkout').click();
}

createQuoteRequest() {
waitLoadingEnd(5000);
createQuoteRequest(waitEnabled = true) {
if (waitEnabled) {
this.saveQuoteRequestButton().should('not.have.class', 'disabled');
cy.wait(3000);
waitLoadingEnd();
}
this.saveQuoteRequestButton().click();
waitLoadingEnd(5000);
waitLoadingEnd();
}

private addToWishlistButton = () => cy.get('ish-shopping-basket').find('[data-testing-id="addToWishlistButton"]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('Basket Handling', () => {
at(FamilyPage, page => page.productList.gotoProductDetailPageBySku(_.product.sku));
at(ProductDetailPage, page => {
page.addProductToCart().its('response.statusCode').should('equal', 201);
waitLoadingEnd();
page.header.miniCart.total.should('contain', _.product.price);
page.header.logout();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Quote Handling as Anonymous User', () => {
page.header.miniCart.goToCart();
});
at(CartPage, page => {
page.createQuoteRequest();
page.createQuoteRequest(false);
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<ng-container *ngIf="isLoggedIn$ | async; else elseTemplate">
<ng-container *ngIf="isLoggedIn$ | async; else disabled">
<a
*ishHasNotRole="['APP_B2B_CXML_USER', 'APP_B2B_OCI_USER']"
class="btn btn-secondary"
id="createQuote"
name="createQuote"
data-testing-id="create-quote-from-basket"
(click)="addToQuote()"
>
{{ 'shopping_cart.quote.create.button' | translate }}
</a>
</ng-container>
<ng-template #elseTemplate>
<span (click)="login()" id="createQuote">
<button class="btn btn-secondary disabled" [title]="'account.login.quotes.message' | translate">
<ng-template #disabled>
<span (click)="login()">
<button
data-testing-id="create-quote-from-basket"
class="btn btn-secondary disabled"
[title]="'account.login.quotes.message' | translate"
>
{{ 'shopping_cart.quote.create.button' | translate }}
</button>
</span>
Expand Down

0 comments on commit 4c8b891

Please sign in to comment.