Skip to content

Test ability to delete repository and activity #1010

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

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<v-menu max-width="350" offset-y left>
<v-menu max-width="350" offset-y left aria-label="additional options">
<template #activator="{ on }">
<v-btn v-on="on" color="primary darken-3" icon tile>
<v-icon>mdi-dots-vertical</v-icon>
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/catalog/create-repository.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { findRepositoryCard } from './utils';

const getDialog = () => cy.findByRole('dialog');
const chance = require('chance').Chance();

describe('create repository', () => {
before(() => cy.visit('/'));
Expand All @@ -11,15 +12,14 @@ describe('create repository', () => {
});

it('should create a new repository using the create dialog', () => {
const repositoryName = `Test_repository_${(new Date()).getTime()}`;
const repositoryName = `Repository - ${chance.sentence({ words: 5 })}`;
cy.findByRole('button', { name: 'Add repository' }).click();
getDialog().within(() => {
cy.findByLabelText(/name/i)
.type(repositoryName);
cy.findByLabelText(/description/i)
.type('Test description');
cy.findByRole('button', { name: /create/i })
.click();
cy.findByRole('button', { name: /create/i }).click();
});
findRepositoryCard(repositoryName);
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/catalog/search-and-filter.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { findRepositoryCard, searchRepository } from './utils.js';
import { findRepositoryCard, searchRepository } from './utils';

describe('ability to search and filter repository catalog', () => {
before(() => cy.visit('/'));
Expand Down
26 changes: 26 additions & 0 deletions cypress/e2e/repository/settings/delete-repository.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { findRepositoryCard } from '../../catalog/utils';

describe('delete repository', () => {
before(function () {
cy.visit('/');
});

beforeEach(function () {
cy.login();
cy.createRepository()
.as('repository')
.then(({ id: repositoryId }) => {
cy.navigateTo({
name: 'repository-info',
params: { repositoryId }
});
});
});

it('should be able to delete the repository', function () {
cy.findByRole('button', { name: 'delete' }).click();
cy.confirmAction('Delete repository?');
cy.assertRoute('catalog');
findRepositoryCard(this.repository.name).should('not.exist');
});
});
29 changes: 29 additions & 0 deletions cypress/e2e/repository/structure/activity-deletion.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {
findActivityItem
} from './utils';

describe('ability to delete child activities', () => {
beforeEach(function () {
cy.visit('/');
cy.login();
cy.createRepository()
.as('repository')
.then(({ id: repositoryId }) => {
cy.seedActivities(repositoryId).as('activities');
cy.openRepository(repositoryId);
});
});

it('should be able to delete the module', function () {
const { module } = this.activities;
clickActivityRemove(module.data.name);
cy.confirmAction('Delete item?');
findActivityItem(module.data.name).should('not.exist');
});
});

function clickActivityRemove(name) {
findActivityItem(name).click().within(() => {
cy.vMenu('additional options', /remove/i);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ describe('ability to create child activities', () => {
});

CHILD_ACTIVITY_TYPES.forEach(type => {
it(`create a "${type}" within "${PARENT_TYPE}" using the add into button`, function () {
cy.get(this.parent).findByRole('button', { name: /add item into/i }).click();
it(`create a "${type}" activity within "${PARENT_TYPE}" activity using the add into button`, function () {
cy.get(this.parent)
.findByRole('button', { name: /add item into/i })
.click();
const name = generateActivityName(type);
getActivityDialog().within(() => {
cy.vSelect('Type', type);
cy.findByLabelText('Name').type(`${name}{enter}`);
cy.findByRole('button', { name: /create/i }).click();
});
findActivityItem(name);
findActivityItem(name).should('be.visible');
});
});
});
4 changes: 2 additions & 2 deletions cypress/e2e/repository/structure/root-activity-creation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ describe('ability to create root activities', () => {
});

ROOT_ACTIVIY_TYPES.forEach(type => {
it(`should create a "${type}" using the add button`, function () {
it(`should create a "${type}" activity using the add into button`, function () {
const name = generateActivityName(type);
createRootActivity(name, type);
findActivityItem(name);
findActivityItem(name).should('be.visible');
});
});

Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/repository/structure/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ const sel = {
addRootBtn: 'repository__createRootActivityBtn'
};

export const generateActivityName = type => `${type} - ${(new Date()).getTime()}`;
const chance = require('chance').Chance();

export const getActivityDialog = () => cy.findByTestId(sel.addDialog);
export const getRootActivityDialog = () => cy.findByTestId(sel.addRootDialog);

export const generateActivityName = type => `${type} - ${chance.sentence({ words: 5 })}`;

export function createRootActivity(name, type) {
cy.findByTestId(sel.addRootBtn).click();
return getRootActivityDialog().within(() => {
cy.vSelect('Type', type);
cy.findByLabelText('Name').type(`${name}{enter}`);
cy.findByLabelText('Name').type(`${name}`);
cy.findByRole('button', { name: /create/i }).click();
});
}
Expand Down
5 changes: 3 additions & 2 deletions cypress/support/e2e/activity.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const generateName = (prefix = 'Activity') => `${prefix} - ${(new Date()).getTime()}`;

const ACTIVITY_TYPES = {
MODULE: 'TEST_SCHEMA/MODULE',
LESSON: 'TEST_SCHEMA/LESSON',
PAGE: 'TEST_SCHEMA/PAGE'
};

const chance = require('chance').Chance();
const generateName = (prefix = 'Activity') => `${prefix} - ${chance.sentence({ words: 5 })}`;

const SAVE_ACTIVITY_ACTION = 'repository/activities/save';
const SET_ENDPOINT_ACTION = 'repository/activities/setEndpoint';

Expand Down
10 changes: 9 additions & 1 deletion cypress/support/e2e/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ Cypress.Commands.add('getRouter', () => cy.getApp().its('$router'));
Cypress.Commands.add('getRoute', () => cy.getApp().its('$route'));
Cypress.Commands.add('getRouteName', () => cy.getRoute().its('name'));
Cypress.Commands.add('assertRoute', name => cy.getRouteName().should('eq', name));
Cypress.Commands.add('navigateTo', route => cy.getRouter().then(router => {
router.replace(route).then(route => {
// TODO: Find a better way to make sure the components are loaded
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1);
return route;
});
}));

// Confirmation dialog actions
Cypress.Commands.add('confirmAction', dialogTitle => {
Expand All @@ -20,7 +28,7 @@ Cypress.Commands.add('cancelAction', dialogTitle => {

const getDialogByTitle = dialogTitle => {
return cy.root()
.findAllByRole('document')
.findAllByRole('dialog')
.filter(`:contains("${dialogTitle}")`)
.eq(0);
};
4 changes: 2 additions & 2 deletions cypress/support/e2e/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

import '@testing-library/cypress/add-commands';
import './common';
import './schema';
import './api';
import './auth';
import './common';
import './repository';
import './schema';
import './activity';
import './vuetify';
4 changes: 2 additions & 2 deletions cypress/support/e2e/repository.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const generateName = () => `Test repository - ${(new Date()).getTime()}`;
const chance = require('chance').Chance();

Cypress.Commands.add('createRepository', (name = generateName()) => {
Cypress.Commands.add('createRepository', (name = `Repository - ${chance.sentence({ words: 5 })}`) => {
return cy.getTestSchema().then(schema => {
return cy.getStore().invoke('dispatch', 'repositories/create', {
schema: schema.id,
Expand Down
4 changes: 4 additions & 0 deletions cypress/support/e2e/vuetify/vMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Cypress.Commands.add('vMenu', (inputLabel, option) => {
cy.findByLabelText(inputLabel).parent().click();
cy.findAllByRole('menuitem').contains(option).click();
});
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"body-parser": "^1.20.0",
"boxen": "^4.1.0",
"bunyan": "^1.8.15",
"chance": "^1.1.8",
"change-case": "^4.1.2",
"cheerio": "^1.0.0-rc.12",
"consolidate": "^0.16.0",
Expand Down