Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions tests/constants/application-data.js

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

96 changes: 96 additions & 0 deletions tests/integration/components/application/detail-header-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'website-www/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { APPLICATIONS_DATA } from 'website-www/tests/constants/application-data';

module('Integration | Component | application/detail-header', function (hooks) {
setupRenderingTest(hooks);

test('it renders application details correctly', async function (assert) {
const user = APPLICATIONS_DATA;
this.set('application', user);
this.set('isAdmin', false);

await render(hbs`
<Application::DetailHeader
@application={{this.application}}
@isAdmin={{this.isAdmin}}
/>
`);

const { firstName, lastName } = user.biodata;
assert
.dom('[data-test-user-name]')
.includesText(`${firstName} ${lastName}`);
assert.dom('[data-test-status-badge]').hasText(user.status.toUpperCase());
assert.dom('[data-test-score-value]').hasText(String(user.score));
assert
.dom('[data-test-nudge-details]')
.includesText(String(user.nudgeCount));
assert
.dom('[data-test-social-link]')
.exists({ count: Object.keys(user.socialLink).length });

assert.dom('[data-test-button="nudge-button"]').exists();
assert.dom('[data-test-button="edit-button"]').exists();
assert.dom('[data-test-button="navigate-button"]').doesNotExist();
});

test('it renders admin actions correctly', async function (assert) {
const user = APPLICATIONS_DATA;
this.set('application', user);
this.set('isAdmin', true);

await render(hbs`
<Application::DetailHeader
@application={{this.application}}
@isAdmin={{this.isAdmin}}
/>
`);

assert.dom('[data-test-button="navigate-button"]').exists();
assert.dom('[data-test-button="nudge-button"]').doesNotExist();
assert.dom('[data-test-button="edit-button"]').doesNotExist();
});

test('it handles partial location data correctly', async function (assert) {
this.set('application', {
location: { city: 'Mumbai', country: 'India' },
});
await render(
hbs`<Application::DetailHeader @application={{this.application}} />`,
);
assert.dom('[data-test-header-profile]').includesText('Mumbai, India');
});

test('it disables nudge button when status is not pending', async function (assert) {
const app = { ...APPLICATIONS_DATA, status: 'accepted' };
this.set('application', app);
this.set('isAdmin', false);

await render(hbs`
<Application::DetailHeader
@application={{this.application}}
@isAdmin={{this.isAdmin}}
/>
`);

assert.dom('[data-test-button="nudge-button"]').hasAttribute('disabled');
});

test('it disables nudge button based on 24h timeout', async function (assert) {
const now = Date.now();
const recentNudge = new Date(now - 12 * 60 * 60 * 1000).toISOString();

this.set('application', {
status: 'pending',
lastNudgedAt: recentNudge,
});

await render(
hbs`<Application::DetailHeader @application={{this.application}} />`,
);
assert.dom('[data-test-button="nudge-button"]').hasAttribute('disabled');
});
});
59 changes: 59 additions & 0 deletions tests/integration/components/application/feedback-card-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'website-www/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { APPLICATIONS_DATA } from 'website-www/tests/constants/application-data';

