Skip to content

Commit 9aca0c2

Browse files
authored
test(extension): add tests for NFT Print Lab (#1873)
1 parent f275f95 commit 9aca0c2

File tree

10 files changed

+225
-14
lines changed

10 files changed

+225
-14
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import NFTPrintLabModal from '../elements/NFTs/NFTPrintLabModal';
2+
import { expect } from 'chai';
3+
import { t } from '../utils/translationService';
4+
5+
class NFTPrintLabModalAssert {
6+
async assertSeeModal(shouldBeDisplayed: boolean) {
7+
await NFTPrintLabModal.dialog.waitForDisplayed({ reverse: !shouldBeDisplayed });
8+
if (shouldBeDisplayed) {
9+
await NFTPrintLabModal.title.waitForDisplayed();
10+
expect(await NFTPrintLabModal.title.getText()).to.equal(await t('browserView.nfts.printlab.modal.title'));
11+
await NFTPrintLabModal.disclaimer.waitForDisplayed();
12+
expect(await NFTPrintLabModal.disclaimer.getText()).to.equal(
13+
await t('browserView.nfts.printlab.disclaimer.full.part1')
14+
);
15+
await NFTPrintLabModal.caption.waitForDisplayed();
16+
expect(await NFTPrintLabModal.caption.getText()).to.equal(
17+
await t('browserView.nfts.printlab.disclaimer.full.nftprintlabLinkCaption')
18+
);
19+
await NFTPrintLabModal.cancelButton.waitForDisplayed();
20+
expect(await NFTPrintLabModal.cancelButton.getText()).to.equal(await t('browserView.nfts.printlab.modal.cancel'));
21+
await NFTPrintLabModal.continueButton.waitForDisplayed();
22+
expect(await NFTPrintLabModal.continueButton.getText()).to.equal(
23+
await t('browserView.nfts.printlab.modal.continue')
24+
);
25+
}
26+
}
27+
}
28+
29+
export default new NFTPrintLabModalAssert();

packages/e2e-tests/src/assert/nftAssert.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable no-undef */
1+
/* global WebdriverIO */
22
import { TestnetPatterns } from '../support/patterns';
33
import NftsPage from '../elements/NFTs/nftsPage';
44
import NftDetails from '../elements/NFTs/nftDetails';
@@ -13,6 +13,7 @@ import adaHandleAssert from './adaHandleAssert';
1313
import NftsCommon from '../elements/NFTs/nftsCommon';
1414
import { scrollToTheTop } from '../utils/scrollUtils';
1515
import { getExtensionUUID } from '../utils/firefoxUtils';
16+
import localStorageManager from '../utils/localStorageManager';
1617

1718
use(chaiSorted);
1819

@@ -108,6 +109,9 @@ class NftAssert {
108109
async assertSeeNftDetails(nftName: string, mode: 'extended' | 'popup') {
109110
await this.assertSeeNFTDetailsHeader(mode, nftName);
110111
await NftDetails.image.waitForDisplayed();
112+
await this.assertSeeSetAsAvatarButton(true);
113+
const appSettings = await localStorageManager.getItem('appSettings');
114+
await this.assertSeePrintThisNFTButton(JSON.parse(appSettings).chainName === 'Mainnet');
111115
await this.assertSeeNFTDetailsTokenInformationSection();
112116
await this.assertSeeNFTDetailsAttributesSection();
113117
await this.assertSeeSendNFTButton(true);
@@ -138,6 +142,20 @@ class NftAssert {
138142
await this.assertNftDisplayed(shouldBeDisplayed, nftItem);
139143
}
140144

145+
private async assertSeeSetAsAvatarButton(shouldBeDisplayed: boolean) {
146+
await NftDetails.setAsAvatarButton.waitForDisplayed({ reverse: !shouldBeDisplayed });
147+
if (shouldBeDisplayed) {
148+
expect(await NftDetails.setAsAvatarButton.getText()).to.equal(await t('core.nftDetail.setAsAvatar'));
149+
}
150+
}
151+
152+
private async assertSeePrintThisNFTButton(shouldBeDisplayed: boolean) {
153+
await NftDetails.printThisNftButton.waitForDisplayed({ reverse: !shouldBeDisplayed });
154+
if (shouldBeDisplayed) {
155+
expect(await NftDetails.printThisNftButton.getText()).to.equal(await t('core.nftDetail.printNft'));
156+
}
157+
}
158+
141159
async assertSeeSendNFTButton(shouldBeDisplayed: boolean) {
142160
await NftDetails.sendNFTButton.waitForDisplayed({ reverse: !shouldBeDisplayed });
143161
if (shouldBeDisplayed) {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* global WebdriverIO */
2+
import { ChainablePromiseElement } from 'webdriverio';
3+
4+
class NFTPrintLabModal {
5+
private DIALOG = '[role="alertdialog"]';
6+
private TITLE = '[data-testid="dialog-title"]';
7+
private DISCLAIMER = '[data-testid="nftprintlab-dialog-disclaimer-part1"]';
8+
private CAPTION = '[data-testid="nftprintlab-dialog-disclaimer-link-caption-1"]';
9+
private CANCEL_BUTTON = '[data-testid="nftprintlab-dialog-go-back-button"]';
10+
private CONTINUE_BUTTON = '[data-testid="nftprintlab-dialog-continue-button"]';
11+
12+
get dialog(): ChainablePromiseElement<WebdriverIO.Element> {
13+
return $(this.DIALOG);
14+
}
15+
16+
get title(): ChainablePromiseElement<WebdriverIO.Element> {
17+
return $(this.TITLE);
18+
}
19+
20+
get disclaimer(): ChainablePromiseElement<WebdriverIO.Element> {
21+
return $(this.DISCLAIMER);
22+
}
23+
24+
get caption(): ChainablePromiseElement<WebdriverIO.Element> {
25+
return $(this.CAPTION);
26+
}
27+
28+
get cancelButton(): ChainablePromiseElement<WebdriverIO.Element> {
29+
return $(this.CANCEL_BUTTON);
30+
}
31+
32+
get continueButton(): ChainablePromiseElement<WebdriverIO.Element> {
33+
return $(this.CONTINUE_BUTTON);
34+
}
35+
36+
async clickOnCancelButton(): Promise<void> {
37+
await this.cancelButton.waitForStable();
38+
await this.cancelButton.click();
39+
}
40+
41+
async clickOnContinueButton(): Promise<void> {
42+
await this.continueButton.waitForStable();
43+
await this.continueButton.click();
44+
}
45+
}
46+
47+
export default new NFTPrintLabModal();

packages/e2e-tests/src/elements/NFTs/nftDetails.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable no-undef */
1+
/* global WebdriverIO */
22
import { ChainablePromiseElement } from 'webdriverio';
33
import CommonDrawerElements from '../CommonDrawerElements';
44
import testContext from '../../utils/testContext';
@@ -7,6 +7,7 @@ class NftDetails {
77
private NFT_DETAILS_DRAWER = '[data-testid="nft-details-drawer"]';
88
private IMAGE = '[data-testid="nft-image"]';
99
private SET_AS_AVATAR_BUTTON = '[data-testid="nft-set-as-avatar-button"]';
10+
private PRINT_THIS_NFT_BUTTON = '[data-testid="nft-print-button"]';
1011
private TOKEN_INFO_SECTION = '[data-testid="nft-info"]';
1112
private TOKEN_INFORMATION_LABEL = '[data-testid="nft-info-label"]';
1213
private ATTRIBUTES_SECTION = '[data-testid="nft-attributes"]';
@@ -51,6 +52,10 @@ class NftDetails {
5152
return this.drawerBody.$(this.SET_AS_AVATAR_BUTTON);
5253
}
5354

55+
get printThisNftButton() {
56+
return this.drawerBody.$(this.PRINT_THIS_NFT_BUTTON);
57+
}
58+
5459
get tokenInfoSection(): ChainablePromiseElement<WebdriverIO.Element> {
5560
return $(this.TOKEN_INFO_SECTION);
5661
}
@@ -123,6 +128,21 @@ class NftDetails {
123128
}
124129
return folderPathText1;
125130
}
131+
132+
async clickOnSendNFTButton(): Promise<void> {
133+
await this.sendNFTButton.waitForStable();
134+
await this.sendNFTButton.click();
135+
}
136+
137+
async clickOnSetAsAvatarButton(): Promise<void> {
138+
await this.setAsAvatarButton.waitForStable();
139+
await this.setAsAvatarButton.click();
140+
}
141+
142+
async clickOnPrintThisNFTButton(): Promise<void> {
143+
await this.printThisNftButton.waitForStable();
144+
await this.printThisNftButton.click();
145+
}
126146
}
127147

128148
export default new NftDetails();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@NftPrintLab-Extended @Testnet @Mainnet
2+
Feature: NFT Print Lab support - extended view
3+
4+
Background:
5+
Given Wallet is synced
6+
7+
@LW-12876
8+
Scenario: Extended View - Print this NFT - Continue
9+
Given I switch network to: "Mainnet" in extended mode
10+
And Wallet is synced
11+
When I navigate to NFTs extended page
12+
And I left click on the NFT with name "Bison Coin" on NFTs page
13+
And I click "Print this NFT" button on NFT details drawer
14+
Then I see "You're leaving Lace for NFTPrintLab.io" modal
15+
When I click on "Continue" button on "You're leaving Lace for NFTPrintLab.io" modal
16+
Then I do not see "You're leaving Lace for NFTPrintLab.io" modal
17+
And NFT Print Lab page is displayed in a new tab
18+
19+
@LW-12877
20+
Scenario: Extended View - Print this NFT - Cancel
21+
Given I switch network to: "Mainnet" in extended mode
22+
And Wallet is synced
23+
When I navigate to NFTs extended page
24+
And I left click on the NFT with name "Bison Coin" on NFTs page
25+
And I click "Print this NFT" button on NFT details drawer
26+
And I click on "Cancel" button on "You're leaving Lace for NFTPrintLab.io" modal
27+
Then I do not see "You're leaving Lace for NFTPrintLab.io" modal
28+
And I am on a NFT details on the extended view for NFT with name: "Bison Coin"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@NftPrintLab-Popup @Testnet @Mainnet
2+
Feature: NFT Print Lab support - popup view
3+
4+
Background:
5+
Given Wallet is synced
6+
7+
@LW-12878
8+
Scenario: Popup View - Print this NFT - Continue
9+
Given I switch network to: "Mainnet" in popup mode
10+
And Wallet is synced
11+
When I navigate to NFTs popup page
12+
And I left click on the NFT with name "Bison Coin" on NFTs page
13+
And I click "Print this NFT" button on NFT details drawer
14+
Then I see "You're leaving Lace for NFTPrintLab.io" modal
15+
When I click on "Continue" button on "You're leaving Lace for NFTPrintLab.io" modal
16+
Then I do not see "You're leaving Lace for NFTPrintLab.io" modal
17+
And NFT Print Lab page is displayed in a new tab
18+
19+
@LW-12879
20+
Scenario: Popup View - Print this NFT - Cancel
21+
Given I switch network to: "Mainnet" in popup mode
22+
And Wallet is synced
23+
When I navigate to NFTs popup page
24+
And I left click on the NFT with name "Bison Coin" on NFTs page
25+
And I click "Print this NFT" button on NFT details drawer
26+
And I click on "Cancel" button on "You're leaving Lace for NFTPrintLab.io" modal
27+
Then I do not see "You're leaving Lace for NFTPrintLab.io" modal
28+
And I am on a NFT details on the popup view for NFT with name: "Bison Coin"

packages/e2e-tests/src/hooks/beforeTagHooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Before(
4040

4141
Before(
4242
{
43-
tags: '@AddressBook-extended or @Transactions-Extended or @Tokens-extended or @Staking-Extended or @LockWallet-extended or @Top-Navigation-Extended or @NFTs-Extended or @NFT-Folders-Extended or @SendTx-Bundles-Extended or @SendTx-Simple-Extended or @MainNavigation-Extended or @Send-Transaction-Metadata-Extended or @Settings-Extended or @DAppConnector or @DAppConnector-Extended or @Analytics-Settings-Extended or @Banxa-Extended or @GeneratePaperWallet or @SignMessage-Extended or @WalletAddressPage-Extended or @NamiMode-Extended or @VotingCenterExtended or @DAppExplorer-Extended or @WalletRenaming-Extended or @SharedWalletOnboarding-Extended'
43+
tags: '@AddressBook-extended or @Transactions-Extended or @Tokens-extended or @Staking-Extended or @LockWallet-extended or @Top-Navigation-Extended or @NFTs-Extended or @NFT-Folders-Extended or @SendTx-Bundles-Extended or @SendTx-Simple-Extended or @MainNavigation-Extended or @Send-Transaction-Metadata-Extended or @Settings-Extended or @DAppConnector or @DAppConnector-Extended or @Analytics-Settings-Extended or @Banxa-Extended or @GeneratePaperWallet or @SignMessage-Extended or @WalletAddressPage-Extended or @NamiMode-Extended or @VotingCenterExtended or @DAppExplorer-Extended or @WalletRenaming-Extended or @SharedWalletOnboarding-Extended or @NftPrintLab-Extended'
4444
},
4545
async () => {
4646
await extendedViewRepositoryWalletInitialization([TestWalletName.TestAutomationWallet]);
@@ -50,7 +50,7 @@ Before(
5050

5151
Before(
5252
{
53-
tags: '@Tokens-popup or @Transactions-Popup or @Staking-Popup or @LockWallet-popup or @Top-Navigation-Popup or @AddressBook-popup or @Common-Popup or @SendTx-Simple-Popup or @MainNavigation-Popup or @Settings-Popup or @NFTs-Popup or @NFT-Folders-Popup or @Send-Transaction-Metadata-Popup or @ForgotPassword or @DAppConnector-Popup or @Analytics-Settings-Popup or @Banxa-Popup or @NamiMode-Popup or @VotingCenterPopup or @DAppExplorer-Popup or @WalletRenaming-Popup'
53+
tags: '@Tokens-popup or @Transactions-Popup or @Staking-Popup or @LockWallet-popup or @Top-Navigation-Popup or @AddressBook-popup or @Common-Popup or @SendTx-Simple-Popup or @MainNavigation-Popup or @Settings-Popup or @NFTs-Popup or @NFT-Folders-Popup or @Send-Transaction-Metadata-Popup or @ForgotPassword or @DAppConnector-Popup or @Analytics-Settings-Popup or @Banxa-Popup or @NamiMode-Popup or @VotingCenterPopup or @DAppExplorer-Popup or @WalletRenaming-Popup or @NftPrintLab-Popup'
5454
},
5555
async () => {
5656
await popupViewRepositoryWalletInitialization([TestWalletName.TestAutomationWallet]);

packages/e2e-tests/src/steps/nftsExtendedSteps.ts

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import NftDetails from '../elements/NFTs/nftDetails';
55
import nftCreateFolderAssert from '../assert/nftCreateFolderAssert';
66
import nftSelectNftsAssert from '../assert/nftSelectNftsAssert';
77
import { progressWithSendUntilPasswordPage } from '../helpers/NFTPageHelper';
8+
import NFTPrintLabModalAssert from '../assert/NFTPrintLabModalAssert';
9+
import NFTPrintLabModal from '../elements/NFTs/NFTPrintLabModal';
10+
import commonAssert from '../assert/commonAssert';
811

912
Then(
1013
/^NFT with name: "([^"]*)" (is displayed|is not displayed) in coin selector$/,
@@ -21,14 +24,20 @@ Given(
2124
);
2225

2326
When(
24-
/^I click "(Send NFT|Set as your wallet avatar)" button on NFT details drawer$/,
25-
async (button: 'Send NFT' | 'Set as your wallet avatar') => {
26-
if (button === 'Send NFT') {
27-
await NftDetails.sendNFTButton.waitForStable();
28-
await NftDetails.sendNFTButton.click();
29-
} else if (button === 'Set as your wallet avatar') {
30-
await NftDetails.setAsAvatarButton.waitForStable();
31-
await NftDetails.setAsAvatarButton.click();
27+
/^I click "(Send NFT|Set as your wallet avatar|Print this NFT)" button on NFT details drawer$/,
28+
async (button: 'Send NFT' | 'Set as your wallet avatar' | 'Print this NFT') => {
29+
switch (button) {
30+
case 'Send NFT':
31+
await NftDetails.clickOnSendNFTButton();
32+
break;
33+
case 'Set as your wallet avatar':
34+
await NftDetails.clickOnSetAsAvatarButton();
35+
break;
36+
case 'Print this NFT':
37+
await NftDetails.clickOnPrintThisNFTButton();
38+
break;
39+
default:
40+
throw new Error(`Unsupported button: ${button}`);
3241
}
3342
}
3443
);
@@ -94,3 +103,27 @@ Then(
94103
await nftAssert.assertSeeCustomAdaHandleNftDetails(mode);
95104
}
96105
);
106+
107+
Then(/^I (see|do not see) "You're leaving Lace for NFTPrintLab.io" modal$/, async (state: 'see' | 'do not see') => {
108+
await NFTPrintLabModalAssert.assertSeeModal(state === 'see');
109+
});
110+
111+
When(
112+
/^I click on "(Cancel|Continue)" button on "You're leaving Lace for NFTPrintLab.io" modal$/,
113+
async (button: 'Cancel' | 'Continue') => {
114+
switch (button) {
115+
case 'Cancel':
116+
await NFTPrintLabModal.clickOnCancelButton();
117+
break;
118+
case 'Continue':
119+
await NFTPrintLabModal.clickOnContinueButton();
120+
break;
121+
default:
122+
throw new Error(`Unsupported button: ${button}`);
123+
}
124+
}
125+
);
126+
127+
Then(/^NFT Print Lab page is displayed in a new tab$/, async () => {
128+
await commonAssert.assertSeeTabWithUrl('https://nftprintlab.io/');
129+
});

packages/e2e-tests/wdio.conf.base.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ export const config: WebdriverIO.Config = {
6969
'./src/features/WalletAccounts*.feature'
7070
],
7171
batch9: ['./src/features/SendTransactionSimplePopup*.feature'],
72-
batch10: ['./src/features/MultiDelegationPageExtended*.feature'],
72+
batch10: [
73+
'./src/features/MultiDelegationPageExtended*.feature',
74+
'./src/features/NFTPrintLabExtended.feature',
75+
'./src/features/NFTPrintLabPopup.feature'
76+
],
7377
batch11: [
7478
'./src/features/analytics/AnalyticsSend*.feature',
7579
'./src/features/analytics/AnalyticsSetting*.feature',

packages/e2e-tests/wdio.conf.firefox.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ const firefoxConfig = {
5555
'./src/features/WalletAccounts*.feature'
5656
],
5757
batch9: ['./src/features/SendTransactionSimplePopup*.feature'],
58-
batch10: ['./src/features/MultiDelegationPageExtended*.feature'],
58+
batch10: [
59+
'./src/features/MultiDelegationPageExtended*.feature',
60+
'./src/features/NFTPrintLabExtended.feature',
61+
'./src/features/NFTPrintLabPopup.feature'
62+
],
5963
batch11: ['./src/features/e2e/StakingInitialFundsE2E.feature', './src/features/SharedWalletOnboarding.feature'],
6064
batch12: [
6165
'./src/features/AdaHandleExtended.feature',

0 commit comments

Comments
 (0)