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

[PB-985]: feature/playwright e2e tests #1233

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3079e25
The first commit contains the creation of the folders: data, helper, …
QAZebass Aug 9, 2024
51c4bb0
login tests was updated and sign up tests are being developed. Still …
QAZebass Aug 14, 2024
68cb6de
existing tests were refined. The folder creation tests was initialize…
QAZebass Aug 15, 2024
568f4d6
faker.js installed. Locators folder deleted for simplicity and use of…
QAZebass Sep 9, 2024
a176dc5
fixed tests that depended on locators folder
QAZebass Sep 9, 2024
c5f6cf6
Hide banner in development mode
Sep 11, 2024
2a8096f
Dinamyc new user per test run was added
QAZebass Sep 12, 2024
a7f3d94
Merge branch 'feature/playwright-e2e-tests' of https://github.com/int…
QAZebass Sep 12, 2024
25b5ed4
BasePage deleted, Edge browser project configured, flaky tests fixed.…
QAZebass Sep 19, 2024
5b3fc8c
unnecessary waits deleted, credentials passed through credentials.json
QAZebass Sep 23, 2024
dbfbe8d
Locators, staticdata, upload folder and first test about file deletio…
QAZebass Nov 13, 2024
58b4951
Added staging env for playwright tests
Nov 15, 2024
1862a2e
Merge branch 'master' into feature/playwright-e2e-tests
Nov 15, 2024
860bf7e
Add required node version to playwright action
Nov 15, 2024
4692429
Run local front to run tests in local env
Nov 15, 2024
2bd3c2c
Change on playwright ci to run dev server
Nov 15, 2024
0d60175
corrected login test url
Nov 15, 2024
670dbee
Changed wait to wrong endpoint
Nov 15, 2024
d513f84
Removed cypress test run from ci action
Nov 15, 2024
f0ddcf6
Diplay on boarding tutorial only in production environment
Nov 18, 2024
d82f8f6
Merge branch 'master' into feature/playwright-e2e-tests
CandelR Jan 13, 2025
b353088
Changed e2e tests url in config files and minor changes
CandelR Jan 13, 2025
cd482e2
Store email in lowercase in order to match with sign up email
CandelR Jan 13, 2025
1876de9
Fixed e2e imports
CandelR Jan 13, 2025
bcd51ad
Modified playwright.yml to add staging env
CandelR Jan 13, 2025
fa99af1
Increased time to be visible Drive text
CandelR Jan 14, 2025
76ba52e
Added headed by default
CandelR Jan 14, 2025
0a86c59
Added screenshots on failure option
CandelR Jan 14, 2025
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
9 changes: 9 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ jobs:
- run: echo "@internxt:registry=https://npm.pkg.github.com" >> .npmrc
- run: echo //npm.pkg.github.com/:_authToken=${{ secrets.PERSONAL_ACCESS_TOKEN }} >> .npmrc
- run: echo "always-auth=true" >> .npmrc
- run: echo REACT_APP_NODE_ENV=staging >> ./.env
- name: Install dependencies
run: npm install -g yarn && yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Start dev server
run: yarn start & npx wait-on http://localhost:3000
- name: Run Playwright tests
run: yarn playwright test
- uses: actions/upload-artifact@v4
Expand All @@ -35,3 +38,9 @@ jobs:
name: playwright-report
path: playwright-report/
retention-days: 30
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-artifacts
path: test-results/
retention-days: 30
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@craco/craco": "^7.1.0",
"@faker-js/faker": "^9.0.0",
"@internxt/eslint-config-internxt": "^1.0.3",
"@internxt/prettier-config": "^1.0.1",
"@playwright/test": "^1.44.1",
Expand Down
47 changes: 35 additions & 12 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
import 'dotenv/config';

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './test/e2e',
expect: {
timeout: 4000,
},
timeout: 70000,