module('Integration | Component | application/feedback-card', function (hooks) {
setupRenderingTest(hooks);

test('it renders feedback details correctly', async function (assert) {
const feedback = APPLICATIONS_DATA.feedback[0];
this.set('feedback', feedback);

await render(hbs`
<Application::FeedbackCard
@status={{this.feedback.status}}
@feedbackText={{this.feedback.feedback}}
@reviewerName={{this.feedback.reviewerName}}
@createdAt={{this.feedback.createdAt}}
/>
`);

assert
.dom('[data-test-status-badge]')
.hasText(feedback.status.toUpperCase());
assert.dom('[data-test-feedback-text]').hasText(feedback.feedback);
assert
.dom('[data-test-feedback-reviewer]')
.includesText(feedback.reviewerName);
assert
.dom('[data-test-feedback-date]')
.hasText(new Date(feedback.createdAt).toLocaleDateString());
});

test('it renders N/A for missing date', async function (assert) {
await render(hbs`
<Application::FeedbackCard
@status="rejected"
@feedbackText="No"
@reviewerName="Reviewer"
/>
`);

assert.dom('[data-test-feedback-date]').hasText('N/A');
});

test('it handles invalid date string correctly', async function (assert) {
await render(hbs`
<Application::FeedbackCard
@status="pending"
@feedbackText="Wait"
@reviewerName="Reviewer"
@createdAt="invalid-date"
/>
`);

assert.dom('[data-test-feedback-date]').hasText('N/A');
});
});
48 changes: 48 additions & 0 deletions tests/integration/components/application/info-card-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'website-www/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Component | application/info-card', function (hooks) {
setupRenderingTest(hooks);

test('it renders title and default sections correctly', async function (assert) {
this.set('sections', [
{ label: 'Intro', value: 'Value 1' },
{ label: 'Fact', value: 'Value 2' },
]);

await render(
hbs`<Application::InfoCard @title="About" @sections={{this.sections}} />`,
);

assert.dom('[data-test-info-card-title]').hasText('About');
assert.dom('[data-test-info-section]').exists({ count: 2 });
assert.dom('.info-label').includesText('Intro');
assert.dom('.info-value').includesText('Value 1');

assert
.dom('[data-test-info-section]:nth-child(1) .info-label')
.hasText('Intro');
assert
.dom('[data-test-info-section]:nth-child(1) .info-value')
.hasText('Value 1');
assert
.dom('[data-test-info-section]:nth-child(2) .info-label')
.hasText('Fact');
assert
.dom('[data-test-info-section]:nth-child(2) .info-value')
.hasText('Value 2');
});

test('it handles empty sections correctly', async function (assert) {
this.set('sections', []);

await render(
hbs`<Application::InfoCard @title="Empty" @sections={{this.sections}} />`,
);

assert.dom('[data-test-info-card-title]').hasText('Empty');
assert.dom('[data-test-info-section]').doesNotExist();
});
});
51 changes: 51 additions & 0 deletions tests/integration/components/application/social-link-pill-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'website-www/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module(
'Integration | Component | application/social-link-pill',
function (hooks) {
setupRenderingTest(hooks);

test('it renders the platform and links correctly', async function (assert) {
this.set('platform', 'GitHub');
this.set('userName', 'testuser');

await render(
hbs`<Application::SocialLinkPill @platform={{this.platform}} @userName={{this.userName}} />`,
);

assert
.dom('[data-test-social-link]')
.hasAttribute('href', 'https://github.com/testuser');
assert.dom('[data-test-social-link]').includesText('GitHub');
assert.dom('[data-test-platform="GitHub"]').exists();
});

test('it renders LinkedIn and other platforms correctly', async function (assert) {
this.set('platform', 'LinkedIn');
this.set('userName', 'testuser');

await render(
hbs`<Application::SocialLinkPill @platform={{this.platform}} @userName={{this.userName}} />`,
);

assert
.dom('[data-test-social-link]')
.hasAttribute('href', 'https://linkedin.com/in/testuser');
assert.dom('[data-test-social-link]').includesText('LinkedIn');
});

test('it handles unknown platforms with fallback icon', async function (assert) {
this.set('platform', 'unknown');
this.set('userName', 'user');

await render(
hbs`<Application::SocialLinkPill @platform={{this.platform}} @userName={{this.userName}} />`,
);
assert.dom('[data-test-social-link]').exists();
assert.dom('[data-test-social-link]').includesText('unknown');
});
},
);
32 changes: 32 additions & 0 deletions tests/integration/components/application/status-badge-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'website-www/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Component | application/status-badge', function (hooks) {
setupRenderingTest(hooks);

test('it renders the status in uppercase', async function (assert) {
await render(hbs`<Application::StatusBadge @status="accepted" />`);
assert.dom('[data-test-status-badge]').hasText('ACCEPTED');

await render(hbs`<Application::StatusBadge @status="pending" />`);
assert.dom('[data-test-status-badge]').hasText('PENDING');

await render(hbs`<Application::StatusBadge @status="changes_requested" />`);
assert.dom('[data-test-status-badge]').hasText('CHANGES REQUESTED');
});

test('it applies the correct status class', async function (assert) {
await render(hbs`<Application::StatusBadge @status="accepted" />`);
assert.dom('[data-test-status-badge]').hasClass('status-badge--accepted');

await render(hbs`<Application::StatusBadge @status="rejected" />`);
assert.dom('[data-test-status-badge]').hasClass('status-badge--rejected');
});

test('it fallbacks to PENDING for unknown status', async function (assert) {
await render(hbs`<Application::StatusBadge @status="unknown" />`);
assert.dom('[data-test-status-badge]').hasText('PENDING');
});
});
Loading