1
0
Fork 0
mirror of https://codeberg.org/beerbrawl/beerbrawl.git synced 2024-09-22 21:20:52 +02:00

refactor: e2e: remove explicit baseUrl usage everywhere

This is set in the appropriate cypress configs anyway, and if that is
done, cypress automatically prepends the configured `baseUrl` to all
cy.visit() calls. [0]

[0] https://docs.cypress.io/api/commands/visit#Arguments

Signed-off-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
Christoph Heiss 2024-07-05 23:28:44 +02:00
parent 916f66fe1b
commit e2aa18acf3
Signed by: c8h4
GPG key ID: 73D5E7FDEE3DE49A
12 changed files with 238 additions and 266 deletions

View file

@ -12,17 +12,15 @@ context('create beer pong table', () => {
cy.loginTestUser();
cy.wait(4000);
cy.fixture('settings').then(settings => {
cy.visit(`${settings.baseUrl}/#/tournaments/1/tables/create`);
cy.visit('/#/tournaments/1/tables/create');
cy.get('input[name="name"]').type('TEST_TABLE');
cy.get('input[name="name"]').type('TEST_TABLE');
cy.get('button#create-beer-pong-table').click();
cy.get('button#create-beer-pong-table').click();
cy.wait('@createBeerPongTable');
cy.wait('@createBeerPongTable');
cy.contains('Successfully created new beer pong table');
});
cy.contains('Successfully created new beer pong table');
});
it('successfully create beer pong table', () => {
@ -30,15 +28,13 @@ context('create beer pong table', () => {
cy.loginTestUser();
cy.wait(4000);
cy.fixture('settings').then(settings => {
cy.visit(`${settings.baseUrl}/#/tournaments/1/tables/create`);
cy.visit('/#/tournaments/1/tables/create');
cy.get('input[name="name"]').type('`');
cy.get('input[name="name"]').type('`');
cy.get('button#create-beer-pong-table').click();
cy.get('button#create-beer-pong-table').click();
cy.contains("Name contains characters that aren't allowed.");
});
cy.contains("Name contains characters that aren't allowed.");
});
it('create beer pong table, but dont fill out the form', () => {
@ -46,12 +42,10 @@ context('create beer pong table', () => {
cy.loginTestUser();
cy.wait(4000);
cy.fixture('settings').then(settings => {
cy.visit(`${settings.baseUrl}/#/tournaments/1/tables/create`);
cy.visit('/#/tournaments/1/tables/create');
cy.get('button#create-beer-pong-table').click();
cy.get('button#create-beer-pong-table').click();
cy.contains('Name is required.');
});
cy.contains('Name is required.');
});
});

View file

@ -25,14 +25,14 @@ context('Get Beer Pong Tables', () => {
});
context('Delete Beer Pong Table', () => {
let firstLoad = true;
beforeEach(() => {
cy.loginTestUser();
cy.wait(2000);
});
it('successfully deletes a beer pong table', () => {
let firstLoad = true;
// Intercept the initial GET request
cy.intercept('GET', '/api/v1/beer-pong-tables/tournament/*', req => {
req.reply(res => {
@ -67,7 +67,7 @@ context('Delete Beer Pong Table', () => {
});
it('cancels beer pong table deletion', () => {
firstLoad = true;
let firstLoad = true;
cy.intercept('GET', '/api/v1/beer-pong-tables/tournament/*', req => {
req.reply(res => {

View file

@ -17,18 +17,16 @@ context('update beer pong table', () => {
cy.loginTestUser();
cy.wait(4000);
cy.fixture('settings').then(settings => {
cy.visit(`${settings.baseUrl}/#/tournaments/1/tables/1/update`);
cy.wait('@getBeerPongTable');
cy.visit('/#/tournaments/1/tables/1/update');
cy.wait('@getBeerPongTable');
cy.get('input[name="name"]').type('TEST_TABLE');
cy.get('input[name="name"]').type('TEST_TABLE');
cy.get('button#update-beer-pong-table').click();
cy.get('button#update-beer-pong-table').click();
cy.wait('@updateBeerPongTable');
cy.wait('@updateBeerPongTable');
cy.contains('Successfully updated beer pong table');
});
cy.contains('Successfully updated beer pong table');
});
it('update beer pong table, but use a banned character as a name', () => {
@ -37,16 +35,14 @@ context('update beer pong table', () => {
cy.loginTestUser();
cy.wait(4000);
cy.fixture('settings').then(settings => {
cy.visit(`${settings.baseUrl}/#/tournaments/1/tables/1/update`);
cy.wait('@getBeerPongTable');
cy.visit('/#/tournaments/1/tables/1/update');
cy.wait('@getBeerPongTable');
cy.get('input[name="name"]').type('`');
cy.get('input[name="name"]').type('`');
cy.get('button#update-beer-pong-table').click();
cy.get('button#update-beer-pong-table').click();
cy.contains("Name contains characters that aren't allowed.");
});
cy.contains("Name contains characters that aren't allowed.");
});
it('update beer pong table, clear name field, but dont fill out the form', () => {
@ -55,15 +51,13 @@ context('update beer pong table', () => {
cy.loginTestUser();
cy.wait(4000);
cy.fixture('settings').then(settings => {
cy.visit(`${settings.baseUrl}/#/tournaments/1/tables/1/update`);
cy.wait('@getBeerPongTable');
cy.visit('/#/tournaments/1/tables/1/update');
cy.wait('@getBeerPongTable');
cy.get('input[name="name"]').clear();
cy.get('input[name="name"]').clear();
cy.get('button#update-beer-pong-table').click();
cy.get('button#update-beer-pong-table').click();
cy.contains('Name is required.');
});
cy.contains('Name is required.');
});
});

View file

@ -31,34 +31,30 @@ context('edit ko-phase for tournament', () => {
cy.contains('Successfully updated KO standing.');
};
cy.fixture('settings').then(settings => {
cy.visit(`http://${settings.baseUrl}/#/tournaments/4/ko-phase`);
cy.visit('/#/tournaments/4/ko-phase');
markDrinksAsPickedUp(3); // team #00
markDrinksAsPickedUp(4); // team #15
selectKoMatchWinner(3);
markDrinksAsPickedUp(3); // team #00
markDrinksAsPickedUp(4); // team #15
selectKoMatchWinner(3);
markDrinksAsPickedUp(6); // team #01
markDrinksAsPickedUp(7); // team #14
selectKoMatchWinner(4);
});
markDrinksAsPickedUp(6); // team #01
markDrinksAsPickedUp(7); // team #14
selectKoMatchWinner(4);
});
it("shouldn't be able to set the teams for a disabled ko-phase round", () => {
cy.loginTestUser();
cy.wait(4000);
cy.fixture('settings').then(settings => {
cy.visit(`http://${settings.baseUrl}/#/tournaments/4/ko-phase`);
cy.visit('/#/tournaments/4/ko-phase');
cy.get('mat-form-field.mat-form-field-disabled')
.first()
.children()
.first()
// force click, because otherwise a timeout happens as input is disabled
.click({ force: true });
cy.get('mat-form-field.mat-form-field-disabled')
.first()
.children()
.first()
// force click, because otherwise a timeout happens as input is disabled
.click({ force: true });
cy.get('mat-option').should('have.length', 0);
});
cy.get('mat-option').should('have.length', 0);
});
});

View file

@ -8,18 +8,16 @@ context('display ko-phase infoscreen for tournament', () => {
fixture: 'infoscreen-ko-standings-teams-only-at-start.json',
}).as('getInfoscreenKoStandings');
cy.fixture('settings').then(settings => {
cy.visit(`http://${settings.baseUrl}/#/infoscreen/1/ko-phase`);
cy.wait('@getInfoscreenKoStandings');
cy.visit('/#/infoscreen/1/ko-phase');
cy.wait('@getInfoscreenKoStandings');
cy.get('.ko-phase-tree')
.children()
.should('have.length', 2 ** 4 + 2 ** 3 + 2 ** 2 + 2 ** 1 + 2 ** 0);
cy.get('.ko-phase-tree')
.children()
.should('have.length', 2 ** 4 + 2 ** 3 + 2 ** 2 + 2 ** 1 + 2 ** 0);
for (let i = 1; i <= 16; i++) {
cy.get('.ko-phase-tree').contains(`Test Team #${i}`).should('have.length', 1);
}
});
for (let i = 1; i <= 16; i++) {
cy.get('.ko-phase-tree').contains(`Test Team #${i}`).should('have.length', 1);
}
});
it('should be able to display the finished ko-phase tree', () => {
@ -27,87 +25,85 @@ context('display ko-phase infoscreen for tournament', () => {
fixture: 'infoscreen-ko-standings-finished-with-winner.json',
}).as('getInfoscreenKoStandings');
cy.fixture('settings').then(settings => {
cy.visit(`http://${settings.baseUrl}/#/infoscreen/1/ko-phase`);
cy.wait('@getInfoscreenKoStandings');
cy.visit('/#/infoscreen/1/ko-phase');
cy.wait('@getInfoscreenKoStandings');
cy.get('.ko-phase-tree')
.children()
.should('have.length', 2 ** 4 + 2 ** 3 + 2 ** 2 + 2 ** 1 + 2 ** 0);
cy.get('.ko-phase-tree')
.children()
.should('have.length', 2 ** 4 + 2 ** 3 + 2 ** 2 + 2 ** 1 + 2 ** 0);
const numberOfOccurencesOfTeam = {
1: 5,
2: 1,
3: 2,
4: 1,
5: 3,
6: 1,
7: 2,
8: 1,
9: 4,
10: 1,
11: 2,
12: 1,
13: 3,
14: 1,
15: 2,
16: 1,
} as Record<number, number>;
const numberOfOccurrencesOfTeam = {
1: 5,
2: 1,
3: 2,
4: 1,
5: 3,
6: 1,
7: 2,
8: 1,
9: 4,
10: 1,
11: 2,
12: 1,
13: 3,
14: 1,
15: 2,
16: 1,
} as Record<number, number>;
const numberOfTimesTeamIsWinner = {
1: 4,
2: 0,
3: 1,
4: 0,
5: 2,
6: 0,
7: 1,
8: 0,
9: 3,
10: 0,
11: 1,
12: 0,
13: 2,
14: 0,
15: 1,
16: 0,
} as Record<number, number>;
const numberOfTimesTeamIsLoser = {
1: 0,
2: 1,
3: 1,
4: 1,
5: 1,
6: 1,
7: 1,
8: 1,
9: 1,
10: 1,
11: 1,
12: 1,
13: 1,
14: 1,
15: 1,
16: 1,
} as Record<number, number>;
const numberOfTimesTeamIsWinner = {
1: 4,
2: 0,
3: 1,
4: 0,
5: 2,
6: 0,
7: 1,
8: 0,
9: 3,
10: 0,
11: 1,
12: 0,
13: 2,
14: 0,
15: 1,
16: 0,
} as Record<number, number>;
const numberOfTimesTeamIsLoser = {
1: 0,
2: 1,
3: 1,
4: 1,
5: 1,
6: 1,
7: 1,
8: 1,
9: 1,
10: 1,
11: 1,
12: 1,
13: 1,
14: 1,
15: 1,
16: 1,
} as Record<number, number>;
for (let i = 1; i <= 16; i++) {
for (let i = 1; i <= 16; i++) {
cy.get(
`.ko-phase-tree mat-card:contains("Test Team #${i.toString().padStart(2, '0')}")`,
).should('have.length', numberOfOccurrencesOfTeam[i]);
if (numberOfTimesTeamIsLoser[i] !== 0) {
cy.get(
`.ko-phase-tree mat-card:contains("Test Team #${i.toString().padStart(2, '0')}")`,
).should('have.length', numberOfOccurencesOfTeam[i]);
if (numberOfTimesTeamIsLoser[i] !== 0) {
cy.get(
`.ko-phase-tree mat-card.team-loser:contains("Test Team #${i.toString().padStart(2, '0')}")`,
).should('have.length', numberOfTimesTeamIsLoser[i]);
}
if (numberOfTimesTeamIsWinner[i] !== 0) {
cy.get(
`.ko-phase-tree mat-card.team-winner:contains("Test Team #${i.toString().padStart(2, '0')}")`,
).should('have.length', numberOfTimesTeamIsWinner[i]);
}
`.ko-phase-tree mat-card.team-loser:contains("Test Team #${i.toString().padStart(2, '0')}")`,
).should('have.length', numberOfTimesTeamIsLoser[i]);
}
if (numberOfTimesTeamIsWinner[i] !== 0) {
cy.get(
`.ko-phase-tree mat-card.team-winner:contains("Test Team #${i.toString().padStart(2, '0')}")`,
).should('have.length', numberOfTimesTeamIsWinner[i]);
}
}
cy.get('.ko-phase-tree mat-card.team-final-winner:contains("Test Team #01")');
});
cy.get('.ko-phase-tree mat-card.team-final-winner:contains("Test Team #01")');
});
});

View file

@ -9,67 +9,61 @@ context('update qualification match results', () => {
});
it('should be able to mark teams as ready', () => {
cy.fixture('settings').then(settings => {
cy.visit(`http://${settings.baseUrl}/#/tournaments/1/qualification-phase`);
cy.visit('/#/tournaments/1/qualification-phase');
cy.get('app-header-card').contains('Qualification Round').should('exist');
cy.get('app-tournament-score-table')
.find('tbody')
.find('button[aria-label="mark team as ready"]')
.should('have.length', 64)
.first()
.click();
cy.get('app-header-card').contains('Qualification Round').should('exist');
cy.get('app-tournament-score-table')
.find('tbody')
.find('button[aria-label="mark team as ready"]')
.should('have.length', 64)
.first()
.click();
cy.get('button[data-cy="confirm-dialog-btn"]').click();
cy.wait(4000);
cy.get('button[data-cy="confirm-dialog-btn"]').click();
cy.wait(4000);
cy.get('app-tournament-score-table')
.find('tbody')
.find('button[aria-label="mark team as ready"]')
.should('have.length', 63);
});
cy.get('app-tournament-score-table')
.find('tbody')
.find('button[aria-label="mark team as ready"]')
.should('have.length', 63);
});
it('should be able to generate qualification matches and mark teams as ready', () => {
cy.fixture('settings').then(settings => {
cy.visit(`http://${settings.baseUrl}/#/tournaments/2/qualification-phase`);
cy.visit('/#/tournaments/2/qualification-phase');
// for tournament2, all teams should already be "ready"
cy.get('app-header-card').contains('Qualification Round').should('exist');
cy.get('app-tournament-score-table')
.find('tbody')
.find('button[aria-label="mark team as ready"]')
.should('have.length', 0);
// for tournament2, all teams should already be "ready"
cy.get('app-header-card').contains('Qualification Round').should('exist');
cy.get('app-tournament-score-table')
.find('tbody')
.find('button[aria-label="mark team as ready"]')
.should('have.length', 0);
cy.get('[data-cy="generate-qualification-matches-btn"]').click();
cy.get('button[data-cy="confirm-dialog-btn"]').click();
cy.get('[data-cy="generate-qualification-matches-btn"]').click();
cy.get('button[data-cy="confirm-dialog-btn"]').click();
cy.get('app-qualification-match-line')
.first()
.as('match')
.should('not.contain', 'Enter match result');
});
cy.get('app-qualification-match-line')
.first()
.as('match')
.should('not.contain', 'Enter match result');
});
it('should be able to mark drinks as picked up and enter match result', () => {
cy.fixture('settings').then(settings => {
cy.visit(`http://${settings.baseUrl}/#/tournaments/3/qualification-phase`);
cy.get('app-qualification-match-line')
.first()
.as('match')
.should('not.contain', 'Enter match result');
cy.visit('/#/tournaments/3/qualification-phase');
cy.get('app-qualification-match-line')
.first()
.as('match')
.should('not.contain', 'Enter match result');
cy.get('@match').find('[data-cy="enter-match-results-btn"]').should('have.attr', 'disabled');
cy.get('@match').find('[data-cy="enter-match-results-btn"]').should('have.attr', 'disabled');
cy.get('@match').find('[data-cy="team1-action-button"]').eq(0).click();
cy.get('button[data-cy="confirm-dialog-btn"]').click();
cy.get('@match').find('[data-cy="team1-action-button"]').eq(0).click();
cy.get('button[data-cy="confirm-dialog-btn"]').click();
cy.get('@match').find('[data-cy="team2-action-button"]').eq(0).click();
cy.get('button[data-cy="confirm-dialog-btn"]').click();
cy.get('@match').find('[data-cy="team2-action-button"]').eq(0).click();
cy.get('button[data-cy="confirm-dialog-btn"]').click();
cy.get('@match')
.find('[data-cy="enter-match-results-btn"]')
.should('not.have.attr', 'disabled');
});
cy.get('@match')
.find('[data-cy="enter-match-results-btn"]')
.should('not.have.attr', 'disabled');
});
});

View file

@ -17,39 +17,39 @@ context('Tournament teams', () => {
});
it('a team can successfully register itself', () => {
cy.fixture('settings').then(settings => {
cy.fixture('tournaments').then(tournaments => {
cy.intercept('GET', '/api/v1/tournaments', { fixture: 'tournaments.json' }).as(
'getTournaments',
);
cy.fixture('tournaments').then(tournaments => {
cy.intercept('GET', '/api/v1/tournaments', { fixture: 'tournaments.json' }).as(
'getTournaments',
);
cy.reload();
cy.wait('@getTournaments');
cy.reload();
cy.wait('@getTournaments');
cy.get('[data-cy="tournaments-list"]')
.children()
.first()
.find('[data-cy="open-copy-team-self-reg-link-dialog"]')
.click();
cy.get('[data-cy="tournaments-list"]')
.children()
.first()
.find('[data-cy="open-copy-team-self-reg-link-dialog"]')
.click();
const { id: tournamentId, publicAccessToken: publicAccessToken } = tournaments[0];
const signupUrl = `http://${settings.baseUrl}/#/tournaments/${tournamentId}/signup?token=${publicAccessToken}`;
const { id: tournamentId, publicAccessToken: publicAccessToken } = tournaments[0];
const signupUrlPath = `/#/tournaments/${tournamentId}/signup?token=${publicAccessToken}`;
cy.get('[data-cy="copy-link-dialog-input"]').should('have.value', signupUrl);
cy.get('[data-cy="copy-link-dialog-input"]')
.invoke('val')
.should(s => expect(s.startsWith('http://') && s.endsWith(signupUrlPath)).to.be.true);
cy.logoutUser();
cy.visit(signupUrl);
cy.logoutUser();
cy.visit(signupUrlPath);
cy.intercept('POST', `/api/v1/tournaments/${tournamentId}/teams?token=*`, req => {
expect(req.query.token).to.equal(publicAccessToken);
expect(req.body.name).to.equal('foobar');
}).as('signupTeamForTournament');
cy.intercept('POST', `/api/v1/tournaments/${tournamentId}/teams?token=*`, req => {
expect(req.query.token).to.equal(publicAccessToken);
expect(req.body.name).to.equal('foobar');
}).as('signupTeamForTournament');
cy.get('[data-cy="team-signup-name-input"]').should('exist').type('foobar');
cy.get('button[type="submit"]').should('exist').click();
cy.get('[data-cy="team-signup-name-input"]').should('exist').type('foobar');
cy.get('button[type="submit"]').should('exist').click();
cy.wait('@signupTeamForTournament');
});
cy.wait('@signupTeamForTournament');
});
});
});

View file

@ -5,9 +5,9 @@ context('Get Tournaments', () => {
cy.intercept('GET', '/api/v1/tournaments', { fixture: 'tournaments.json' }).as(
'getTournaments',
);
//login automatically lands oin /tournaments
// login automatically lands on /tournaments
cy.loginTestUser();
// cy.visit('/#/tournaments');
cy.wait('@getTournaments');
cy.wait(3000);
});
@ -18,11 +18,11 @@ context('Get Tournaments', () => {
});
it('successfully copied team self-registration link', () => {
cy.fixture('settings').then(settings => {
cy.get('[data-cy="open-copy-team-self-reg-link-dialog"]').first().click();
cy.get('[data-cy="copy-button"]').first().click();
cy.assertClipboardContents(`http://${settings.baseUrl}/#/tournaments/1/signup`);
});
cy.get('[data-cy="open-copy-team-self-reg-link-dialog"]').first().click();
cy.get('[data-cy="copy-button"]').first().click();
cy.withClipboardContents(
s => expect(s.startsWith('http://') && s.endsWith('/#/tournaments/1/signup')).to.be.true,
);
});
});
@ -45,7 +45,7 @@ context('Delete Tournament', () => {
// Intercept the DELETE request
cy.intercept('DELETE', '/api/v1/tournaments/*', { statusCode: 200 }).as('deleteTournament');
// Login automaticlly lands on /tournaments
// Login automatically lands on /tournaments
cy.loginTestUser();
cy.wait('@getTournaments');
cy.get('[data-cy="tournaments-list"]').should('exist');

View file

@ -25,7 +25,7 @@ context('update qualification match results', () => {
throw new Error('No tournament token found!');
}
cy.logoutUser();
cy.visit(`http://localhost:4200/#/tournaments/1952/upload-image?token=${token}`);
cy.visit(`/#/tournaments/1952/upload-image?token=${token}`);
cy.get('[data-cy="image-upload-file-input"]').then(subject => {
return cy
.fixture('../fixtures/img.png', 'base64')

View file

@ -1,7 +1,6 @@
{
"username": "admin",
"password": "password",
"baseUrl": "localhost:4200",
"testUser": "testUser",
"testUserPassword": "test_user_password"
}

View file

@ -2,7 +2,7 @@
Cypress.Commands.add('createUser', () => {
cy.fixture('settings').then(settings => {
cy.visit(settings.baseUrl);
cy.visit('/');
cy.get('[data-cy="register-button"]').click();
cy.get('[data-cy="submit-button"]').should('be.visible');
cy.get('input[name="username"]').type(settings.username);
@ -15,7 +15,7 @@ Cypress.Commands.add('createUser', () => {
Cypress.Commands.add('loginUser', () => {
cy.fixture('settings').then(settings => {
cy.visit(settings.baseUrl);
cy.visit('/');
cy.get('input[name="login-username"]').type(settings.username, { force: true });
cy.get('input[name="login-password"]').type(settings.password, { force: true });
cy.get('[data-cy="login-button"]').click({ force: true });
@ -24,7 +24,7 @@ Cypress.Commands.add('loginUser', () => {
Cypress.Commands.add('loginTestUser', () => {
cy.fixture('settings').then(settings => {
cy.visit(settings.baseUrl);
cy.visit('/');
cy.get('input[name="login-username"]').type(settings.testUser, { force: true });
cy.get('input[name="login-password"]').type(settings.testUserPassword, { force: true });
cy.get('[data-cy="login-button"]').click({ force: true });
@ -32,61 +32,55 @@ Cypress.Commands.add('loginTestUser', () => {
});
Cypress.Commands.add('logoutUser', () => {
cy.fixture('settings').then(settings => {
cy.visit(settings.baseUrl);
cy.get('[data-cy="logout-button"]').click();
});
cy.visit('/');
cy.get('[data-cy="logout-button"]').click();
});
Cypress.Commands.add('fillTournamentCreateForm', () => {
cy.fixture('settings').then(settings => {
cy.visit(`${settings.baseUrl}/#/tournaments/create`);
cy.visit('/#/tournaments/create');
const now = new Date();
now.setDate(now.getDate() + 7);
const now = new Date();
now.setDate(now.getDate() + 7);
cy.get('input[name="name"]').type('TEST_TOURNAMENT');
cy.get('input[name="registrationEndDate"]')
.should('be.visible')
.clear({ force: true })
.type(`${now.getDate()}.${now.getMonth() + 1}.${now.getFullYear()}`);
cy.get('input[name="maxParticipants"]').clear({ force: true }).type(16);
cy.get('textarea[name="description"]').type('TEST_TOURNAMENT');
cy.get('input[name="name"]').type('TEST_TOURNAMENT');
cy.get('input[name="registrationEndDate"]')
.should('be.visible')
.clear({ force: true })
.type(`${now.getDate()}.${now.getMonth() + 1}.${now.getFullYear()}`);
cy.get('input[name="maxParticipants"]').clear({ force: true }).type(16);
cy.get('textarea[name="description"]').type('TEST_TOURNAMENT');
cy.get('button#create-tournament').click();
cy.get('button#create-tournament').click();
cy.wait(200);
cy.wait(200);
cy.contains('Successfully created new tournament');
});
cy.contains('Successfully created new tournament');
});
Cypress.Commands.add('fillTournamentCreateFormWithInvalidData', () => {
cy.fixture('settings').then(settings => {
cy.visit(`${settings.baseUrl}/#/tournaments/create`);
cy.visit('/#/tournaments/create');
const now = new Date();
now.setDate(now.getDate() - 1);
const now = new Date();
now.setDate(now.getDate() - 1);
cy.get('input[name="maxParticipants"]').clear({ force: true }).type(-1);
cy.get('input[name="registrationEndDate"]')
.clear({ force: true })
.type(`${now.getDate()}.${now.getMonth() + 1}.${now.getFullYear()}`);
cy.get('input[name="maxParticipants"]').clear({ force: true }).type(-1);
cy.get('input[name="registrationEndDate"]')
.clear({ force: true })
.type(`${now.getDate()}.${now.getMonth() + 1}.${now.getFullYear()}`);
cy.get('button#create-tournament').click();
cy.get('button#create-tournament').click();
cy.wait(200);
cy.wait(200);
cy.contains('Name is required.');
cy.contains('Registration end needs to be in the future.');
cy.contains('At least 16 participants are required.');
});
cy.contains('Name is required.');
cy.contains('Registration end needs to be in the future.');
cy.contains('At least 16 participants are required.');
});
Cypress.Commands.add('assertClipboardContents', value => {
Cypress.Commands.add('withClipboardContents', testFn => {
cy.window().then(window => {
window.navigator.clipboard.readText().then(text => {
expect(text).to.eq(value);
testFn(text);
});
});
});

View file

@ -31,5 +31,10 @@ declare namespace Cypress {
* Fill the tournament create form with invalid data
*/
fillTournamentCreateFormWithInvalidData(): void;
/**
* Calls the specified `testFn` with the current clipboard contents.
*/
withClipboardContents(testFn: (content: string) => void): void;
}
}