testDir: './test/e2e/tests/specs',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
Expand All @@ -24,27 +28,40 @@ export default defineConfig({
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
baseURL: 'https://drive.internxt.com/login',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to run the test with the current branch in a local environment, not pointing to the production frontend, the backend could be the production one but not the frontend.
If you point to the production frontend you are not testing the actual changes.

screenshot: 'only-on-failure',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
outputDir: 'test-results',

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
name: 'setup',
testMatch: /.*\.setup\.ts/,
testDir: './test/e2e/tests/specs',
},
{
name: 'Internxt E2E tests on chromium',
testDir: './test/e2e/tests/specs',
use: { ...devices['Desktop Chrome'], storageState: './test/e2e/tests/specs/playwright/auth/user.json' },
dependencies: ['setup'],
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
name: 'Internxt E2E tests on firefox',
testDir: './test/e2e/tests/specs',
use: { ...devices['Desktop Firefox'], storageState: './test/e2e/tests/specs/playwright/auth/user.json' },
dependencies: ['setup'],
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
name: 'Internxt E2E tests on webkit',
testDir: './test/e2e/tests/specs',
use: { ...devices['Desktop Safari'], storageState: './test/e2e/tests/specs/playwright/auth/user.json' },
dependencies: ['setup'],
},

/* Test against mobile viewports. */
Expand All @@ -59,8 +76,14 @@ export default defineConfig({

/* Test against branded browsers. */
{
name: 'edge',
use: { ...devices['Desktop Edge'], channel: 'msedge' },
name: 'Internxt E2E tests on Edge',
testDir: './test/e2e/tests/specs',
use: {
...devices['Desktop Edge'],
channel: 'msedge',
storageState: './test/e2e/tests/specs/playwright/auth/user.json',
},
dependencies: ['setup'],
},
// {
// name: 'Google Chrome',
Expand Down
5 changes: 3 additions & 2 deletions src/app/banners/BannerManager.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { UserSettings } from '@internxt/sdk/dist/shared/types/userSettings';
import envService from '../core/services/env.service';
import localStorageService from '../core/services/local-storage.service';
import { useAppSelector } from '../store/hooks';
import { PlanState } from '../store/slices/plan';
import { userSelectors } from '../store/slices/user';
import { UserSettings } from '@internxt/sdk/dist/shared/types/userSettings';

const BANNER_NAME_IN_LOCAL_STORAGE = 'show_banner';
const BANNER_NAME_FOR_FREE_USERS = 'show_free_users_banner';
Expand Down Expand Up @@ -48,7 +49,7 @@ export class BannerManager {
}

handleBannerDisplay(setShowBanner: (show: boolean) => void): void {
if (this.shouldShowBanner()) {
if (this.shouldShowBanner() && envService.isProduction()) {
setTimeout(() => {
setShowBanner(true);
}, 5000);
Expand Down
9 changes: 6 additions & 3 deletions src/app/drive/components/DriveExplorer/DriveExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ import { UserSettings } from '@internxt/sdk/dist/shared/types/userSettings';
import { useHotkeys } from 'react-hotkeys-hook';
import moveItemsToTrash from 'use_cases/trash/move-items-to-trash';

import { Button } from '@internxt/internxtui';
import { Role } from '@internxt/sdk/dist/drive/share/types';
import { getAncestorsAndSetNamePath } from 'app/store/slices/storage/storage.thunks/goToFolderThunk';
import workspacesSelectors from 'app/store/slices/workspaces/workspaces.selectors';
import { t } from 'i18next';
import BannerWrapper from '../../../banners/BannerWrapper';
import deviceService from '../../../core/services/device.service';
import envService from '../../../core/services/env.service';
import errorService from '../../../core/services/error.service';
import localStorageService, { STORAGE_KEYS } from '../../../core/services/local-storage.service';
import navigationService from '../../../core/services/navigation.service';
Expand All @@ -38,7 +41,6 @@ import {
import { useTranslationContext } from '../../../i18n/provider/TranslationProvider';
import notificationsService, { ToastType } from '../../../notifications/services/notifications.service';
import { AdvancedSharedItem } from '../../../share/types';
import { Button } from '@internxt/internxtui';
import { Tutorial } from '../../../shared/components/Tutorial/Tutorial';
import { getSignUpSteps } from '../../../shared/components/Tutorial/signUpSteps';
import { useAppDispatch, useAppSelector } from '../../../store/hooks';
Expand Down Expand Up @@ -69,9 +71,9 @@ import WarningMessageWrapper from '../WarningMessage/WarningMessageWrapper';
import './DriveExplorer.scss';
import { DriveTopBarItems } from './DriveTopBarItems';
import DriveTopBarActions from './components/DriveTopBarActions';
import { getAncestorsAndSetNamePath } from 'app/store/slices/storage/storage.thunks/goToFolderThunk';
import { IRoot } from '../../../store/slices/storage/types';

import { useTrashPagination } from 'app/drive/hooks/trash/useTrashPagination';
import { IRoot } from '../../../store/slices/storage/types';

export const UPLOAD_ITEMS_LIMIT = 3000;

Expand Down Expand Up @@ -211,6 +213,7 @@ const DriveExplorer = (props: DriveExplorerProps): JSX.Element => {
const divRef = useRef<HTMLDivElement | null>(null);

const showTutorial =
envService.isProduction() &&
useAppSelector(userSelectors.hasSignedToday) &&
!isSignUpTutorialCompleted &&
(showSecondTutorialStep || currentTutorialStep === 0);
Expand Down
18 changes: 0 additions & 18 deletions test/e2e/tests/example.spec.ts

This file was deleted.

Empty file added test/e2e/tests/global.d.ts
Empty file.
5 changes: 5 additions & 0 deletions test/e2e/tests/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// global.ts
export const userCredentials = {
email: '',
password: '',
};
38 changes: 38 additions & 0 deletions test/e2e/tests/helper/staticData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export const staticData = {
//CREDENTIALS
invalidPassword: 'invalid',
tooShortPassword: 'tes',
notComplexPassword: 'password',

//URLS
passwordRecoveryLinkURL: 'http://localhost:3000/recovery-link/',
signUpURL: 'http://localhost:3000/new',
driveURL: 'http://localhost:3000/',

//SIGNUP DISCLAIMER
disclaimer:
'Internxt doesn’t store passwords. If you forget your password, you can download a backup key to regain access to your files. Learn more',

//PASSWORD WARNINGS
passwordNotLongEnough: 'Password has to be at least 8 characters long',
passwordNotComplex: 'Password is not complex enough',
passwordWeak: 'Password is weak',
passwordStrong: 'Password is strong',

//PAGE TITLES
termsOfServiceTitle: 'Terms of Service',
needHelpTitle: 'How can we help you?',
howToCreateBackUpKeyPageTitle: 'How do I create a backup key?',
logInPageTitle: 'Log in',

userAlreadyRegistered: 'already registered',
accountRecovery: 'Account recovery',
wrongLoginWarning: 'Invalid username or password',
dontHaveAccountText: 'Don\'t have an account?',
createAccountText: 'Create account',
termsAndConditionsLinkText: 'Terms and conditions',
youAcceptTermsLinkText: 'you accept the terms & conditions',
needHelpLinkText: 'Need help?',
driveTitle: 'Drive',
itemMovedToTrash: 'moved to trash',
};
Loading
Loading