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

Make Cypress tests more resilient #2249

Merged
merged 15 commits into from Mar 28, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/actions/setup-system/action.yml
Expand Up @@ -58,6 +58,17 @@ runs:
curl -L# 'https://github.com/rui314/mold/releases/download/v2.4.0/mold-2.4.0-x86_64-linux.tar.gz' \
| sudo tar -xzf- -C /usr/local

- name: Remove 32-bit libs and incompatible pre-installed pkgs from Runner
shell: bash
if: ${{ runner.os == 'Linux' }}
run: |
dpkg -l | grep i386
sudo apt-get purge --allow-remove-essential libc6-i386 ".*:i386"
sudo dpkg --remove-architecture i386

# https://github.com/actions/runner-images/issues/9546#issuecomment-2014940361
sudo apt-get remove libunwind-*

- name: Setup Rust and Dependencies
uses: ./.github/actions/setup-rust
with:
Expand All @@ -83,4 +94,4 @@ runs:
pushd scripts
npm i --production
popd
node scripts/preprep.mjs
env NODE_ENV=debug node scripts/preprep.mjs
7 changes: 0 additions & 7 deletions .github/workflows/release.yml
Expand Up @@ -68,13 +68,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Remove 32-bit libs
if: ${{ runner.os == 'Linux' }}
run: |
dpkg -l | grep i386
sudo apt-get purge --allow-remove-essential libc6-i386 ".*:i386"
sudo dpkg --remove-architecture i386
- name: Install Apple API key
if: ${{ runner.os == 'macOS' }}
run: |
Expand Down
28 changes: 20 additions & 8 deletions apps/web/cypress/e2e/1-onboarding.spec.cy.ts
@@ -1,5 +1,12 @@
import { discordUrl, libraryName, privacyUrl } from '../fixtures/onboarding.json';
import { libraryRegex, onboardingRegex } from '../fixtures/routes';
import {
libraryRegex,
newLibraryRegex,
onboardingCreatingLibraryRegex,
onboardingLocationRegex,
onboardingPrivacyRegex,
onboardingRegex
} from '../fixtures/routes';

describe('Onboarding', () => {
// TODO: Create debug flag to bypass auto language detection
Expand All @@ -16,7 +23,7 @@ describe('Onboarding', () => {
.then((url) => (onboardingRegex.test(url) ? url : cy.deleteLibrary(libraryName)));

// Check redirect to initial alpha onboarding screen
cy.url().should('match', /\/onboarding\/alpha$/);
cy.url().should('match', onboardingRegex);

// Check application name is present
cy.get('h1').should('contain', 'Spacedrive');
Expand All @@ -41,7 +48,7 @@ describe('Onboarding', () => {
.click();

// Check we were redirect to Library creation screen
cy.url().should('match', /\/onboarding\/new-library$/);
cy.url().should('match', newLibraryRegex);

// Check create library screen title
cy.get('h2').should('contain', 'Create a Library');
Expand Down Expand Up @@ -70,7 +77,7 @@ describe('Onboarding', () => {
cy.get('@newLibraryButton').click();

// Check redirect to add default locations
cy.url().should('match', /\/onboarding\/locations$/);
cy.url().should('match', onboardingLocationRegex);

// Check we have a Toggle All button
cy.get('#toggle-all').as('toggleAllButton');
Expand All @@ -80,6 +87,11 @@ describe('Onboarding', () => {
if (locations == null || typeof locations !== 'object')
throw new Error('Invalid locations data');

const locationsEntries = Object.entries(locations);

// When there is no default locations, the UI doesn't show any buttons
if (locationsEntries.length <= 0) return;

// Check that default location checkboxes work
for (const state of ['unchecked', 'checked']) {
if (state === 'checked') {
Expand All @@ -90,7 +102,7 @@ describe('Onboarding', () => {
}

// Check we have all the default locations available
for (const [location, locationName] of Object.entries(locations)) {
for (const [location, locationName] of locationsEntries) {
if (typeof locationName !== 'string') throw new Error('Invalid location name');

let newState: typeof state;
Expand All @@ -113,7 +125,7 @@ describe('Onboarding', () => {
cy.get('button').contains('Continue').click();

// Check redirect to privacy screen
cy.url().should('match', /\/onboarding\/privacy$/);
cy.url().should('match', onboardingPrivacyRegex);

// Check privacy screen title
cy.get('h2').should('contain', 'Your Privacy');
Expand All @@ -133,8 +145,8 @@ describe('Onboarding', () => {
// Check we have a button to finish onboarding
cy.get('button[type="submit"]').contains('Continue').click();

// Check redirect to privacy screen
cy.url().should('match', /\/onboarding\/creating-library$/);
// Check redirect to create library screen
cy.url().should('match', onboardingCreatingLibraryRegex);

// FIX-ME: This fails a lot, due to the creating library screen only being show for a short time
// Check creating library screen title
Expand Down
1 change: 1 addition & 0 deletions apps/web/cypress/fixtures/routes.ts
Expand Up @@ -5,4 +5,5 @@ export const onboardingLocationRegex = /\/onboarding\/locations$/;
export const onboardingPrivacyRegex = /\/onboarding\/privacy$/;
export const librarySettingsRegex = /\/settings\/library\/general$/;
export const onboardingLibraryRegex = /\/onboarding\/new-library$/;
export const onboardingCreatingLibraryRegex = /\/onboarding\/creating-library$/;
export const locationRegex = /\/location\/1$/;
5 changes: 5 additions & 0 deletions apps/web/cypress/support/commands.ts
Expand Up @@ -6,6 +6,7 @@ import {
onboardingLibraryRegex,
onboardingLocationRegex,
onboardingPrivacyRegex,
onboardingCreatingLibraryRegex,
onboardingRegex
} from '../fixtures/routes';

Expand Down Expand Up @@ -45,8 +46,12 @@ Cypress.Commands.add('fastOnboarding', (libraryName: string) => {

// Privacy screen
cy.url().should('match', onboardingPrivacyRegex);
cy.get('label').contains('Share the bare minimum').click();
cy.get('button[type="submit"]').contains('Continue').click();

// Check redirect to create library screen
cy.url().should('match', onboardingCreatingLibraryRegex);

// Check redirect to Library
cy.checkUrlIsLibrary();
});
Expand Down